Пример #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
 public static void RotateZ(float angle, ref float x, ref float y)
 {
     MathTrigonometry.RotateZ(angle, ref x, ref y);
 }