Jump to content
  • Advertisement


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


Vector along a plane

This topic is 5611 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

How do I rotate a vector so that it is parallel to a plane? I can do this using sin/cos but is there a way to do it in directX? The info I have is 1) The Plane as a D3dPlane 2) The normal of the plane as a d3dvector 3) The vector i want to rotate as a d3dvector I can use the the D3dxmatrixReflect to reflect the vector, but this is more for bounce, and I''m trying to get acceleration along a slope. Learning to fly is easy, but as a tortoise, the landings are really rough.

Share this post

Link to post
Share on other sites
The fastest way I know of is to algebraically simplify the following:

A = input_vector;
N = plane_normal_vector;
P = Projection(A, N); // A onto N
B = A-P; // the remainder, which is aligned to the plane
B = B * Length(A) / Length(B); // fixes the length

// output is B.

I'm about 70% sure that there is a way to do it without the Length() calculations that would be pretty slow. You may be able to remove that part of the equation completely if you simplify the equations algebraically.

You're using this for your ball/landscape thing, right? If so, this might not be the best solution for that situation.

[edited by - Nypyren on March 7, 2003 4:09:39 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!