#### Archived

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

# lines and plane

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

## Recommended Posts

can anyone tell me how to project a line onto a plane so that it is parallel with it but not necessarily in the plane. thanks

##### Share on other sites
"can anyone tell me how to project a line onto a plane so that it is parallel with it but not necessarily in the plane."

There are infinitely many ways you can take a line and make it parallel with a plane (without lying in the plane). You need to specify more precisely _which one_ of these infinitely many lines you are interested in.

Also, are you sure you are interested in a _line_? A line is something that has infinite extent in one dimension. I''m guessing you''re probably refering to a _line segment_ (or just _segment_) which is a finite portion of a line.

Assuming you''re talking about a line segment, it has endpoints A and B. You also have a plane P. How do you want the endpoints A and B to be modified to make this segment AB parallel to plane P? Do you want to move A, move B, or move both? Can they move arbitrarily or do you want them to move only perpendicularly to the plane?

Unless you exactly state what it is you want to know, the answers you''ll get are unlikely to be what you need. Conversely, the better you state your problem (which includes using the accepted terminology of the field), the better answers you''ll get.

Christer Ericson
Sony Computer Entertainment, Santa Monica

##### Share on other sites
Line.Dir -= (Line.Dir.Dot(Plane.Normal) / Plane.Normal.Dot(Plane.Normal)) * Plane.Normal;
Line.Dir.Normalise();

the ".... / Plane.Normal.Dot(Plane.Normal)" is only there if the plane normal is not normalised

[edited by - oliii on December 13, 2003 8:06:07 AM]

##### Share on other sites
Allow me to clarify, I need to project a velocity vector onto a plane so as to limit the movement of the object to be parallel to the plane.

##### Share on other sites
quote:
Original post by shaobohou
Allow me to clarify, I need to project a velocity vector onto a plane so as to limit the movement of the object to be parallel to the plane.

If A is your velocity vector and B is your plane normal...

C = A crossproduct B
D = B crossproduct C

D is your projected velocity vector..

Note: Your plane normal B must be a unit vector.

##### Share on other sites
quote:
Original post by shaobohou
Allow me to clarify, I need to project a velocity vector onto a plane so as to limit the movement of the object to be parallel to the plane.

assuming the plane is normalised,

Velocity -= (Velocity.Dot(N)) * N;

else, see above (divide by N.Dot(N)).

##### Share on other sites
Any vector W in R^3 can be decomposed with respect to a plane such that W is the sum of two components, W = U + V, where U is a vector in the plane and V is a vector perpendicular to the plane. You are asking for the U component, given W and some plane H.

V is given by the projection of W onto N, where N is the normal to plane H. Using the projective properties of the dot product (and this is where you should consult a linear algebra book if you are not familiar with them) you obtain V as:

V = Dot(W, N) * N

If N is not normalized, you instead obtain V as:

V = Dot(W, N/Length(N)) * (N/Length(N)) =>
V = Dot(W, N) * N / (Length(N)^2) =>
V = Dot(W, N) * N / Dot(N, N)

Now that you have V and W, you get U as:

U = W - V.

This is now straightforward to translate into code.

Christer Ericson
Sony Computer Entertainment, Santa Monica

##### Share on other sites
thats the same as what oliii said... with more words

##### Share on other sites
"thats the same as what oliii said... with more words"

It is indeed. My opinion is that someone who asks a question at this level generally benefits from more than just a formula with no explanation. Thus the added wordiness.

In fact, your reply could also have benefitted from some explanation as to why it gives the result the OP requested (for unit normals only).

Recall the adage "Give a man a fish..."? Well the same applies to math formulas!

Christer Ericson
Sony Computer Entertainment, Santa Monica

##### Share on other sites
thanks, all of you

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5

• 13
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632926
• Total Posts
3009239
• ### Who's Online (See full list)

There are no registered users currently online

×