Calculating Vectors

corkscrew

New member
Joined
Nov 21, 2006
Messages
1
First off, let me say although math is a part of my job and I am interested in it, I am not very good at it. I program Coordinate measuring machines that use X,Y,Z points with I,J,K vectors. The machine automatically calculates the vectors for me. Sometimes there is a need to edit the vectors. In a 2 dimensional (x-y plane) circle, if I approach the circle from 0 degrees, I get IJK vectors of 1,0,0. Approaching from 45 degrees give me IJK vectors of .70711,.70711,0. If I approach the circle from 90 degrees, I get an IJK vector of 0,1,0. I found out that for 2d circles, I can use the following:

I vector=COS(RADIANS(angle))
J vector=COS(RADIANS(90-angle))
K vector= 0

I need to know how to invert the process to get the angle from the
vectors.

In a 3D sphere, if I approach from 45 degrees in the X-Y plane and 45 degrees in the Z, I get an IJK vector of .57735,.57735,.57735.

Per the machines software help file: "the software will normalize the vector, making its length one unit. This vector is used for probe compensation." Hence the 3x by 45 degrees turning into a solid row of .57735's instead of .70711's.

My 2nd question is how can I get the angles if I have the 3D IJK vectors and how do I invert the process to get the 3D vectors from angles.

I understand ½ of the 2D part of my problem but I am totally lost on how to do anything for 3D spheres. Your assistance would be greatly appreciated. Thanks in advance.
 
corkscrew said:
First off, let me say although math is a part of my job and I am interested in it, I am not very good at it. I program Coordinate measuring machines that use X,Y,Z points with I,J,K vectors.
The machine automatically calculates the vectors for me. Sometimes there is a need to edit the vectors. In a 2 dimensional (x-y plane) circle, if I approach the circle from 0 degrees, I get IJK vectors of 1,0,0. Approaching from 45 degrees give me IJK vectors of .70711,.70711,0. If I approach the circle from 90 degrees, I get an IJK vector of 0,1,0. I found out that for 2d circles, I can use the following:

I vector=COS(RADIANS(angle))
J vector=COS(RADIANS(90-angle))
K vector= 0

I need to know how to invert the process to get the angle from the
vectors.

Looks like unit vectors.

If you approach from 45 degrees, you get coordinates \(\displaystyle \H\\(\underbrace{\frac{1}{\sqrt{2}}}_{\text{x}},\underbrace{\frac{1}{\sqrt{2}}}_{\text{y}},\underbrace{0}_{\text{z}})\)

\(\displaystyle \L\\cos^{-1}(\frac{1}{\sqrt{2}})=\frac{\pi}{4}=45\;\ deg\)

\(\displaystyle \L\\sin^{-1}(\frac{1}{\sqrt{2}})=\frac{\pi}{4}=45\;\ deg\)

Since it's 2-dimensional, z=0. See?.

If you have coordinates (0,1,0). You want the angle.

\(\displaystyle cos^{-1}(0)=90\;\ deg\)

\(\displaystyle sin^{-1}(1)=90\;\ deg\)

z=0

Let's try something else:

Suppose you have coordinates (1/2, 1/2, 0)

\(\displaystyle cos^{-1}(\frac{1}{2})=60 \;\ deg\)

\(\displaystyle sin^{-1}(\frac{1}{2})=30 \;\ deg\)

z=0

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[quote:2o2kvg91]

In a 3D sphere, if I approach from 45 degrees in the X-Y plane and 45 degrees in the Z, I get an IJK vector of .57735,.57735,.57735.

I would think it should give you .707106, not .57735

cos(45)=.707106 or \(\displaystyle \frac{1}{\sqrt{2}}\)

\(\displaystyle cos^{-1}(\frac{1}{\sqrt{2}})=\frac{\pi}{4}=45\)

.57735 is \(\displaystyle \frac{1}{\sqrt{3}}\)

\(\displaystyle cos^{-1}(\frac{1}{\sqrt{3}})=0.955316618125 \;\ or \;\ 54.73561 \;\ degrees.\)


Per the machines software help file: "the software will normalize the vector, making its length one unit. This vector is used for probe compensation." Hence the 3x by 45 degrees turning into a solid row of .57735's instead of .70711's.

My 2nd question is how can I get the angles if I have the 3D IJK vectors and how do I invert the process to get the 3D vectors from angles.

I understand ½ of the 2D part of my problem but I am totally lost on how to do anything for 3D spheres. Your assistance would be greatly appreciated. Thanks in advance.
[/quote:2o2kvg91]

When you multiply a nonzero vector by the reciprocal of its length it produces a unit vector. When you multiply v by \(\displaystyle \frac{1}{||v||}\) you normalize the vector.

Example:

Vector vv=(3,4) has length \(\displaystyle ||v||=\sqrt{3^{2}+5^{2}}=5\)

Therefore, \(\displaystyle \frac{1}{||v||}v=\frac{1}{5}(3,4)=(\frac{3}{5},\frac{4}{5})\)

is a unit vector in the same direction as v.

If your angle is from the positive x-axis to v, then

\(\displaystyle (cos({\phi}))i+(sin({\phi}))j\)

Find the vector length 1 that makes an angle of 45 degrees with the positive x-axis:

\(\displaystyle v=cos(45)i+sin(45)j=\frac{1}{\sqrt{2}}i+\frac{1}{\sqrt{2}}j\)

To go the other way:

\(\displaystyle cos^{-1}(\frac{1}{\sqrt{2}})=\frac{\pi}{4}=45\)

\(\displaystyle sin^{-1}(\frac{1}{\sqrt{2}})=\frac{\pi}{4}=45\)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The direction cosines may be of interest.

Find the direction cosines of the vector u=2i-4j+4k.

\(\displaystyle ||u||=\sqrt{4+16+16}=6\)

\(\displaystyle \L\\\frac{u}{||u||}=\frac{1}{3}i-\frac{2}{3}j+\frac{2}{3}k\)

\(\displaystyle cos({\alpha})=\frac{1}{3}; \;\ {\alpha}=cos^{-1}(\frac{1}{3})=71\)

\(\displaystyle cos({\beta})=\frac{-2}{3}; \;\ {\beta}=cos^{-1}(\frac{-2}{3})=132\)

\(\displaystyle cos({\gamma})=\frac{2}{3}; \;\ {\gamma}=cos^{-1}(\frac{2}{3})=48\)

I hope all this helps.
 
Top