AddPolygon() public method

public AddPolygon ( Point3D points ) : void
points Point3D
return void
Example #1
0
        private static void CreatePipe(AutoStereogramBuilder asb, List <Circle3D> circles, Vector3D firstDirection = null)
        {
            List <Point3D> prevPoints = null;
            Vector3D       v1 = null, v2 = null;

            if (firstDirection == null)
            {
                firstDirection = circles[1].Center - circles[0].Center;
            }

            for (int n = 0; n < circles.Count; n++)
            {
                if (n == 0)
                {
                    GetSomeOrthonormalizedVectors(firstDirection, out v1, out v2);
                }
                else
                {
                    GetNextOrthonormalizedVectors((n == 1 ? firstDirection : circles[n - 1].Center - circles[n - 2].Center).Normalize(),
                                                  (circles[n].Center - circles[n - 1].Center).Normalize(), v1, v2, out v1, out v2);
                }

                List <Point3D> points = GetCirclePoints(circles[n].Center, circles[n].Radius, v1, v2);

                if (prevPoints != null)
                {
                    for (int m = 0; m < points.Count; m++)
                    {
                        Point3D p1 = points[m], p2 = prevPoints[m], p3 = points[(m + 1) % points.Count], p4 = prevPoints[(m + 1) % points.Count];

                        asb.AddPolygon(new Point3D[] { p1, p2, p3 });
                        asb.AddPolygon(new Point3D[] { p2, p3, p4 });
                    }
                }

                prevPoints = points;
            }
        }
Example #2
0
        private static void CreateFigures()
        {
            var asb = new AutoStereogramBuilder(1024, 768, 3);

            asb.AddHorizontalPlane(2);

            Vector3D v1 = new Vector3D {
                X = 1, Y = 0, Z = 0
            };

            for (int n = 0; n < 4; n++)
            {
                Vector3D v2 = new Vector3D {
                    X = 0, Y = Math.Cos(n * Math.PI / 8), Z = -Math.Sin(n * Math.PI / 8)
                };
                Vector3D v3 = new Vector3D {
                    X = 0, Y = Math.Sin(n * Math.PI / 8), Z = Math.Cos(n * Math.PI / 8)
                };

                // hexagonal prism

                Point3D[] prismUpperPoints = new Point3D[6], prismLowerPoints = new Point3D[6];

                for (int m = 0; m < 6; m++)
                {
                    prismUpperPoints[m] = new Point3D {
                        X = -0.2 + n * 0.25, Y = -0.2, Z = 1.7
                    } +v1 *Math.Sin(m / 3.0 *Math.PI) * 0.1 + v2 * Math.Cos(m / 3.0 * Math.PI) * 0.1 - v3 * 0.05;

                    prismLowerPoints[m] = new Point3D {
                        X = -0.2 + n * 0.25, Y = -0.2, Z = 1.7
                    } +v1 *Math.Sin(m / 3.0 *Math.PI) * 0.1 + v2 * Math.Cos(m / 3.0 * Math.PI) * 0.1 + v3 * 0.05;
                }

                asb.AddPolygon(prismUpperPoints);
                asb.AddPolygon(prismLowerPoints);

                for (int m = 0; m < 6; m++)
                {
                    asb.AddPolygon(new Point3D[] { prismLowerPoints[m], prismUpperPoints[m], prismUpperPoints[(m + 1) % 6], prismLowerPoints[(m + 1) % 6] });
                }

                // cylinder

                asb.AddCylinder(new Point3D {
                    X = -0.2 + n * 0.25, Y = 0.1, Z = 1.7
                } -v3 * 0.1, new Point3D {
                    X = -0.2 + n * 0.25, Y = 0.1, Z = 1.7
                } +v3 * 0.1, 0.08);

                // octahedron

                Point3D octahedronCenter = new Point3D {
                    X = -0.2 + n * 0.25, Y = 0.4, Z = 1.7
                };
                Point3D   octahedronUpperPoint = octahedronCenter - v3 * 0.1 * Math.Sqrt(2), octahedronLowerPoint = octahedronCenter + v3 * 0.1 * Math.Sqrt(2);
                Point3D[] octahedronMiddlePoints = new Point3D[] { octahedronCenter + v1 * 0.1 + v2 * 0.1, octahedronCenter - v1 * 0.1 + v2 * 0.1,
                                                                   octahedronCenter - v1 * 0.1 - v2 * 0.1, octahedronCenter + v1 * 0.1 - v2 * 0.1 };

                for (int m = 0; m < 4; m++)
                {
                    asb.AddPolygon(new Point3D[] { octahedronUpperPoint, octahedronMiddlePoints[m], octahedronMiddlePoints[(m + 1) % 4] });
                    asb.AddPolygon(new Point3D[] { octahedronLowerPoint, octahedronMiddlePoints[m], octahedronMiddlePoints[(m + 1) % 4] });
                }
            }

            asb.GenerateBitmap().Save(GetPathAtAssemblyLocation("output\\figures.gif"), ImageFormat.Gif);
        }