Sign in to follow this  

point perpendicular to a vector question

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

Hi, I have a linesegment 'v' and I want to find a point that is at an 'r' distance to v and perpendicular to v(from the starting point of the line segment).Its in 2d so there will be two points on either side of the line.This can be one by solving 2 equations,one by testing dot product and other equation through distanace.Is there an efficient implementation for it???Thanks in advance. Thanks & Regards, brett.

Share this post


Link to post
Share on other sites
vector2 perp(-v.y, v.x);
perp = normalize(perp) * r;
vector2 point1 = start_point + perp;
vector2 point2 = start_point - perp;
Is that what you're looking for?

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
vector2 perp(-v.y, v.x);
perp = normalize(perp) * r;
vector2 point1 = start_point + perp;
vector2 point2 = start_point - perp;
Is that what you're looking for?


Ya thank you very much.But why is (-v.y, v.x) taken??

Share this post


Link to post
Share on other sites
Because 2 perpendicular vectors have a dot product equal to 0
And the dot product v1.v2 = v1.x * v2.x + v1.y * v2.y

so if v2.x = -v1.y and v2.y = v1.x,
v1.v2 = v1.x * -v1.y + v1.y * v1.x = 0

You could also take v2.x = v1.y and v2.y = -v1.x (which is the opposed vector)
This is how the previous poster gets to two distinct solutions (start_point + perp and start_point - perp)

Share this post


Link to post
Share on other sites

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