解释 - 用于通过控制点进行曲线的公式 [英] Explain - Formula to curve through a control point

查看:206
本文介绍了解释 - 用于通过控制点进行曲线的公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于公式通过控制点弯曲的问题。
正如你所知,HTML Canvas有 quadraticCurveTo(x1,y1,x2,y2) x1和x2 是控制点。



但是,当您尝试使用它绘制笔划时,笔划将永远不会触及控制点。



所以我们有这个公式:

  x1 = xt * 2-(x0 + x2)/ 2; 
y1 = yt * 2-(y0 + y2)/ 2;

(xt,yt)你想要通过。 t 用于切线,因为它在该点垂直90度。



重新计算控制点位置。



我从书中得到了这个公式,但是这本书并没有解释它是如何导出的。



任何人都知道这个公式是如何导出的。



谢谢,
Venn。

解决方案

二次贝塞尔曲线由等式描述:



x(t)= x0 *(1-t)^ 2 + 2 * x1 * t *(1-t)+ x2 * t ^ 2



如果我们应用参数值t = 1/2(以某种方式 - 曲线中间),我们将得到您的公式: / p>

x(t = 1/2)= xt = x0 * 1/4 + 2 * x1 * 1/4 + x2 * 1/4

然后



x1 / 2 = xt - (x0 + x2)/ 4



x1 = 2 * xt- code>


I have a question regarding formula curving through a control point. As you know, HTML Canvas has quadraticCurveTo(x1, y1, x2, y2) with x1 and x2 being the control point.

However when you try to draw a stroke using it, the stroke will never touch the control point.

So we have this formula:

x1 = xt * 2 - (x0 + x2) / 2;
y1 = yt * 2 - (y0 + y2) / 2;

(xt, yt) = the point you want to curve through. t for tangent as it is 90 degrees perpendicular at that point.

This recalculates the control point position.

I got this formula from a book, however the book doesn't explain how it is been derived. I tried google around but in vain.

Anyone knows how this formula is derived?

Thanks, Venn.

解决方案

Quadratic Bezier curve is described by equations:

x(t) = x0 * (1-t)^2 + 2 * x1 * t * (1 - t) + x2 * t^2 (and similar for y(t)).

If we apply parameter value t = 1/2 (in some way - middle of the curve), we will get your formula:

x(t=1/2) = xt = x0 * 1/4 + 2 * x1 * 1/4 + x2 * 1/4

then

x1/2 = xt - (x0 + x2)/4

x1 = 2 * xt - (x0 + x2)/2

这篇关于解释 - 用于通过控制点进行曲线的公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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