/// <summary> /// Constructor. /// </summary> /// <param name="anchor">Anchor points of curve.</param> public CubicBezierCurve(CubicBezierAnchor anchor) { this.anchor = anchor; }
/// <summary> /// Get curve point base on anchor points and key. /// </summary> /// <param name="anchor">Anchor points of curve.</param> /// <param name="key">Key is in the range(0~1).</param> /// <returns>Point on curve.</returns> public static Vector3 GetPointAt(CubicBezierAnchor anchor, float key) { return(Mathf.Pow(1 - key, 3) * anchor.start + 3 * key * Mathf.Pow(1 - key, 2) * anchor.startTangent + 3 * (1 - key) * Mathf.Pow(key, 2) * anchor.endTangent + Mathf.Pow(key, 3) * anchor.end); }
/// <summary> /// Constructor. /// </summary> public CubicBezierCurve() { anchor = new CubicBezierAnchor(); }