本文介绍了贝塞尔曲线:强制4点的曲线穿过3D空间中的控制点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了使此发生4分的线索,但仅在2D空间中发生

I have read the thread to make this happen for 4 points but only in 2D space here .

I have implemented the answer for 3D but only for 3 control points here

I have read this post but don't understand the sudo code or the math

Can anyone simplify in java? I don't want to draw the curve as 2 segments of 3 points

解决方案

Formula for cubic Bezier curve component (say X):

X(t) = P0.X*(1-t)^3 + 3*P1.X*(1-t)^2*t + 3*P2.X*(1-t)*t^2 + P3.X*t^3

where P0 and P3 are end points, and P1 an P2 are control points.

We have four points for curve (SrcPt array in that answer), end points coincide with Bezier endpoints, and two internal points on curve should define two control points P1 an P2 of Bezier curve. To calculate, we must know - what t parameters correspond to SrcPt[1] and SrcPt[2]. Let these parameters are 1/3 and 2/3 (possible issues are in linked answers).

So substitute t=1/3 and t=2/3 into the formula above:

SrcPt[1].X = SrcPt[0].X*(1-1/3)^3 + 3*P1.X*(1-1/3)^2*1/3 +
             3*P2.X*(1-1/3)*1/3^2 + SrcPt[3].X*1/3^3
SrcPt[2].X = SrcPt[0].X*(1-2/3)^3 + 3*P1.X*(1-2/3)^2*2/3 +
             3*P2.X*(1-2/3)*(2/3)^2 + SrcPt[3].X*2/3)^3

and solve this system for unknown P1.X and P2.X. So we will have all needed points to describe Bezier curve. Linked answer implements the solution.

Example - how changing t values for the same internal points influences on curve:

这篇关于贝塞尔曲线:强制4点的曲线穿过3D空间中的控制点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:18