Ejemplo n.º 1
0
        /// <summary>
        ///     Splits the line into two lines at the distance along the line given.
        /// </summary>
        /// <param name="distance">The distance along the line to split the line, in the range 0-1 (exclusive).</param>
        /// <param name="line1">The first line.</param>
        /// <param name="line2">The second line.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">The distance must be in the range 0-1.</exception>
        public void SplitLine(float distance, out ILine line1, out ILine line2)
        {
            if (distance <= 0 || distance >= 1)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(distance),
                          distance,
                          "The distance must be in the range 0-1.");
            }

            Vector2 p1 = Start;
            Vector2 p2 = ControlPoint;
            Vector2 p3 = End;

            Vector2 p12 = ((p2 - p1) * distance) + p1;
            Vector2 p23 = ((p3 - p2) * distance) + p2;

            Vector2 p123 = ((p23 - p12) * distance) + p12;

            LineVector midVector = new LineVector(p123);

            line1 = new QuadraticBezierCurve(Start, new LineVector(p12), midVector);
            line2 = new QuadraticBezierCurve(midVector, new LineVector(p23), End);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Splits the line into two lines at the distance along the line given.
        /// </summary>
        /// <param name="distance">The distance along the line to split the line, in the range 0-1 (exclusive).</param>
        /// <param name="line1">The first line.</param>
        /// <param name="line2">The second line.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">The distance must be in the range 0-1.</exception>
        public void SplitLine(float distance, out ILine line1, out ILine line2)
        {
            if (distance <= 0 || distance >= 1)
            {
                throw new ArgumentOutOfRangeException(
                    nameof(distance),
                    distance,
                    "The distance must be in the range 0-1.");
            }

            Vector2 p1 = Start;
            Vector2 p2 = ControlPoint;
            Vector2 p3 = End;

            Vector2 p12 = ((p2 - p1) * distance) + p1;
            Vector2 p23 = ((p3 - p2) * distance) + p2;

            Vector2 p123 = ((p23 - p12) * distance) + p12;

            LineVector midVector = new LineVector(p123);

            line1 = new QuadraticBezierCurve(Start, new LineVector(p12), midVector);
            line2 = new QuadraticBezierCurve(midVector, new LineVector(p23), End);
        }