}// CreateCuboid public static Prism CreateCylinder(int nslices) { Polygon3D bot = Polygon3D.CreateCircle(nslices, -1); Polygon3D top = Polygon3D.CreateCircle(nslices, 1); return(new Prism(top, bot)); }// CreateCylinder
public Prism(Polygon3D top, Polygon3D bot) { _points3d = new Vector3d[top.points3d.Length + bot.points3d.Length]; int i = 0; foreach (Vector3d v in top.points3d) { _points3d[i++] = new Vector3d(v); } foreach (Vector3d v in bot.points3d) { _points3d[i++] = new Vector3d(v); } initInfo(); }
}// createPlanes public static Prism CreateCuboid(Vector3d center, Vector3d scale) { Vector3d off = scale; Vector3d[] top = new Vector3d[4] { new Vector3d(center + new Vector3d(-off.x, -off.y, off.z)), new Vector3d(center + new Vector3d(off.x, -off.y, off.z)), new Vector3d(center + new Vector3d(off.x, off.y, off.z)), new Vector3d(center + new Vector3d(-off.x, off.y, off.z)) }; Vector3d[] bot = new Vector3d[4] { new Vector3d(center - off), new Vector3d(center + new Vector3d(off.x, -off.y, -off.z)), new Vector3d(center + new Vector3d(off.x, off.y, -off.z)), new Vector3d(center + new Vector3d(-off.x, off.y, -off.z)) }; Polygon3D p1 = new Polygon3D(top); Polygon3D p2 = new Polygon3D(bot); return(new Prism(p1, p2)); }// CreateCuboid
public Object clone() { Polygon3D cloned = new Polygon3D(this.points3d); return(cloned); }