Jump to content
  • Advertisement
Sign in to follow this  
BaSSraf

Finding points parallel to a line

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

Say I have a bunch of lines which can be at any angle, how would I plot a parallel line with say 5 pixels distance to that line? (its for tracing the outline of a font to a smaller version) Best regards, Bas

Share this post


Link to post
Share on other sites
Advertisement
(I assume you mean 2D lines.)

Given a line defined by a point P and a direction vector D:

Find the normal of the line (a vector perpendicular to the line's direction) and normalize it:

  N = (-D.y, D.x) / length(D)


Now your new line's direction is of course also D, as the lines are parallel, and the point you get by shifting P along the normal:

D' = D
P' = P + x * N

where x is the distance you want between the lines. If P and D are given in pixels, then x=5 means the new line will be 5 pixels away.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!