Example #1
0
 /// <summary>
 /// Returns shortest distance from segment to the line
 /// </summary>
 public double DistanceTo(Line3d l)
 {
     if (l.PerpendicularTo(this.ToLine).BelongsTo(this))
     {
         return(l.DistanceTo(this.ToLine));
     }
     else
     {
         return(Min(this.P1.DistanceTo(l), this.P2.DistanceTo(l)));
     }
 }
Example #2
0
        /// <summary>
        /// Shortest distance between sphere and line
        /// </summary>
        public double DistanceTo(Line3d l)
        {
            double d = l.DistanceTo(this.Center);

            if (d > this.R)
            {
                return(d - this.R);
            }
            else
            {
                return(0);
            }
        }