public static Point3D?GetCentroid(IList <Point3D> polygon, out Plane3D?plane) { int count = polygon.Count; Point3D point3D1 = polygon[0]; if (count < 3) { plane = new Plane3D?(); switch (count) { case 0: return(new Point3D?()); case 1: return(new Point3D?(polygon[0])); case 2: Point3D point3D2 = polygon[0]; return(new Point3D?(new Point3D(0.5 * (point3D1.X + point3D2.X), 0.5 * (point3D1.Y + point3D2.Y), 0.5 * (point3D1.Z + point3D2.Z)))); } } plane = Polygon3D.GetPlane(polygon); if (!plane.HasValue) { return(new Point3D?()); } Matrix4D matrix4D = Transformation4D.Translation(point3D1.X, point3D1.Y, point3D1.Z) * Transformation4D.GetArbitraryCoordSystem(plane.Value.Normal); Matrix4D inverse = matrix4D.GetInverse(); Point2D point2D = Polygon3D.GetProjection2D(polygon, inverse).GetCentroid().Value; return(new Point3D?(matrix4D.Transform(new Point3D(point2D.X, point2D.Y, 0.0)))); }
public Point3D?GetCentroid(out Plane3D?plane) { return(Polygon3D.GetCentroid((IList <Point3D>) this, out plane)); }
public Point3D?GetCentroid() { return(Polygon3D.GetCentroid((IList <Point3D>) this)); }
public Polygon2D GetProjection2D(Matrix4D projectionTransform) { return(Polygon3D.GetProjection2D((IList <Point3D>) this, projectionTransform)); }
public Plane3D?GetPlane() { return(Polygon3D.GetPlane((IList <Point3D>) this)); }
public Polygon3D(Polygon3D polyline) : base((IEnumerable <Point3D>)polyline) { }
public static Point3D?GetCentroid(IList <Point3D> polygon) { Plane3D?plane; return(Polygon3D.GetCentroid(polygon, out plane)); }