Beispiel #1
0
        /// <summary>
        /// Returns the projection of this UV as a point from a specified line.
        /// </summary>
        /// <param name="line">The line.</param>
        /// <returns>UV.</returns>
        public UV Projection(UVLine line)
        {
            double u = (line.End - line.Start).DotProduct(this - line.Start);

            u /= line.GetLength();
            return(line.FindPoint(u));
        }
Beispiel #2
0
        /// <summary>
        /// Return ths distance of the UV as a point from a line.
        /// </summary>
        /// <param name="line">The line.</param>
        /// <returns>System.Double.</returns>
        public double DistanceTo(UVLine line)
        {
            double area = (line.Start - line.End).CrossProductValue(line.Start - this);

            area = Math.Abs(area);
            return(area / line.GetLength());
        }
Beispiel #3
0
        /// <summary>
        /// Gets the closest point of this UV as a point from a line.
        /// </summary>
        /// <param name="line">The line.</param>
        /// <returns>UV.</returns>
        public UV GetClosestPoint(UVLine line)
        {
            double length = line.GetLength();
            double u      = (line.End - line.Start).DotProduct(this - line.Start);

            u /= length;
            if (u < 0)
            {
                return(line.Start);
            }
            if (u > length)
            {
                return(line.End);
            }
            return(line.FindPoint(u));
        }
Beispiel #4
0
        /// <summary>
        /// Gets the closest point of this UV as a point from a line.
        /// </summary>
        /// <param name="line">The line.</param>
        /// <param name="isEndPoint">if set to <c>true</c> the closest point is the end point of the line.</param>
        /// <returns>UV.</returns>
        public UV GetClosestPoint(UVLine line, ref bool isEndPoint)
        {
            double length = line.GetLength();
            double u      = (line.End - line.Start).DotProduct(this - line.Start);

            u /= length;
            if (u < 0)
            {
                isEndPoint = true;
                return(line.Start);
            }
            if (u > length)
            {
                isEndPoint = true;
                return(line.End);
            }
            isEndPoint = false;
            return(line.FindPoint(u));
        }
Beispiel #5
0
        /// <summary>
        /// Returns the closest distance of this UV as a point from a line .
        /// </summary>
        /// <param name="line">The line.</param>
        /// <returns>System.Double.</returns>
        public double ClosestDistance(UVLine line)
        {
            UV     p      = new UV();
            double length = line.GetLength();
            double u      = (line.End - line.Start).DotProduct(this - line.Start);

            u /= length;
            if (u < 0)
            {
                p = line.Start;
            }
            else if (u > length)
            {
                p = line.End;
            }
            else
            {
                p = this.GetClosestPoint(line);
            }
            return(p.DistanceTo(this));
        }