Esempio n. 1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>	Creates a circle event. </summary>
        /// <remarks>Circle events are created at the circumcenters of three sites - the sites for poly1/2/3.</remarks>
        /// <param name="poly1">		The first polygon. </param>
        /// <param name="poly2">		The second polygon. </param>
        /// <param name="poly3">		The third polygon. </param>
        /// <param name="yScanLine">	The y coordinate scan line. </param>
        /// <returns>	A new circle event. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        internal static CircleEvent CreateCircleEvent(FortunePoly poly1, FortunePoly poly2, FortunePoly poly3,
                                                      double yScanLine)
        {
            // Locals
            CircleEvent cevtRet = null;

            // Determine a circumcenter for the sites of poly1/2/3.
            if (Geometry2D.FFindCircumcenter(poly1.VoronoiPoint, poly2.VoronoiPoint, poly3.VoronoiPoint, out var ptCenter))
            {
                // Determine y coordinate for the side of the circle
                // The event will fire when the scan line hits that y position
                var radius = Geometry2D.Distance(poly1.VoronoiPoint, ptCenter);
                ptCenter.Y -= radius;

                // If the circumcenter is above the scan line we've already passed it by, so don't put it in the queue
                if (ptCenter.Y <= yScanLine)
                {
                    cevtRet = new CircleEvent(ptCenter, radius);
                }
            }

            return(cevtRet);
        }