Intersection between bezier curve and a line segment

前端 未结 2 1247
挽巷
挽巷 2021-02-05 15:04

I am writing a game in Python (with pygame) that requires me to generate random but nice-looking \"sea\" for each new game. After a long search I settled on an algorithm that in

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-05 15:31

    As a rough outline, rotate and translate the system so that the line segment lies on the X axis. Now the y coordinate is a cubic function of the parameter t. Find the 'zeros' (the analytic formulae will be found in good math texts or wikipedia). Now evaluate the x coordinates corresponding to those zero points and test against your line segment.

提交回复
热议问题