Sign in to follow this  

Getting vector at a right angle to another?

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

If I have a vector that is say, (1, 0, 5) how can I derive another vector from it that is facing 90 degrees in another direction from it on any given plane? I think it might have something to do with using D3DXVec3Cross() but not sure how exactly.

Share this post


Link to post
Share on other sites
You'd cross it with the planes normal. http://en.wikipedia.org/wiki/Cross_product

Vector perpindicularToYourVectorAndPlaneNormal = Cross(yourVector, planeNormal);

There are two vectors that would satisfy that description, and you'll get either one depending on the order of the parameters of the Cross function. You'll have to choose either a right hand or left hand coordinate system to determine if the order is correct or not.

Share this post


Link to post
Share on other sites
Do you mean that you have the plane normal too, or just that vector?
If you have just that vector, then there are infinite vectors that are perpendicular to it, on the plane where the vector is the normal.
If you also have a plane, in which the vector lies, then you can get a perpendicular vector from the cross-product, of the vector and the plane normal.

So if you have (1, 0, 5) in a plane with normal (0, 1, 0), then you do cross((1, 0, 5), (0, 1, 0)).

The cross product is:

cross(v0, v1)
x = v0.y * v1.z - v0.z * v1.y
y = v0.z * v1.x - v0.x * v1.z
z = v0.x * v1.y - v0.y * v1.z

Share this post


Link to post
Share on other sites
Hi guys,

I was reading your posts and was thinking how I was already doing exactly as you were both saying before realizing that I was for reasons unknown substituting the position of a point rather than a normal as I was intending hence the strange results I was getting.

Thanks for the help anyway! Helped snap me out of my hysteria :P

Share this post


Link to post
Share on other sites

This topic is 3101 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this