Basic trig question

Hi…

I know that you can calculate the cosine between two unit vectors is essentially the dot product between those vectors. But what happens if one of those vectors is at the origin? (0,0,0) This would give me a big fat angle of 0. So should I test for this case?

Thanks,

Bode

In that case the dot product doesn’t make sense. Think about measuring the angle “between” a single vector.

On the other hand, the result “a big fat zero” makes sense. A dot B means the length of A when projected onto B. The other way around is also true since A dot B == B dot A. If A is the zero vector, it’s length is zero when projected onto B.

Need to comment my last statement. The actual dot product is not the length of the projection. There are some scale factors involved to get the actual length. It is true for unit vectors however. But if the dot product is zero, then so is the result when scaling it.

Hmmm, I think my confusion lies with what angle the Dot product signifies. If my graphic comes out okay, I can show you what I think my problem is:

If it doesn’t show, click here

What I want to do is calculate the angle of the yellow line. I was assuming that the dot product gives me the cosine of that yellow line . But it sounds like the dot product actually gives you the angle of the green arc. Correct?

Bode

the angle of the yellow line with respect to the x axis? if thats the case youre going to have to do the arc tangent of (by-ay,bx-ax) remember: SOHCAHTOA
Tan(theta)=Opposite/Adjacent=ydist/xdist

so: theta=atan(ydist,xdist)

[This message has been edited by KenR7A (edited 12-01-2002).]

Hi Ken…

Yeah, that’s the formula that I’ve been using. I got confused because I thought that I could just use the dot product as a subsitute for calculating the yellow-line angle (along the X axis).

Ok… the dot product formula (cos(angle)=(A dot B)/((length of A) * (length of B))) gives you the cosine of the angle between A and B.

If you want the angle between the yellow line and the X-axis, use the above formula for the vectors (B-A) and <1,0>. B-A is equivalent to the vector starting at A and terminating at B, and <1,0> will represent the X-axis for that calculation.

that too…hehe. i guess there is more than one way to do it…so your green arc would actually be the dot product of the unit vectors on y and x/1. since its zero: cos(angle)=0 angle = 90

[This message has been edited by KenR7A (edited 12-02-2002).]