问题描述
所以,我需要找出控制点会是一个三次Bezier曲线时,只需要知道曲线上的点,这些点可以位于3D。这将是理想的,如果我能做到这一点的任何数量的曲线上的点。大部分我发现只能用2D的交易,或只为4分。
So I need to find out where the control points would be for a cubic bezier curve when only knowing points on the curve, the points can lie in 3D. It would be ideal if I could do this for any number of points on the curve. Most of what I have found deals only with 2D, or only for 4 points.
推荐答案
让我看看,如果我理解你:你想要一个插值贝塞尔曲线,经历一个给定的点集P0 P1,...
但绘制贝塞尔曲线,像函数
Let me see if I understand you:you want an interpolating Bezier curve,going through a given set of points P0 P1 ...
but drawn as Bezier curves, with a function like
bezier4( nstep, Pj, Cj, Dj, Pj+1 ) -- control points Cj, Dj
也就是说,你要导出两个贝塞尔控制点CJ,DJ每件PJ - PJ + 1
That is, you want to derive two Bezier control points Cj, Djfor each piece Pj -- Pj+1 ?
之一导出这样的控制点的方法是使用所述伯恩斯坦多项式基
One way of deriving such control points is to use the Bernstein polynomial basis
b0(t) = (1-t)^3
b1(t) = 3 (1-t)^2 t,
b2(t) = 3 (1-t) t^2
b3(t) = t^3
bezier4(t) = b0(t) P0 + b1(t) C0 + b2(t) D0 + b3(t) P1
= P0 at t=0, tangent --> C0
= P1 at t=1, tangent <-- D0
和查找或得到插值又名卡特莫尔-Rom样条即经过P-1 P0 P1 P2:
and look up or derive the interpolating aka Catmull-Rom splinethat goes through P-1 P0 P1 P2:
b0(t) P0
+ b1(t) (P0 + (P1 - P-1) / 6)
+ b2(t) (P1 - (P2 - P0) / 6)
+ b3(t) P1
= P0 at t=0, P1 at t=1
我们想bezier4(吨),以完全相同曲线作为CatmullRom(吨),所以:
We want bezier4(t) to be exactly the same curve as CatmullRom(t), so:
C0 = P0 + (P1 - P-1) / 6
D0 = P1 - (P2 - P0) / 6
由于N点P0 P1 ......(在2D转3D ... anyd),带他们4的时间;每个4,该公式为您提供了2个控制点CJ,DJ为
Given N points P0 P1 ... (in 2d 3d ... anyd), take them 4 at a time;for each 4, that formula gives you 2 control points Cj, Dj for
bezier4( nstep, Pj, Cj, Dj, Pj+1 )
这是否有道理,是不是你想要的?
(对于一个赏金,我会凑齐一些Python / numpy的在一起。)
Does this make sense, is it what you want ?
(For a bounty, I'd cobble some Python / numpy together.)
这篇关于如何创建一个三次Bezier曲线时,在3D给予N个点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!