Exemplo n.º 1
0
        public void RotateBlah(Rotation rotation)
        {
            var rotateX = rotation.GetXMatrix();
            var rotateY = rotation.GetYMatrix();
            var rotateZ = rotation.GetZMatrix();

            var result = rotateZ * rotateX * rotateY;
            for (int i = 0; i < TransformedVertices.Length; i++)
            {
                var verticeMatrix = TransformedVertices[i].ToSingleRowMatrix();
                var verticeResult = verticeMatrix * result;
                TransformedVertices[i].X = (float)verticeResult[0, 0];
                TransformedVertices[i].Y = (float)verticeResult[0, 1];
                TransformedVertices[i].Z = (float)verticeResult[0, 2];
            }
        }
Exemplo n.º 2
0
        public void RotateOriginal(Rotation rotation)
        {
            float sin;
            float cos;
            float x, y, z;

            for (int i = 0; i < TransformedVertices.Length; i++)
            {
                x = TransformedVertices[i].X;
                y = TransformedVertices[i].Y;
                z = TransformedVertices[i].Z;

                if (rotation.AngleX != 0)
                {
                    sin = (float)Math.Sin(rotation.AngleX);
                    cos = (float)Math.Cos(rotation.AngleX);
                    y = TransformedVertices[i].Y * cos - TransformedVertices[i].Z * sin;
                    z = TransformedVertices[i].Z * cos + TransformedVertices[i].Y * sin;

                    TransformedVertices[i].Y = y;
                    TransformedVertices[i].Z = z;
                }
                if (rotation.AngleY != 0)
                {
                    sin = (float)Math.Sin(rotation.AngleY);
                    cos = (float)Math.Cos(rotation.AngleY);
                    x = TransformedVertices[i].Z * sin + TransformedVertices[i].X * cos;
                    z = TransformedVertices[i].Z * cos - TransformedVertices[i].X * sin;

                    TransformedVertices[i].X = x;
                    TransformedVertices[i].Z = z;
                }
                if (rotation.AngleZ != 0)
                {
                    sin = (float)Math.Sin(rotation.AngleZ);
                    cos = (float)Math.Cos(rotation.AngleZ);
                    x = TransformedVertices[i].X * cos - TransformedVertices[i].Y * sin;
                    y = TransformedVertices[i].Y * cos + TransformedVertices[i].X * sin;

                    TransformedVertices[i].X = x;
                    TransformedVertices[i].Y = y;
                }
            }
        }
Exemplo n.º 3
0
 public void Rotate(Rotation rotation)
 {
     for (int i = 0; i < TransformedVertices.Length; i++)
     {
         TransformedVertices[i] = Rotation.RotateX(TransformedVertices[i], rotation.AngleX);
         TransformedVertices[i] = Rotation.RotateY(TransformedVertices[i], rotation.AngleY);
         TransformedVertices[i] = Rotation.RotateZ(TransformedVertices[i], rotation.AngleZ);
     }
 }