Пример #1
0
        //Draw Polygon to Grid
        public void DrawPolygon(GridContext bgc, PenTwist twistType, int x, int y, int z, int radius, int sides)
        {
            double angleSize = 360.0 / sides;

            for (int i = 0; i < sides; i++)
            {
                double vx1    = radius;
                double vy1    = 0;
                var    angle1 = (int)(i * angleSize);
                MathTrigonometry.RotateZ(-angle1, ref vx1, ref vy1);

                double vx2    = radius;
                double vy2    = 0;
                var    angle2 = (int)((i + 1) * angleSize);

                MathTrigonometry.RotateZ(-angle2, ref vx2, ref vy2);

                if (i == sides - 1) //connect last segment
                {
                    vx2 = radius;
                    vy2 = 0;
                }
                DrawAxisLine2D(bgc, twistType, x + (int)vx1, y + (int)vy1, x + (int)vx2, y + (int)vy2, z);
            }
        }
Пример #2
0
        //Draw an Arc to Grid
        public void DrawArc(GridContext bgc, PenTwist twistType, int x, int y, int z, int radius, int startAnglePercent, int stopAnglePercent)
        {
            var realStartAngle = (int)(startAnglePercent * 3.6);
            var realStopAngle  = (int)(stopAnglePercent * 3.6);

            for (int angle = realStartAngle; angle < realStopAngle; angle++)
            {
                double vx = radius;
                double vy = 0;
                MathTrigonometry.RotateZ(-angle, ref vx, ref vy);
                DrawAxisPen(bgc, twistType, x + (int)vx, y + (int)vy, z);
            }
        }
Пример #3
0
        //Transform:RotateZ in degrees not radians
        public void RotateZ(float angle)
        {
            float x1 = Vertex1[0];
            float y1 = Vertex1[1];
            float x2 = Vertex2[0];
            float y2 = Vertex2[1];
            float x3 = Vertex3[0];
            float y3 = Vertex3[1];

            MathTrigonometry.RotateZ(angle, ref x1, ref y1);
            MathTrigonometry.RotateZ(angle, ref x2, ref y2);
            MathTrigonometry.RotateZ(angle, ref x3, ref y3);
            CalcNormal();
            Vertex1[0] = x1; Vertex1[1] = y1;
            Vertex2[0] = x2; Vertex2[1] = y2;
            Vertex3[0] = x3; Vertex3[1] = y3;
        }
Пример #4
0
        //Transform:RotateY in degrees not radians
        public void RotateY(float angle)
        {
            float x1 = Vertex1[0];
            float z1 = Vertex1[2];
            float x2 = Vertex2[0];
            float z2 = Vertex2[2];
            float x3 = Vertex3[0];
            float z3 = Vertex3[2];

            MathTrigonometry.RotateY(angle, ref x1, ref z1);
            MathTrigonometry.RotateY(angle, ref x2, ref z2);
            MathTrigonometry.RotateY(angle, ref x3, ref z3);
            CalcNormal();
            Vertex1[0] = x1; Vertex1[2] = z1;
            Vertex2[0] = x2; Vertex2[2] = z2;
            Vertex3[0] = x3; Vertex3[2] = z3;
        }
Пример #5
0
        //Transform:RotateX in degrees not radians
        public void RotateX(float angle)
        {
            float y1 = Vertex1[1];
            float z1 = Vertex1[2];
            float y2 = Vertex2[1];
            float z2 = Vertex2[2];
            float y3 = Vertex3[1];
            float z3 = Vertex3[2];

            MathTrigonometry.RotateX(angle, ref y1, ref z1);
            MathTrigonometry.RotateX(angle, ref y2, ref z2);
            MathTrigonometry.RotateX(angle, ref y3, ref z3);
            CalcNormal();

            Vertex1[1] = y1; Vertex1[2] = z1;
            Vertex2[1] = y2; Vertex2[2] = z2;
            Vertex3[1] = y3; Vertex3[2] = z3;
        }
Пример #6
0
 public static void RotateZ(float angle, ref float x, ref float y)
 {
     MathTrigonometry.RotateZ(angle, ref x, ref y);
 }
Пример #7
0
 public static void RotateY(float angle, ref float x, ref float z)
 {
     MathTrigonometry.RotateY(angle, ref x, ref z);
 }
Пример #8
0
        //public static bool BytesAreEqual(byte[] result, byte[] expectedResult) { return Compare.BytesAreEqual(result, expectedResult); }

        //Rotations
        public static void RotateX(float angle, ref float y, ref float z)
        {
            MathTrigonometry.RotateX(angle, ref y, ref z);
        }