JAVA3D 多段bezier曲面拼接,如何创建一个三次Bezier曲线时,在3D给予N个点?

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.

解决方案

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

That is, you want to derive two Bezier control points Cj, Dj

for 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

and look up or derive the interpolating aka Catmull-Rom spline

that 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

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

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 )

Does this make sense, is it what you want ?

(For a bounty, I'd cobble some Python / numpy together.)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值