Esempio n. 1
0
        public RotationFigure(List <Point3D> startPoints, Axis axis, int count)
        {
            Polygons = new List <Polygon>();
            List <Point3D> rotatedPoints = new List <Point3D>();
            //Points = new List<Point3D>();
            //Polygons = new List<Polygon>();
            //Points.AddRange(startPoints);
            float angle = 360f / count;

            foreach (var p in startPoints)
            {
                rotatedPoints.Add(new Point3D(p.X, p.Y, p.Z));
            }

            for (int i = 0; i < count; ++i)
            {
                foreach (var p in rotatedPoints)
                {
                    p.rotate(angle, axis);
                }

                for (int j = 1; j < startPoints.Count; ++j)
                {
                    Polygon p = new Polygon(
                        new List <Point3D>()
                    {
                        new Point3D(startPoints[j - 1]),
                        new Point3D(rotatedPoints[j - 1]),
                        new Point3D(rotatedPoints[j]),
                        new Point3D(startPoints[j])
                    });

                    Polygons.Add(p);
                }

                //foreach (var f in Polygons)
                //    f.translate(Ax, Ay, Az);

                //Points = new List<Point3D>();
                //Polygons = new List<Polygon>();
                //Points.AddRange(startPoints);
                //List<Point3D> rotatedPoints = new List<Point3D>();

                //var startCount = startPoints.Count;


                //Points.Add(Points[0]);
                //Points.Add(Points[1]);

                //var n = startPoints.Count;
                //for (int k = 0; k < n - 1; k++)
                //{
                //    for (int i = 0; i <= Points.Count; i += 4)
                //    {
                //        if (i != Points.Count - 2)// - 3)  -2
                //        {
                //            Polygons.Add(
                //                new Polygon(
                //                    new List<Point3D>
                //                        {
                //                        Points[i],
                //                        Points[i+1],
                //                        Points[i+2],
                //                        Points[i+3],
                //                        Points[i+1],
                //                        Points[i+3]
                //                        }
                //                )
                //             );
                //        }
                //        //else
                //        //{
                //        //    Polygons.Add(
                //        //        new Polygon(
                //        //            new List<Point3D>
                //        //                {
                //        //                Points[i],
                //        //                Points[i+1],
                //        //                Points[0],
                //        //                Points[1],
                //        //                Points[1+1],
                //        //                Points[1]
                //        //                }
                //        //        )
                //        //     );
                //        //}
                //    }

                //}

                foreach (var p in startPoints)
                {
                    p.rotate(angle, axis);
                }
            }
        }
Esempio n. 2
0
 public Polygon(Polygon face)
 {
     Points = face.Points.Select(pt => new Point3D(pt.X, pt.Y, pt.Z)).ToList();
     Center = new Point3D(face.Center);
 }