Advertisement

Vectors in 3D

Started by March 16, 2002 09:00 PM
10 comments, last by Eyrian 22 years, 11 months ago
How do I find the angle between two vectors in 3D? Would the result be meaningful? I know that in 2D, it''s just the inverse cosine of the dotrproduct over the magnitudes of the two vectors, but in 3d... Eyrian
...project the vectors to the plane in which you are interested and do inverse cosine of the 2D dot product.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Advertisement
You still use the dot product. Its still a 2D problem, consider the plane that both vectors lie on.

ECKILLER
ECKILLER
the dot product of two vectors divided by the product of the lengths of those vectors is equal to the cosine of the angle between the vectors for vectors of any dimension.
quote:
Original post by Anonymous Poster
the dot product of two vectors divided by the product of the lengths of those vectors is equal to the cosine of the angle between the vectors for vectors of any dimension.

Mustn''t the vectors be coplanar?

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
quote:
Original post by Oluseyi
Mustn''t the vectors be coplanar?



Two vectors can be used to define a plane. At least in lighting calculations and the like, the plane you''re interested in is the plane formed by the two vectors. In those cases, you just use the dot product.

Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Advertisement
quote:
Original post by Oluseyi Mustn''t the vectors be coplanar?


Any pair of vectors will always be co-planar.
quote:
Original post by sjelkjd
Any pair of vectors will always be co-planar.

For some reason I keep seeing two vectors that are perpendicular but do not act through any common points - are not coincident. I can''t see how they''re coplanar. Of course I see that any coincident vectors are coplanar; that''s trivial. This, though, has me stumped.

(This is why visualization can be a bad thing...)

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
quote:
Original post by Oluseyi This is why visualization can be a bad thing...

Maybe you''re visualizing lines (with two endpoints each) instead of vectors...?
Just to spare Eyrian some trouble:

a = acos( A dot B / |A||B| )

However, if both A and B are normalized, you can leave |A||B| out of the equation, since that would just be dividing by one
delete this;

This topic is closed to new replies.

Advertisement