Esempio n. 1
0
 /// <summary>
 ///  Constructor (default tightness and no predefined bernstein polynomial)
 /// </summary>
 /// <param name="rawPoints">List of control point vectors</param>
 /// <param name="b">Predefined Bernstein polynomial (good for reusing)</param>
 /// <param name="tightness">Default curve tightness used for the interpolated vertices</param>
 public Spline3D(List <Coord3d> rawPoints, BernsteinPolynomial b, double tightness)
 {
     this.Tightness = tightness;
     mpointList     = new List <Coord3d>();
     mpointList.AddRange(rawPoints);
     bernstein = b;
 }
Esempio n. 2
0
        public List <Coord3d> ComputeVertices(int resolution)
        {
            UpdateCoefficients();
            resolution += 1;
            if (bernstein == null || bernstein.resolution != resolution)
            {
                bernstein = new BernsteinPolynomial(resolution);
            }
            if (vertices == null)
            {
                vertices = new List <Coord3d>();
            }
            else
            {
                vertices.Clear();
            }
            findCPoints();
            Coord3d deltaP = default(Coord3d);
            Coord3d deltaQ = default(Coord3d);

            resolution -= 1;
            for (int i = 0; i <= numP - 2; i++)
            {
                Coord3d p = points[i];
                Coord3d q = points[i + 1];
                deltaP = delta[i].@add(p);
                deltaQ = q.substract(delta[i + 1]);
                for (int k = 0; k <= resolution - 1; k++)
                {
                    double x = p.x * bernstein.b0[k] + deltaP.x * bernstein.b1[k] + deltaQ.x * bernstein.b2[k] + q.x * bernstein.b3[k];
                    double y = p.y * bernstein.b0[k] + deltaP.y * bernstein.b1[k] + deltaQ.y * bernstein.b2[k] + q.y * bernstein.b3[k];
                    double z = p.z * bernstein.b0[k] + deltaP.z * bernstein.b1[k] + deltaQ.z * bernstein.b2[k] + q.z * bernstein.b3[k];
                    vertices.Add(new Coord3d(x, y, z));
                }
            }
            vertices.Add(points[points.Length - 1]);
            return(vertices);
        }
Esempio n. 3
0
 /// <summary>
 ///  Constructor (default tightness and no predefined bernstein polynomial)
 /// </summary>
 /// <param name="rawPoints">Array of control point vectors</param>
 /// <param name="b">Predefined Bernstein polynomial (good for reusing)</param>
 /// <param name="tightness">Default curve tightness used for the interpolated vertices</param>
 public Spline3D(Coord3d[] rawPoints, BernsteinPolynomial b, double tightness) : this(new List <Coord3d>(rawPoints), b, DEFAULT_TIGHTNESS)
 {
 }