public static GetPoint ( Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t ) : Vector3 | ||
p0 | Vector3 | |
p1 | Vector3 | |
p2 | Vector3 | |
p3 | Vector3 | |
t | float | |
return | Vector3 |
public static Vector3 GetPoint(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
{
t = Mathf.Clamp01 (t);
Vector3 a = 0.5f * (2f * p1);
Vector3 b = 0.5f * (p2 - p0);
Vector3 c = 0.5f * (2f * p0 - 5f * p1 + 4f * p2 - p3);
Vector3 d = 0.5f * (-p0 + 3f * p1 - 3f * p2 + p3);
Vector3 pos = a + (b * t) + (c * t * t) + (d * t * t * t);
return pos;
}
public Vector3 GetPoint(float t) { int i; if (t >= 1f) { t = 1f; i = points.Length - 4; } else { t = Mathf.Clamp01(t) * CurveCount; i = (int)t; t -= i; // [0, 1] i *= 3; } return(transform.TransformPoint(CatmullRom.GetPoint(points[i], points[i + 1], points[i + 2], points[i + 3], t))); }