如何沿着贝塞尔曲线样条线找到相交的Y值? [英] How to find intersecting Y values along a bezier spline?

查看:189
本文介绍了如何沿着贝塞尔曲线样条线找到相交的Y值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

距我进行此类数学运算已有一段时间,因此也许有人可以为我解答.我不认为这个问题正是我想要的,因为我正在尝试寻找精确x值的交集.

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.

所以我有一条样条,它从X,Y到XX,YY,两端都有控制点.我认为这将是二次曲线(曲线不会交叉)是正确的.我计划使用给定图形库中的路径例程(当前正在考虑HTML5画布)来绘制这条线,因此我不会自己绘制它.

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.

我有一些点,表示为X + n,我想为其找到交点的Y值.我不是在沿着路径的给定点 求位置,而是要在路径上与X线相交的位置.

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).

例程本身看起来并不难画线,所以我可以做到这一点,并测试(沿公差)图上的X值(如果有的话).

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.

*数学

推荐答案

最近,我回答了一个有关如何转换2d的非常相似的问题将样条函数f(t)转换为f(x).答案从一方面的三次方程式(因为三次贝塞尔曲线样条线是最常见的)的精确解到另一方面的简单对等(介于两者之间)之间不等.随便挑.

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.

这篇关于如何沿着贝塞尔曲线样条线找到相交的Y值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆