# point perpendicular to a vector question

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

## 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 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 on other sites
Quote:
 Original post by jykvector2 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 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)

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
gaxio
10

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631778
• Total Posts
3002310
×