using UnityEngine; public class Bezier { /// /// /// /// /// /// /// 0.0 >= t <= 1.0 /// public static Vector3 BezierCurve(Vector3 P0, Vector3 P1, Vector3 P2, float t) { var t1 = (1 - t) * (1 - t); var t2 = t * (1 - t); var t3 = t * t; return P0 * t1 + 2 * t2 * P1 + t3 * P2; } /// /// /// /// /// /// /// /// 0.0 >= t <= 1.0 /// public static Vector3 BezierCurve(Vector3 P0, Vector3 P1, Vector3 P2, Vector3 P3, float t) { var t1 = (1 - t) * (1 - t) * (1 - t); var t2 = (1 - t) * (1 - t) * t; var t3 = t * t * (1 - t); var t4 = t * t * t; return P0 * t1 + 3 * t2 * P1 + 3 * t3 * P2 + P3 * t4; } }