/// <summary>
        /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of x and y:
        /// - If less than 0, x is less than y.
        /// - If 0, x equals y.
        /// - If greater than 0, x is greater than y.
        /// </returns>
        public int Compare(Cartesian3dCoordinate x, Cartesian3dCoordinate y)
        {
            // Check perfect equality first to avoid further calculations.
            if (x.IsSamePoint(y))
            {
                return(0);
            }

            Cartesian2dCoordinate x2 = m_Converter.ConvertTo2d(x);
            Cartesian2dCoordinate y2 = m_Converter.ConvertTo2d(y);

            return(Compare(x2, y2));
        }
Esempio n. 2
0
        /// <summary>
        /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of x and y:
        /// - If less than 0, x is less than y.
        /// - If 0, x equals y.
        /// - If greater than 0, x is greater than y.
        /// </returns>
        public int Compare(Cartesian3dCoordinate x, Cartesian3dCoordinate y)
        {
            // Calculate intersection with plane to have all point on same plane.
            Cartesian3dCoordinate intersectX = m_Converter.Plane.GetIntersection(x);
            Cartesian3dCoordinate intersectY = m_Converter.Plane.GetIntersection(y);

            // Convert in a 2D referential to facilitate the comparison.
            Cartesian2dCoordinate x2 = m_Converter.ConvertTo2d(intersectX);
            Cartesian2dCoordinate y2 = m_Converter.ConvertTo2d(intersectY);

            if (x2.Y.IsEqualTo(y2.Y))
            {
                // Same line
                if (x2.X.IsEqualTo(y2.X))
                {
                    return(0);
                }

                return(x2.X < y2.X ? -1 : 1);
            }

            return(x2.Y > y2.Y ? -1 : 1);
        }