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