CalculatePoint() public static méthode

Calculates the point on the given bezier curve with the specified t parameter.
public static CalculatePoint ( IList points, float t ) : System.Vector2
points IList The points.
t float The t parameter, a value between 0.0f and 1.0f.
Résultat System.Vector2
        /// <summary>
        /// Calculates the length of the specified bezier curve.
        /// </summary>
        /// <param name="points">The points.</param>
        /// <param name="precision">The precision value.</param>
        /// <param name="parallel">The parallel value.</param>
        /// <returns>Length of curve.</returns>
        /// <remarks><para>The precision gets better as the <paramref name="precision"/>
        /// value gets smaller.</para>
        /// <para>The <paramref name="parallel"/> parameter defines whether the curve should be calculated as a
        /// parallel curve to the original bezier curve. A value of 0.0f represents
        /// the original curve, 5.0f represents a curve that has always a distance
        /// of 5.0f to the orignal curve.</para></remarks>
        public static float CalculateLength(IList <Vector2> points, float precision, float parallel)
        {
            float   length = 0.0f;
            Vector2 old    = BezierCurve.CalculatePoint(points, 0.0f, parallel);

            for (float i = precision; i < (1.0f + precision); i += precision)
            {
                Vector2 n = CalculatePoint(points, i, parallel);
                length += (n - old).Length;
                old     = n;
            }

            return(length);
        }
Exemple #2
0
        public static float CalculateLength(IList <Vector2> points, float precision, float parallel)
        {
            float   num       = 0.0f;
            Vector2 vector2_1 = BezierCurve.CalculatePoint(points, 0.0f, parallel);
            float   t         = precision;

            while ((double)t < 1.0 + (double)precision)
            {
                Vector2 vector2_2 = BezierCurve.CalculatePoint(points, t, parallel);
                num      += (vector2_2 - vector2_1).Length;
                vector2_1 = vector2_2;
                t        += precision;
            }
            return(num);
        }
 /// <summary>
 /// Calculates the point on the given bezier curve with the specified t parameter.
 /// </summary>
 /// <param name="points">The points.</param>
 /// <param name="t">The t parameter, a value between 0.0f and 1.0f.</param>
 /// <returns>Resulting point.</returns>
 public static Vector2 CalculatePoint(IList <Vector2> points, float t)
 {
     return(BezierCurve.CalculatePoint(points, t, 0.0f));
 }
 /// <summary>
 /// Calculates the point with the specified t.
 /// </summary>
 /// <param name="t">The t value, between 0.0f and 1.0f.</param>
 /// <returns>Resulting point.</returns>
 public Vector2 CalculatePoint(float t)
 {
     return(BezierCurve.CalculatePoint(points, t, Parallel));
 }
Exemple #5
0
 public Vector2 CalculatePoint(float t)
 {
     return(BezierCurve.CalculatePoint((IList <Vector2>) this.points, t, this.Parallel));
 }
        /// <summary>
        /// Tessellates the path.
        /// </summary>
        /// <param name="path">The path.</param>
        public void TessellatePath(PathGeometry path)
        {
            _vertexList.Clear();
            _tesselator.EmptyCache();
            _tesselator.BeginPolygon();

            switch(path.FillRule)
            {
                case FillRule.EvenOdd:
                    _tesselator.WindingRule = Tesselator.Tesselator.WindingRuleType.Odd;
                    break;
                case FillRule.Nonzero:
                    _tesselator.WindingRule = Tesselator.Tesselator.WindingRuleType.NonZero;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            foreach (var figure in path.Figures)
            {
                _tesselator.BeginContour();

                foreach (var seg in figure.Segments)
                {
                    if (seg is PolyLineSegment)
                    {
                        var polyline = seg as PolyLineSegment;
                        polyline.Points.ForEach(AddPoint);
                    }
                    else if (seg is LineSegment)
                    {
                        AddPoint((seg as LineSegment).Point);
                    }
                    else if (seg is PolyBezierSegment)
                    {
                        var polybezier = (PolyBezierSegment) seg;

                        var bezierCurve = new BezierCurve(polybezier.Points.Select(p => new Vector2((float) p.X, (float) p.Y)));

                        Enumerable
                            .Range(1, 10)
                            .Select(i => bezierCurve.CalculatePoint(1.0f/i))
                            .ForEach(p => AddPoint(new Point(p.X, p.Y)));
                    }
                    else if (seg is BezierSegment)
                    {
                        var polybezier = (BezierSegment)seg;

                        var bezierCurve = new BezierCurveCubic(
                            LastPoint(),
                            new Vector2((float) polybezier.Point3.X, (float) polybezier.Point3.Y),
                            new Vector2((float) polybezier.Point1.X, (float) polybezier.Point1.Y),
                            new Vector2((float) polybezier.Point2.X, (float) polybezier.Point2.Y)
                            );

                        Enumerable
                            .Range(1, 10)
                            .Select(i => bezierCurve.CalculatePoint(1.0f / i))
                            .ForEach(p => AddPoint(new Point(p.X, p.Y)));
                    }
                    else
                    {
                        throw new ApplicationException(string.Format("segment type {0} not supported.", seg));
                    }
                }
                _tesselator.EndContour();
            }
            _tesselator.EndPolygon();
        }