在三次贝塞尔曲线上找到给定X的Y? [英] Finding Y given X on a Cubic Bezier Curve?

查看:576
本文介绍了在三次贝塞尔曲线上找到给定X的Y?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种方法,可以让我在给定x坐标的情况下在三次贝塞尔曲线上找到Y坐标.

I need a method that allows me to find the Y-coordinate on a Cubic Bezier Curve, given an x-coordinate.

我遇到了很多地方,告诉我将其视为三次函数,然后尝试查找根,据我所知.然而,三次贝塞尔曲线的方程是(对于x坐标):

I've come across lots of places telling me to treat it as a cubic function then attempt to find the roots, which I understand. HOWEVER the equation for a Cubic Bezier curve is (for x-coords):

X(t) = (1-t)^3 * X0 + 3*(1-t)^2 * t * X1 + 3*(1-t) * t^2 * X2 + t^3 * X3

让我感到困惑的是(1-t)值的增加.例如,如果我用一些随机数填写X值:

What confuses me is the addition of the (1-t) values. For instance, if I fill in the X values with some random numbers:

400 = (1-t)^3 * 100 + 3*(1-t)^2 * t * 600 + 3*(1-t) * t^2 * 800 + t^3 * 800

然后重新排列:

800t^3 + 3*(1-t)*800t^2 + 3*(1-t)^2*600t + (1-t)^3*100 -400 = 0

我仍然不知道(1-t)系数的值. (1-t)仍然未知时,我应该如何求解方程式?

I still don't know the value of the (1-t) coefficients. How I am I supposed to solve the equation when (1-t) is still unknown?

推荐答案

表达三次贝塞尔曲线的三种常见方法.

There are three common ways of expressing a cubic bezier curve.

第一个x是t的函数

x(t) = sum( f_i(t) a_i )
     = (1-t)^3 * x0 + 3*(1-t)^2 * t * x1 + 3*(1-t) * t^2 * x2 + t^3 * x3

第二,y是x的函数

y(x) = sum( f_i(x) a_i )
     = (1-x)^3 * y0 + 3*(1-x)^2 * x * y1 + 3*(1-x) * x^2 * y2 + x^3 * y3

这前两个在数学上是相同的,只是对变量使用了不同的名称.

These first two are mathematically the same, just using different names for the variables.

根据您的描述判断,在三次贝塞尔曲线上找到Y坐标,并为其指定x坐标".我猜想您在使用第二个方程式时遇到问题,正在尝试重新排列第一个方程式以帮助您解决它,就像您应该在第二个方程式中一样.如果是这种情况,则无需重新排列或求解-只需插入x值即可获得解决方案.

Judging by your description "find the Y-coordinate on a Cubic Bezier Curve, given an x-coordinate on it." I'm guessing that you've got a question using the second equation are are trying to rearrange the first equation to help you solve it, where as you should be using the second equation. If thats the case, then no rearranging or solving is required - just plug your x value in and you have the solution.

您可能有第三种情况的方程式,这是丑陋而困难的情况. 这是x和y参数都是第三个变量t的三次方贝塞尔曲线.

Its possible that you have an equation of the third kind case, which is the ugly and hard case. This is both the x and y parameters are cubic Beziers of a third variable t.

x(t) = sum( f_i(t) x_i )
y(t) = sum( f_i(t) y_i )

如果这是您的情况.让我知道,我可以详细说明您需要解决的问题.

If this is your case. Let me know and I can detail what you need to do to solve it.

这篇关于在三次贝塞尔曲线上找到给定X的Y?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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