コード例 #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="from">Anchor point of curve from.</param>
 /// <param name="to">Anchor point of curve to.</param>
 public BezierCurve(BezierAnchor from, BezierAnchor to)
 {
     this.from = from;
     this.to   = to;
 }
コード例 #2
0
 /// <summary>
 /// Evaluate the curve at anchor and time.
 /// </summary>
 /// <param name="from"></param>
 /// <param name="to"></param>
 /// <param name="t"></param>
 /// <returns></returns>
 public static Vector3 Evaluate(BezierAnchor from, BezierAnchor to, float t)
 {
     return(Mathf.Pow(1 - t, 3) * from.point + 3 * t * Mathf.Pow(1 - t, 2) * from.tangent +
            3 * (1 - t) * Mathf.Pow(t, 2) * to.tangent + Mathf.Pow(t, 3) * to.point);
 }
コード例 #3
0
 /// <summary>
 /// Transform anchor.
 /// </summary>
 /// <param name="anchor"></param>
 /// <returns></returns>
 protected BezierAnchor TransformAnchor(BezierAnchor anchor)
 {
     anchor.point   = transform.TransformPoint(anchor.point);
     anchor.tangent = transform.TransformVector(anchor.tangent);
     return(anchor);
 }