Beispiel #1
0
        /// <summary>
        /// Find the shortest distance from this point to any point on the
        /// polyline, and output the location of the closest point on that polyline.
        /// </summary>
        /// <param name="polyline">The polyline for computing the distance.</param>
        /// <param name="closestPoint">The point on the polyline that is closest to this point.</param>
        public double DistanceTo(Polyline polyline, out Vector3 closestPoint)
        {
            var closest = double.MaxValue;

            closestPoint = default(Vector3);

            foreach (var line in polyline.Segments())
            {
                var distance = this.DistanceTo(line, out var thisClosestPoint);
                if (distance < closest)
                {
                    closest      = distance;
                    closestPoint = thisClosestPoint;
                }
            }

            return(closest);
        }
Beispiel #2
0
 /// <summary>
 /// Extend this line to its (nearest, by default) intersection with a polyline.
 /// </summary>
 /// <param name="polyline">The polyline to intersect with</param>
 /// <param name="bothSides">Optional — if false, will only extend in the line's direction; if true will extend in both directions.</param>
 /// <param name="extendToFurthest">Optional — if true, will extend line as far as it will go, rather than stopping at the closest intersection.</param>
 public Line ExtendTo(Polyline polyline, bool bothSides = true, bool extendToFurthest = false)
 {
     return(ExtendTo(polyline.Segments(), bothSides, extendToFurthest));
 }
Beispiel #3
0
 /// <summary>
 /// Extend this line to its nearest intersection with a polyline or polygon.
 /// </summary>
 /// <param name="polyline">The polyline or polygon to intersect with</param>
 /// <param name="bothSides">Optional — if false, will only extend in the line's direction; if true will extend in both directions.</param>
 public Line ExtendTo(Polyline polyline, bool bothSides = true)
 {
     return(ExtendTo(polyline.Segments(), bothSides));
 }