1 public class BezierTool
2 {
3 /// <summary>
4 /// 二次贝塞尔曲线
5 /// 公式:(1-t)^2*P0+ 2*(1-t) tP1 + t^2*P2
6 /// </summary>
7 public static Vector3 BezierMath2(Vector3 p0, Vector3 p1, Vector3 p2, float t)
8 {
9 return (1 - t) * (1 - t) * p0 + 2 * (1 - t) * t * p1 + t * t * p2;
10 }
11
12
13 // 三次贝塞尔
14 public static Vector3 Bezier_3(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
15 {
16 return (1 - t) * ((1 - t) * ((1 - t) * p0 + t * p1) + t * ((1 - t) * p1 + t * p2)) + t * ((1 - t) * ((1 - t) * p1 + t * p2) + t * ((1 - t) * p2 + t * p3));
17 }
18 }