# Direction vector along plane?

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

## Recommended Posts

Hi This is probably basic high school maths or something that everyone else learned in kindergarten, but somehow I missed out along the way. So if anyone knows a pre-schooler who can answer this question for me, I'd be very appreciative. :) Lets say I have a plane, and I know it's equation. And I have an object, traveling in a direction along a vector that collides with the plane. I have detected the collision, and all is well with the world. But I then want the object to "slide" along the plane in the same general direction is was heading, but without passing thru the plane. So what I'm asking is, how do I work out the direction vector along the plane, from the plane equation and the original vector? I'm thinking there must be some way of "projecting" the direction vector onto the plane so that I have a new 3D vector which points along the surface of the plane? I really hope this makes sense. I've been reading thru all sorts of vector maths stuff, but because I don't know what this method would be called, I'm not sure what to look for. Any help would be greatly appreciated! Rob.

##### Share on other sites
Quote:
 Original post by UselessRobI'm thinking there must be some way of "projecting" the direction vector onto the plane so that I have a new 3D vector which points along the surface of the plane?

Don't sell yourself short, what you're looking for is precisely called projection [smile] You first project the vector onto the plane normal, and then subtract that from the original vector. What you end up with is a vector on the plane representing the projection of the original vector. The formula is v' = v - (v.n - d)n, where 'v' is the original vector, 'n' is the plane normal, 'd' is the plane distance, and 'v'' is the projected vector. (v.n - d) tells you how far away the vector is from the plane. Multiply that by 'n' gives you a vector with that length which is parallel to the normal. If you then subtract this vector from 'v', then you end up with the projection 'v''. This might be different from equations you would find online for projections, since a projection in the pure mathematical sense is onto a subspace (meaning d = 0), and you wouldn't see that subtraction term.

##### Share on other sites
Hmm. I think of a slightly different solution:

If v is the original direction of motion and n is the plane normal (assuming unit length for simplicity of projection) then IMHO the original motion vector can be splitted into a part v perpendicular to the plane and a part v|| parallel to the plane, so that
v := v + v||
Now, with n being of unit length, the perpendicular part can be expressed as the projection
v := ( v . n ) n
where the dot product computes the projected length, and the scaling of n reconstructs the direction.

Substitution and re-arrangement yields in
v|| = v - ( v . n ) n

For a direction vector there is no definition of a distance. So I don't see how the plane's distance should appear in the wanted problem solution?! Please correct me if I'm wrong.

EDIT: I hope your browsers show up the &perp; correctly, my doesn't do so :(

[Edited by - haegarr on September 18, 2006 3:10:44 AM]

##### Share on other sites
Thanks a lot! This really helped. I've now got a parallel vector happening which goes in the general direction. Exactly what I was looking for!

Thanks for the help guys. Very much appreciated.

Rob.

##### Share on other sites
just a quick fun tip

if your plane normal isn;t normalised (or you aren;t sure), you can do

v|| = v - (( v . n ) / ( n . n )) * n

##### Share on other sites
Quote:
 Original post by haegarrFor a direction vector there is no definition of a distance. So I don't see how the plane's distance should appear in the wanted problem solution?! Please correct me if I'm wrong.

No you're right, it was early in the morning and I was thinking of points [smile]

1. 1
Rutin
65
2. 2
3. 3
4. 4
5. 5

• 17
• 10
• 29
• 20
• 9
• ### Forum Statistics

• Total Topics
633415
• Total Posts
3011768
• ### Who's Online (See full list)

There are no registered users currently online

×