Search code examples
pythonmathline

two postions on one straight line, find third postion further away


To the point directly, I have two coordinates on one straight line See pic 1 pic 1 But if I want to find another coordinate that are on the same line just further away, is there a Python pre created function that does that? or do I need to manually try and create one? If I need to create on, how can I do that? that basically takes two positions on the line, and in some way calculates a new on further down the line


Solution

  • If you have line with points p1=(x1,y1) and p2=(x2, y2), then any point on the line might be represented in form:

     x = x1 + (x2 - x1) * t
     y = y1 + (y2 - y1) * t
    

    For value of t in range 0..1 point lies inside segment p1p2, for t<0 and t>1 point lies on continuation of line. So choose needed value of t to place new point properly.