public CatmullRomSpline(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3) { this.p0 = p0; this.p1 = p1; this.p2 = p2; this.p3 = p3; cpX = new CubicPolynomial(); cpY = new CubicPolynomial(); }
static CubicPolynomial CreateNonUniformCatmullRom(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float dt0, float dt1, float dt2) { // compute tangents when parameterized in [t1,t2] Vector3 t1 = (p1 - p0) / dt0 - (p2 - p1) / (dt0 + dt1) + (p2 - p1) / dt1; Vector3 t2 = (p2 - p1) / dt1 - (p3 - p1) / (dt1 + dt2) + (p3 - p2) / dt2; // rescale tangents for parametrization in [0,1] t1 *= dt1; t2 *= dt1; return(CubicPolynomial.Create(p1, t1, p2, t2)); }