private void QuantizeSegmentOrientations() { // Find the optimal rotation angle, to minimize segments' orientation from 0/30/45/60. Point center = Geometry.EstimatePolygonCentroid(idealverts); QsoImpl fi = new QsoImpl(idealverts,center); GoldenSectionDescender.F f = new GoldenSectionDescender.F(fi.F); GoldenSectionDescender gsd = new GoldenSectionDescender(f); double tolerance = 0.01; double optangle = gsd.FindMinimumWithin(-12.0,+12.0,tolerance); // Now rotate them! using (Matrix m = new Matrix()) { m.RotateAt((float)optangle, new PointF(center.X,center.Y)); m.TransformPoints(idealverts); } }