/// <summary> /// Gets the curve acceleration at t. /// </summary> /// <param name="t">The curve position parameter.</param> /// <returns>The acceleration vector</returns> public Vector3 GetAcceleration(float t) { int i; if (t >= 1f) { t = 1f; i = _points.Length - 4; } else { t = Mathf.Clamp01(t) * curveCount; i = (int)t; t -= i; i *= 3; } return(transform.TransformPoint(Bezier.GetSecondDerivative(_points[i], _points[i + 1], _points[i + 2], _points[i + 3], t)) - transform.position); }
/// <summary> /// Gets the acceleration. /// </summary> /// <param name="startIndex">The start knot index.</param> /// <param name="endIndex">The end knot index.</param> /// <param name="t">The curve position parameter.</param> /// <returns>The acceleration vector.</returns> public Vector3 GetAcceleration(int startIndex, int endIndex, float t) { int i; if (t >= 1f) { t = 1f; i = (endIndex - 1) * 3; } else { t = Mathf.Clamp01(t) * (endIndex - startIndex); i = (int)t; t -= i; i = (startIndex + i) * 3; } return(transform.TransformPoint(Bezier.GetSecondDerivative(_points[i], _points[i + 1], _points[i + 2], _points[i + 3], t)) - transform.position); }