Ejemplo n.º 1
0
 /// <summary>
 /// CatmullRom spline.
 /// It's passing through b and c points.
 /// Point a and d is been used to determine tangents.
 /// </summary>
 /// <param name="t">[0,1]</param>
 /// <param name="a">first control (tangent) point</param>
 /// <param name="b">first point [interpolated]</param>
 /// <param name="c">second point [interpolated]</param>
 /// <param name="d">second control (tangent) point</param>
 /// <returns></returns>
 public static Vec2 value(double t, Vec2 a, Vec2 b, Vec2 c, Vec2 d)
 {
     double c0 =  t * ((2.0 - t) * t - 1.0);
     double c1 = (t * t * (3.0 * t - 5.0) + 2.0);
     double c2 =  t * ((4.0 - 3.0 * t) * t + 1.0);
     double c3 = (t - 1.0) * t * t;
     return 0.5 * (c0 * a + c1 * b + c2 * c + c3 * d);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// a.Count == b.Count !!!!!!!
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <param name="t"></param>
 /// <returns></returns>
 public static Bezier merge(Bezier a, Bezier b, double t = 0.5)
 {
     Vec2[] points = new Vec2[a.Count];
     for (int i = 0; i < a.Count; ++i)
         points[i] = t * (a.points[i] + b.points[i]);
     return new Bezier(points);
 }
Ejemplo n.º 3
0
 public Bezier(Vec2[] points_)
 {
     points = points_.ToArray();
     findRange(this);
 }