//# } // isIndexed #region Geometric Properties /// <summary> /// The vertex centroid is the average of the vertex coordinates. /// </summary> public static __tvec__ ComputeVertexCentroid(this __tipolygon__ polygon) { var sum = __tvec__.Zero; int pc = polygon.PointCount; for (int i = 0; i < pc; i++) { sum += polygon[i]; } var scale = 1.0 / (double)pc; return(sum * scale); }
public static double ComputePerimeter(this __tipolygon__ polygon) { var pc = polygon.PointCount; var p0 = polygon[pc - 1]; var r = 0.0; for (int i = 0; i < pc; i++) { var p1 = polygon[i]; r += __tvec__.Distance(p0, p1); p0 = p1; } return(r); }
//# if (isIndexed) { #region Conversions public static __tpolygon__ To__tpolygon__(this __tipolygon__ polygon) { return(new __tpolygon__(polygon.GetPointArray())); }