Getting vector at a right angle to another?

Started by
3 comments, last by programci_84 14 years, 9 months ago
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.
Advertisement
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.
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.yy = v0.z * v1.x - v0.x * v1.zz = v0.x * v1.y - v0.y * v1.z

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
Hi,

I replied a post here. It was about building/rotating matrices but I think you might use the angle-related approach.

Hope this helps.
Rohat.
There's no "hard", and "the impossible" takes just a little time.

This topic is closed to new replies.

Advertisement