// 三角形から作成 public static Centroid Create(Vector3d p0, Vector3d p1, Vector3d p2) { Centroid ret = default(Centroid); ret.set(p0, p1, p2); return(ret); }
public override Centroid GetCentroid() { Centroid cent = default; Centroid ct = default; for (int i = 0; i < mHeModel.FaceStore.Count; i++) { HeFace f = mHeModel.FaceStore[i]; HalfEdge head = f.Head; HalfEdge he = head; int i0 = he.Vertex; int i1 = he.Next.Vertex; int i2 = he.Next.Next.Vertex; ct.set( mHeModel.VertexStore[i0].vector, mHeModel.VertexStore[i1].vector, mHeModel.VertexStore[i2].vector ); cent = cent.Merge(ct); } return(cent); }
public override Centroid GetCentroid() { Centroid ret = default; ret.Point = mPointList[0].vector; return(ret); }
public override Centroid GetCentroid() { Centroid ret = default; ret.IsInvalid = true; return(ret); }
public override Centroid GetCentroid() { Centroid ret = default; Vector3d cp = StoreList[0].vector; Vector3d rp = StoreList[1].vector; Vector3d d = rp - cp; double r = d.Norm(); ret.Point = cp; ret.Area = r * r * Math.PI; return(ret); }
// 二つの重心情報から重心を求める public static Centroid Merge(Centroid c0, Centroid c1) { Vector3d gpt = default; double ratio = c1.Area / (c0.Area + c1.Area); gpt.X = (c1.Point.X - c0.Point.X) * ratio + c0.Point.X; gpt.Y = (c1.Point.Y - c0.Point.Y) * ratio + c0.Point.Y; gpt.Z = (c1.Point.Z - c0.Point.Z) * ratio + c0.Point.Z; Centroid ret = default(Centroid); ret.Area = c0.Area + c1.Area; ret.Point = gpt; return(ret); }
// 三角形群の重心を求める public static Centroid TriangleListCentroid(List <CadFigure> triangles) { Centroid c0 = default; Centroid c1 = default; Centroid ct = default; int i = 1; c0.Area = TriangleArea(triangles[0]); c0.Point = TriangleCentroid(triangles[0]); for (; i < triangles.Count; i++) { c1.Area = TriangleArea(triangles[i]); c1.Point = TriangleCentroid(triangles[i]); ct = c0.Merge(c1); c0 = ct; } return(c0); }
// 二つの重心情報から重心を求める public Centroid Merge(Centroid c1) { return(Merge(this, c1)); }