Пример #1
0
 /// <summary>
 /// Get the area of the polygon
 /// May be optimized for PolyAdv
 /// </summary>
 /// <param name="poly"></param>
 /// <returns></returns>
 public static float GetArea(this IPoly poly)
 {
     if (poly is IPolyExtensionArea)
     {
         return(((IPolyExtensionArea)poly).AdvGetArea());
     }
     else if (poly is IPolyForwarder)
     {
         return(((IPolyForwarder)poly).GetPoly().GetArea());
     }
     else
     {
         return(poly.CalcArea());
     }
 }
Пример #2
0
 /// <summary>
 /// Returns the radius of a circle with the same area.
 /// Useful for approximating the size of a polygon.
 /// </summary>
 /// <param name="poly"></param>
 /// <returns></returns>
 public static float GetRadius(this IPoly poly)
 {
     return(Mathf.Sqrt(poly.CalcArea() / Mathf.PI));
 }