Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Palidine

Smallest angle between 2 vectors

This topic is 5878 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK i hate myself for not being able to figure this out, but i cant anyway the smallest angle between 2 vectors v and u is: theta = cos-1(v dot u / |v||u|); fine so what''s wrong with my math in the following example. (i''m just trying to prove that i can use this equation before i put it in my game engine): 2 vectors: 1,1,1 1,1,-1 those should be orthagonal, right? anyway calculating theta from the above equation gives: theta = cos-1(1 + 1 - 1 / (sqrt(3) * sqrt(3)) ) theta = cos-1(1/3) which clearly isn''t 90 degrees. it''s something like 70.4 what did i do wrong? are 1,1,1 and 1,1,-1 not orthagonal or am i retarded and did something wrong in my calculation? -me

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Aren''t the two vectors you mentioned anti-parallel, 180 degrees from each other? Orthogonal means they are at right angles to each other, so it would be like:
v: (1,0,0)
u: (0,1,0)
But uh I''m not sure about the smallest angle thing.... actually, I''m not sure what you mean by the "smallest angle", but the equation you gave SHOULD give the angle between the two vectors...
so using the vectors I gave:

v dot u = 0
|v| = 1
|u| =1
cos-1(0/1) = cos-1(0) = 90, thus they are orthogonal...

Share this post


Link to post
Share on other sites
no 1,1,1 and 1,1,-1 should be only 90 degrees seperated. -1,-1,-1 and 1,1,1 are 180degrees seperated.

-me

[edited by - Palidine on April 19, 2002 2:40:48 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Whoops, actually I lied, the two vectors you gave are NOT antiparallel, I don''t know what I was thinking, but anyway, they aren''t orthagonal anyway, but the two vectors I gave were....

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
In order for two vectors to be orthogonal the dot product must be 0.

2 vectors:
1,1,1
1,1,-1

Dot product is: (1*1) + (1*1) + (1*-1) = 1

So your calculation for the angle is probably correct.

Share this post


Link to post
Share on other sites
yeah, i figured that. my brain''s 3D visualization system is messed up i guess. it baffles me why 1,1,1 and 1,1,-1 aren''t orthagonal.

i mean 1,1,1 goes straight out through the "center" of the 1st quadrant of 3-space. 1,1,-1 goes through the "center" of the some other numbered quadrant. in my head it looks exactly like the coordinate axes rotated 45 degrees.

whatever. i trust the equation

-me

Share this post


Link to post
Share on other sites
1, 1, 1 and
-1, -1, -1 are 180 degrees apart. the only time they''re 180 apart is when it''s

x, y, z and -x, -y, -z

why don''t you try, for 90 degrees apart, somthing like

0,0,1
0,1,0

Share this post


Link to post
Share on other sites
Paladine, your visualisation problem arises because your looking in 3d where you're used to looking in 2d. In 2d, the vectors < 1,1 > and < 1,-1 > are orthoganl, but in 3d, when you go out to < 1,1,1 > you are actually going out a length of sqrt(2) in the xy plane and then up 1 unit in the z-axis (assuming your vector basis is aligned with the Cartesian axes). Hence, the angle made between the vector and the xy plane is NOT 45 degrees, as you might have thought by the vector < 1,1,1 > . The vectors < 1,1,SQRT(2) > and < 1,1,-SQRT(2) > are orthoganal and each makes an angle of 45 degrees with the xy plane!

Cheers,

Timkin

[edited by - Timkin on April 19, 2002 11:00:36 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!