Exemple #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));
        }
Exemple #2
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));
        }
Exemple #3
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));
        }