Return the point on the line connecting (*x0*, *y0*) -- (*x1*, *y1*) whose distance from (*x0*, *y0*) is *d*.
(x0, y0, x1, y1, d)
| 3299 | |
| 3300 | |
| 3301 | def _point_along_a_line(x0, y0, x1, y1, d): |
| 3302 | """ |
| 3303 | Return the point on the line connecting (*x0*, *y0*) -- (*x1*, *y1*) whose |
| 3304 | distance from (*x0*, *y0*) is *d*. |
| 3305 | """ |
| 3306 | dx, dy = x0 - x1, y0 - y1 |
| 3307 | ff = d / (dx * dx + dy * dy) ** .5 |
| 3308 | x2, y2 = x0 - ff * dx, y0 - ff * dy |
| 3309 | |
| 3310 | return x2, y2 |
| 3311 | |
| 3312 | |
| 3313 | @_docstring.interpd |