Sign in to follow this  

Projecting a line segment on a plane

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

I need to project a line segment ( represented by two vectors, vStart and vEnd ) on a plane ( ax + by + cz + d = 0 ). I'm not very good at 3d math, and I didn't find anything useful on google. Cound you point me to an article or tutorial about this? Anyway, I already know the basics about vectors, planes, matrices etc. I just need this particular operation. Ok, here is my attempt: -find the plane-segment intersection point, call it P -find the intersection point of the vector going from vStart perpendicular towards the plane, parallel to the plane normal (How do I find this?), call this K -The projected segment is now K - P Is this the standard approach? I'm pretty sure there are other ways..

Share this post


Link to post
Share on other sites
simply do

Vector N = Vector(a, b, c); // normal of the plane

float sn = vStart.Dot(N) + d;
float en = vEnd.Dot(N) + d;
float n2 = N.Dot(N); // square length of normal

vStart -= (sn / n2) * N; // projection on plane
vEnd -= (en / n2) * N; // projection on plane



Share this post


Link to post
Share on other sites
Quote:
Original post by oliii
simply do

Vector N = Vector(a, b, c); // normal of the plane

float sn = vStart.Dot(N) + d;
float en = vEnd.Dot(N) + d;
float n2 = N.Dot(N); // square length of normal

vStart -= (sn / n2) * N; // projection on plane
vEnd -= (en / n2) * N; // projection on plane


Thanks, this code works perfectly.
I understand what it does, it's rather simple, but.. why are you computing the square length of the plane normal? The normal has length 1 so it has no effect.

Share this post


Link to post
Share on other sites
Quote:
Original post by Arcibald Wearlot
Quote:
Original post by oliii
simply do

Vector N = Vector(a, b, c); // normal of the plane

float sn = vStart.Dot(N) + d;
float en = vEnd.Dot(N) + d;
float n2 = N.Dot(N); // square length of normal

vStart -= (sn / n2) * N; // projection on plane
vEnd -= (en / n2) * N; // projection on plane


Thanks, this code works perfectly.
I understand what it does, it's rather simple, but.. why are you computing the square length of the plane normal? The normal has length 1 so it has no effect.

for case normal's length !=1

if normal's length is surely 1, then of course you can remove squared length, and use 1 instead.

Share this post


Link to post
Share on other sites
Just to be sure. Else you would have said "uhhh doesn't work!!!! panic!" [grin]

well, to be fair, I'm not sure if it would work then... [embarrass]

Share this post


Link to post
Share on other sites

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