在P5J中找到两条曲线之间的交点
我的画布上有多个弯曲线(使用开始形状/曲面方法绘制)。这些线可能在一个或多个点相交。我想找到任何交叉点的坐标,以便将它们添加到数组中。有人知道我如何处理吗?
I have multiple curved lines on my Canvas (drawn with the beginShape/curvedVertex methods). These lines may intersect at one or more points. I’d like to find the coordinates of any intersections so that I can add them to an array. Does anyone know how I can approach this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为,这个问题更多地是关于数学的。
在计算机程序中,使用太多点绘制图形。例如,如果真实的交叉点为SQRT(2),则不可能使用点找到相交。
数学家提供了许多解决方案。
最好的之一:如果图形被称为连续,请找到2个x和y,以便£:f(x)> g(x)和¥:f(y)< g(y)。因此,相交在[x,y]中。用(x+y)/2替换x和y中的一个,以使£和¥表达式保持。通过这种方式,您将通过迭代此算法来尽可能靠近交叉点。
In my opinion, this question is more about mathematics.
In computer programs, graphs are drawn using too many points. For example, if the real intersection is sqrt(2), It will be impossible to find intersection using points.
Many solutions are provided by mathematicians.
One of the best ones: If the graphs are known as continuous, find 2 points x and y such that £: f(x)>g(x) and ¥: f(y)<g(y). So the intersection is in [x,y]. Replace one of x and y with (x+y)/2 such that £ and ¥ expressions hold. In this way, you will reach as near as you need, to the intersection by iterating this algorithm.