コード例 #1
0
        /// <summary>
        /// Creates the vertices of an icosahedron with vertices at (0, 0, 1) and (0, 0, -1)
        /// </summary>
        private List <Vertex> MakeIcosahedronVertices()
        {
            var vertices = new List <Vertex>
            {
                new Vertex(new Point3D(0, 0, 1), new Vector3D(0, 0, 1), new Point(0, 0)),
                new Vertex(new Point3D(0, 0, -1), new Vector3D(0, 0, -1), new Point(1, 1))
            };

            double       thetaHi    = Math.PI / 2 - Math.Atan(.5);
            double       thetaLo    = Math.PI / 2 + Math.Atan(.5);
            const double deltaPhi   = 2 * Math.PI / 10;
            bool         alternator = true;

            for (double iphi = 0; iphi < Math.PI * 2 + deltaPhi / 2; iphi += deltaPhi)
            // The addition to the cutoff avoids roundoff issues
            {
                double   theta    = alternator ? thetaHi : thetaLo;
                Vector3D position = Vector3DExtensions.SphericalCoordinates(1, iphi, theta);
                double   u        = iphi / (2 * Math.PI);
                double   v        = theta / (Math.PI);
                vertices.Add(new Vertex(ConvertToPoint3D(position), position, new Point(u, v)));

                // Switch the alternator
                alternator = alternator ? false : true;
            }

            return(vertices);
        }
コード例 #2
0
            /// <summary>
            /// Finds the midpoint between two points on the unit sphere
            /// </summary>
            private Vertex CreateMidpoint(Vertex one, Vertex two)
            {
                Vector3D midpoint = Vector3DExtensions.Midpoint(ConvertToVector3D(one.Position), ConvertToVector3D(two.Position));
                double   u        = midpoint.Azimuthal() / (2 * Math.PI);
                double   v        = midpoint.Polar() / Math.PI;

                midpoint.Normalize();
                return(new Vertex(ConvertToPoint3D(midpoint), midpoint, new Point(u, v)));
            }