简体   繁体   中英

Method to find x,y point on a spline that is an exact distance from another point

I have a 2-d Spline that is a list of (x,y) tuples. I need to determine a point on the spline where a line of length L falls if one end of the line is placed on an existing spline point.

spline=[(x1,y1),(x2,y2),(xn,yn).....]
Line=200
for i in spline:
    find (xn,yn) 200 units from here

So for each point in the spline, find a (Xn,Yn) (or interpolated value) that is a linear distance of 200 from the chosen point.

Why not compute the distances and compare them to "Line" like this

   spline=[(x1,y1),(x2,y2),(xn,yn).....]
    Line=200
    for x1,y1 in spline:
       for x2,y2 in spline:
           dist=math.sqrt((x2-x1)**2+(y2-y1)**2)
           if dist==Line:
              print x1,y1,'is Line distant from',x2,y2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM