public static GeometryModel3D creatCircleModel(int Nsides, Point3D InputCenter, double InputRadius) { MeshGeometry3D mesh = new MeshGeometry3D(); Circle circle = new Circle(Nsides, InputCenter, InputRadius); circle.addToMesh(mesh, false); Material material = new DiffuseMaterial(new SolidColorBrush(Colors.White)); GeometryModel3D productModel = new GeometryModel3D(mesh, material); return productModel; }
public Cylinder(Point3D InputCenterUpp, int Nsides, double RadiusUpp, double RadiusDown, double Length) { centerUpp = InputCenterUpp; nSides = Nsides; radiusUpp = RadiusUpp; radiusDown = RadiusDown; length = Length; uppSide = new Circle(nSides, centerUpp, radiusUpp); centerDown = new Point3D(centerUpp.X, centerUpp.Y, centerUpp.Z - length); downSide = new Circle(nSides, centerDown, radiusDown); }
public Cylinder(Point3D InputCenterUpp, int Nsides, double InputRadiusUpp, Double InputRadiusDown, double Lengt, Point3D rotationPoint, double RotationInRadians) { centerUpp = InputCenterUpp; nSides = Nsides; radiusUpp = InputRadiusUpp; radiusDown = InputRadiusDown; length = Lengt; uppSide = new Circle(nSides, centerUpp, radiusUpp); centerDown = new Point3D(centerUpp.X, centerUpp.Y, centerUpp.Z - length); downSide = new Circle(nSides, centerDown, radiusDown); RotateYZ(rotationPoint, RotationInRadians); }
public Sphere(Point3D InputCenter, int Nsides, int Nstacks, Double InputRadius) { nSides = Nsides; nStacks = Nstacks; sphereCirces = new Circle[2 * nStacks - 1]; centerCenter = InputCenter; radius = InputRadius; MessageBox.Show(sphereCirces.Length.ToString()); for(int i = 0; i < nStacks; i++) { double zHeight = radius * ((double)(nStacks - 1 - i) / (nStacks - 1)); Point3D centerOfCircle = new Point3D(centerCenter.X, centerCenter.Y, centerCenter.Z + zHeight); double radiusOfCircle = Math.Sqrt(Math.Pow(radius, 2) - Math.Pow(zHeight, 2)); sphereCirces[i] = new Circle(nSides, centerOfCircle, radiusOfCircle); } for (int i = nStacks; i > 1; i--) { double zHeight = radius * ((double)(i - 1) / (nStacks - 1)); Point3D centerOfCircle = new Point3D(centerCenter.X, centerCenter.Y, centerCenter.Z - (radius * ((double)(i - 1) / (nStacks - 1)))); double radiusOfCircle = Math.Sqrt(Math.Pow(radius, 2) - Math.Pow(zHeight, 2)); sphereCirces[(nStacks - 2) + i] = new Circle(nSides, centerOfCircle, radiusOfCircle); } MessageBox.Show(sphereCirces[0].Center.ToString()); MessageBox.Show(sphereCirces[0].radiusX.ToString()); MessageBox.Show(sphereCirces[1].Center.ToString()); MessageBox.Show(sphereCirces[1].radiusX.ToString()); MessageBox.Show(sphereCirces[2 * nStacks - 2].Center.ToString()); MessageBox.Show(sphereCirces[2 * nStacks - 2].radiusX.ToString()); MessageBox.Show(sphereCirces[nStacks - 1].Center.ToString()); MessageBox.Show(sphereCirces[nStacks - 1].radiusX.ToString()); MessageBox.Show(sphereCirces[nStacks - 3].Center.ToString()); MessageBox.Show(sphereCirces[nStacks - 3].radiusX.ToString()); MessageBox.Show(sphereCirces[nStacks].Center.ToString()); MessageBox.Show(sphereCirces[nStacks].radiusX.ToString()); }