Converting 3D vector to Cartesian triplet x,y,z
Converting 3D vector to Cartesian triplet x,y,z
I just received my DM42 and I'm stuck trying to convert a 3D vector to a Cartesian triplet x,y,z. If someone could give me a hand it would be greatly appreciated.
-
- Posts: 1101
- Joined: Tue May 02, 2017 5:48 pm
- Location: Netherlands
- Contact:
Re: Converting 3D vector to Cartesian triplet x,y,z
Here are two approaches:
Assuming the vector is in the X register, this code will put the first three elements in T, Z, and Y, while leaving the vector in X:
N.B. ↓ is not a short-hand for R↓; it is the matrix editor's "down one element" function, found near the end of the FCN catalog.
Another approach, more flexible, assuming the vector is stored in the variable "VEC":
N.B. Since vectors are, by definition, Nx1 or 1xN, it doesn't matter whether you use ↓ or →, or J+ or I+.
Assuming the vector is in the X register, this code will put the first three elements in T, Z, and Y, while leaving the vector in X:
Code: Select all
EDIT
ENTER
↓
ENTER
↓
ENTER
EXITALL
Another approach, more flexible, assuming the vector is stored in the variable "VEC":
Code: Select all
INDEX "VEC"
RCLEL
J+
RCLEL
J+
RCLEL