[RESOLVED] Angle between two vectors.
I don't have any of my math books here, but I am reading in a game programming book about vectors, but I can't get the same result as the authour. I am getting something else all the time.
I'll give a rep to the first guy that gets the same result as me or the authour for these vectors:
v1 = [1.5, 3.0, 4.0]
v2 = [4.0, 1.0, 2.0]
PS: Please give the angle in both Rad and Deg.
Thanks
- ØØ -
Re: Angle between two vectors.
Hi,
Two words for you, Product and Dot. Not necessarily in that order.
A dot B = mod(A)mod(B)cos(theta)
A.B = (1.5*4)+(3*1)+(4*2) = 6+3+8 = 17
mod(A) = sqrt((1.5^2)+(3^2)+(4^2)) = sqrt(2.25+9+16) = 5.22015....
mod(B) = sqrt((4^2)+(1^2)+(2^2)) = sqrt(16+1+4) = 4.58258...
Hence cos(theta) = 17 / sqrt(27.25*21) = 0.71065...
Hence theta = 44.7 degrees or 0.78 rad
What do you get?
zaza
PS. Lazy whatnot.
Quote:
Please give the angle in both Rad and Deg.
Re: [RESOLVED] Angle between two vectors.
Me:
Angle (Rad): 0.7803741
Angle (Deg): 44.7121424
Authour:
Angle (Rad): 0.26
Angle (Deg): 15.0
So I guess my Vertex class is working after all then..:)...Thanks for the help. I was going nuts..:)
- ØØ -