Beispiel #1
0
        public Vec3 Dot(Mat3x3 mat)
        {
            float x = X * mat.XX + Y * mat.YX + Z * mat.ZX;
            float y = X * mat.XY + Y * mat.YY + Z * mat.ZY;
            float z = X * mat.XZ + Y * mat.YZ + Z * mat.ZZ;

            return(new Vec3(x, y, z));
        }
Beispiel #2
0
 public void Rotate(Mat3x3 mat)
 {
     foreach (Facet facet in Facets)
     {
         facet.Vertex1 = facet.Vertex1.Dot(mat);
         facet.Vertex2 = facet.Vertex2.Dot(mat);
         facet.Vertex3 = facet.Vertex3.Dot(mat);
     }
 }
Beispiel #3
0
        public void Rotate(float rotX, float rotY, float rotZ)
        {
            var rotMat = Mat3x3.RotationX(rotX).Dot(Mat3x3.RotationY(rotY)).Dot(Mat3x3.RotationZ(rotZ));

            foreach (Facet facet in Facets)
            {
                facet.Vertex1 = facet.Vertex1.Dot(rotMat);
                facet.Vertex2 = facet.Vertex2.Dot(rotMat);
                facet.Vertex3 = facet.Vertex3.Dot(rotMat);
            }
        }
Beispiel #4
0
        public static Mat3x3 RotationZ(float angle)
        {
            var result = new Mat3x3();

            result.data[0, 0] = MathF.Cos(angle);
            result.data[0, 1] = -MathF.Sin(angle);
            result.data[1, 0] = MathF.Sin(angle);
            result.data[1, 1] = MathF.Cos(angle);
            result.data[2, 2] = 1;
            return(result);
        }
Beispiel #5
0
        public Mat3x3 Dot(Mat3x3 other)
        {
            var result = new Mat3x3();

            for (int y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    float sum = 0f;
                    for (int z = 0; z < 3; z++)
                    {
                        sum += data[y, z] * other.data[z, x];
                    }
                    result.data[y, x] = sum;
                }
            }
            return(result);
        }