private Vector3 q5(List <Vector3> p, float t) { Vector3 a = Mathf.Pow(1f - t, 5f) * p[0]; a += (float)CubicSpline.BinomCoefficient(5L, 1L) * t * Mathf.Pow(1f - t, 4f) * p[1]; a += (float)CubicSpline.BinomCoefficient(5L, 2L) * Mathf.Pow(t, 2f) * Mathf.Pow(1f - t, 3f) * p[2]; a += (float)CubicSpline.BinomCoefficient(5L, 3L) * Mathf.Pow(t, 3f) * Mathf.Pow(1f - t, 2f) * p[3]; a += (float)CubicSpline.BinomCoefficient(5L, 4L) * Mathf.Pow(t, 4f) * Mathf.Pow(1f - t, 1f) * p[4]; return(a + Mathf.Pow(t, 5f) * p[5]); }
private Vector3 QuadraticN(List <Vector3> p, float t) { int num = p.Count - 1; Vector3 zero = Vector3.zero; zero.x = Mathf.Pow(1f - t, (float)num) * p[0].x; zero.y = Mathf.Pow(1f - t, (float)num) * p[0].y; zero.z = Mathf.Pow(1f - t, (float)num) * p[0].z; for (int i = 1; i < num; i++) { zero.x += (float)CubicSpline.BinomCoefficient((long)num, (long)i) * Mathf.Pow(1f - t, (float)(num - i)) * (Mathf.Pow(t, (float)i) * p[i].x); zero.y += (float)CubicSpline.BinomCoefficient((long)num, (long)i) * Mathf.Pow(1f - t, (float)(num - i)) * (Mathf.Pow(t, (float)i) * p[i].y); zero.z += (float)CubicSpline.BinomCoefficient((long)num, (long)i) * Mathf.Pow(1f - t, (float)(num - i)) * (Mathf.Pow(t, (float)i) * p[i].z); } zero.x += Mathf.Pow(t, (float)num) * p[num].x; zero.y += Mathf.Pow(t, (float)num) * p[num].y; zero.z += Mathf.Pow(t, (float)num) * p[num].z; return(zero); }
private Vector3 RationalN(List <Vector3> p, float t) { int num = p.Count - 1; Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; Vector3 zero3 = Vector3.zero; for (int i = 0; i < num; i++) { zero2.x += (float)CubicSpline.BinomCoefficient((long)num, (long)i) * Mathf.Pow(1f - t, (float)(num - i)) * p[i].x * 1f; zero2.y += (float)CubicSpline.BinomCoefficient((long)num, (long)i) * Mathf.Pow(1f - t, (float)(num - i)) * p[i].y * 1f; zero2.z += (float)CubicSpline.BinomCoefficient((long)num, (long)i) * Mathf.Pow(1f - t, (float)(num - i)) * p[i].z * 1f; zero3.x += (float)CubicSpline.BinomCoefficient((long)num, (long)i) * Mathf.Pow(1f - t, (float)(num - i)) * 1f; zero3.y += (float)CubicSpline.BinomCoefficient((long)num, (long)i) * Mathf.Pow(1f - t, (float)(num - i)) * 1f; zero3.z += (float)CubicSpline.BinomCoefficient((long)num, (long)i) * Mathf.Pow(1f - t, (float)(num - i)) * 1f; } zero.x = zero2.x / zero3.x; zero.y = zero2.x / zero3.y; zero.z = zero2.x / zero3.z; return(zero); }