InitVerts() 개인적인 메소드

Size our Vertices matrix.
private InitVerts ( ) : void
리턴 void
예제 #1
0
        /// <summary>
        /// Calculates a torus which divides the 3-sphere in two.
        /// </summary>
        public static Torus CreateTorus(Parameters parameters)
        {
            Torus t = new Torus();

            t.Params = parameters;
            t.InitVerts();

            // Shorter var names for inputs.
            int    n1 = parameters.NumSegments1;
            int    n2 = parameters.NumSegments2;
            double r  = parameters.Radius;
            double r1 = parameters.TubeRadius1;

            // Calc r2.
            double r2 = r - r1;

            if (r2 < 0)
            {
                r2 = 0;
            }

            r1 *= Math.Sqrt(2);
            r2 *= Math.Sqrt(2);

            double angleInc1 = 2 * Math.PI / n1;
            double angleInc2 = 2 * Math.PI / n2;

            double angle1 = 0;

            for (int i = 0; i < n1; i++)
            {
                double angle2 = 0;
                for (int j = 0; j < n2; j++)
                {
                    t.Vertices[i][j].X = r1 * Math.Cos(angle1);
                    t.Vertices[i][j].Y = r1 * Math.Sin(angle1);
                    t.Vertices[i][j].Z = r2 * Math.Cos(angle2);
                    t.Vertices[i][j].W = r2 * Math.Sin(angle2);
                    angle2            += angleInc2;
                }
                angle1 += angleInc1;
            }

            return(t);
        }
예제 #2
0
파일: Torus.cs 프로젝트: roice3/Honeycombs
        /// <summary>
        /// Calculates a torus which divides the 3-sphere in two.
        /// </summary>
        public static Torus CreateTorus( Parameters parameters )
        {
            Torus t = new Torus();
            t.Params = parameters;
            t.InitVerts();

            // Shorter var names for inputs.
            int n1 = parameters.NumSegments1;
            int n2 = parameters.NumSegments2;
            double r = parameters.Radius;
            double r1 = parameters.TubeRadius1;

            // Calc r2.
            double r2 = r - r1;
            if( r2 < 0 )
                r2 = 0;

            double angleInc1 = 2 * Math.PI / n1;
            double angleInc2 = 2 * Math.PI / n2;

            double angle1 = 0;
            for( int i = 0; i < n1; i++ )
            {
                double angle2 = 0;
                for( int j = 0; j < n2; j++ )
                {
                    t.Vertices[i][j].X = r1 * Math.Cos( angle1 );
                    t.Vertices[i][j].Y = r1 * Math.Sin( angle1 );
                    t.Vertices[i][j].Z = r2 * Math.Cos( angle2 );
                    t.Vertices[i][j].W = r2 * Math.Sin( angle2 );
                    angle2 += angleInc2;
                }
                angle1 += angleInc1;
            }

            return t;
        }