How to find intersecting Y values along a bezier spline?

纵然是瞬间 提交于 2019-12-25 05:16:10

问题


It's been a while since I did any maths* of this kind, so perhaps someone can answer this for me. I don't think this question is exactly what I want, because I am trying to find intersections for precise x values.

So I have a spline which goes from X,Y to XX,YY, with control points at each end. I think I would be correct in saying it will be a quadratic curve (the curve will not cross itself). I plan on using the path routines from the given graphics library (currently thinking HTML5 canvas) to draw this line, so I will not be drawing it myself.

I have a number of points, expressed as X + n, for which I want to find the Y value of the intersection. I am not asking for a position at a given point along the path, I am asking the position on the path where it intersects a line X.

I am planning to draw a vertical line to meet up with it, so if possible it would be great if the point were precise enough to meet up with the curve in a convincing looking way (not off by a couple of pixels).

The routines don't look to hard to draw the line myself, so I could do that and just test (with tolerance) for X values along the plot, if it comes to it.

*Math


回答1:


Recently I answered to a very similar question about how to transform 2d spline function f(t) into f(x). The answers there ranged from exact solution of a cubic equation (as cubic bezier splines are the most common ones) on the one end and simple bisecting on the other hand, with various root finding algorithms in between. Take your pick.



来源:https://stackoverflow.com/questions/8953931/how-to-find-intersecting-y-values-along-a-bezier-spline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!