// *** METHODS *** /// <summary> /// Rotates the point around a particular axis /// </summary> /// <param name="type">Rotation axis</param> /// <param name="angle">Angle to be rotated</param> /// <param name="center">Center point of rotation</param> public Cube3D Rotate(RotationType type, double angle, Point3D center) { //Deep Clone List <Face3D> faces = new List <Face3D>(); foreach (Face3D f in Faces) { List <Point3D> edges = new List <Point3D>(); foreach (Point3D p in f.Vertices) { edges.Add(new Point3D(p.X, p.Y, p.Z)); } Face3D f2 = new Face3D(edges, f.Color, f.Position, f.MasterPosition); f2.Vertices.ToList().ForEach(e => { e.X -= center.X; e.Y -= center.Y; e.Z -= center.Z; }); f2.Rotate(type, angle); f2.Vertices.ToList().ForEach(e => { e.X += center.X; e.Y += center.Y; e.Z += center.Z; }); faces.Add(f2); } return(new Cube3D(faces, this.Position, this.Location, this.Scale)); }
// *** METHODS *** /// <summary> /// Rotates the point around a particular axis /// </summary> /// <param name="type">Rotation axis</param> /// <param name="angle">Angle to be rotated</param> /// <param name="center">Center point of rotation</param> public Cube3D Rotate(RotationType type, double angle, Point3D center) { //Deep Clone List<Face3D> faces = new List<Face3D>(); foreach (Face3D f in Faces) { List<Point3D> edges = new List<Point3D>(); foreach (Point3D p in f.Vertices) { edges.Add(new Point3D(p.X, p.Y, p.Z)); } Face3D f2 = new Face3D(edges, f.Color, f.Position, f.MasterPosition); f2.Vertices.ToList().ForEach(e => { e.X -= center.X; e.Y -= center.Y; e.Z -= center.Z; }); f2.Rotate(type, angle); f2.Vertices.ToList().ForEach(e => { e.X += center.X; e.Y += center.Y; e.Z += center.Z; }); faces.Add(f2); } return new Cube3D(faces, this.Position, this.Location,this.Scale); }