Пример #1
0
        private void Create(List <SplineVertex> points)
        {
            this.controlPoints = new List <SplineVertex>();

            int replicate        = this.isPeriodic ? this.degree : 0;
            int numControlPoints = points.Count + replicate;

            foreach (SplineVertex controlPoint in points)
            {
                SplineVertex vertex = new SplineVertex(controlPoint.Position, controlPoint.Weight);
                this.controlPoints.Add(vertex);
            }

            for (int i = 0; i < replicate; i++)
            {
                SplineVertex vertex = new SplineVertex(points[i].Position, points[i].Weight);
                this.controlPoints.Add(vertex);
            }

            int numKnots = numControlPoints + this.degree + 1;

            this.knots = new List <double>(numKnots);

            double factor = 1.0 / (numControlPoints - this.degree);

            if (!this.isPeriodic)
            {
                int i;
                for (i = 0; i <= this.degree; i++)
                {
                    this.knots.Add(0.0);
                }

                for (; i < numControlPoints; i++)
                {
                    this.knots.Add(i - this.degree);
                }

                for (; i < numKnots; i++)
                {
                    this.knots.Add(numControlPoints - this.degree);
                }
            }
            else
            {
                for (int i = 0; i < numKnots; i++)
                {
                    this.knots.Add((i - this.degree) * factor);
                }
            }
        }
Пример #2
0
        private void Create(List<SplineVertex> points)
        {
            this.controlPoints = new List<SplineVertex>();

            int replicate = this.isPeriodic ? this.degree : 0;
            int numControlPoints = points.Count + replicate;

            foreach (SplineVertex controlPoint in points)
            {
                SplineVertex vertex = new SplineVertex(controlPoint.Position, controlPoint.Weigth);
                this.controlPoints.Add(vertex);
            }

            for (int i = 0; i < replicate; i++)
            {
                SplineVertex vertex = new SplineVertex(points[i].Position, points[i].Weigth);
                this.controlPoints.Add(vertex);
            }

            int numKnots = numControlPoints + this.degree + 1;
            this.knots = new List<double>(numKnots);

            double factor = 1.0/(numControlPoints - this.degree);
            if (!this.isPeriodic)
            {
                int i;
                for (i = 0; i <= this.degree; i++)
                    this.knots.Add(0.0);

                for (; i < numControlPoints; i++)
                    this.knots.Add(i - this.degree);

                for (; i < numKnots; i++)
                    this.knots.Add(numControlPoints - this.degree);
            }
            else
            {
                for (int i = 0; i < numKnots; i++)
                    this.knots.Add((i - this.degree)*factor);
            }
        }