コード例 #1
0
        public static Vector3 ToPointZisW(MyMatrix4x1 m)
        {
            float x = m.points[0, 0];
            float y = m.points[1, 0];
            float z = m.points[2, 0];

            return(new Vector3(x, y, z / m.points[3, 0]));
        }
コード例 #2
0
        public static MyMatrix4x1 FromPoint4x1(Vector3 vector)
        {
            MyMatrix4x1 temp = new MyMatrix4x1();

            temp.points[0, 0] = vector.X;
            temp.points[1, 0] = vector.Y;
            temp.points[2, 0] = vector.Z;
            return(temp);
        }
コード例 #3
0
        public static MyMatrix4x1 operator *(MyMatrix4x4 A, MyMatrix4x1 B)
        {
            MyMatrix4x1 C = new MyMatrix4x1();

            for (var i = 0; i < 4; i++)
            {
                C.points[i, 0] = 0;

                for (var k = 0; k < 4; k++)
                {
                    C.points[i, 0] += A.points[i, k] * B.points[k, 0];
                }
            }

            return(C);
        }
コード例 #4
0
        public static Vector3 ToPoint(MyMatrix4x1 m, float A, float B, float C, float D, float E, int width, int height)
        {
            float x = m.points[0, 0];
            float y = m.points[1, 0];
            float z = m.points[2, 0];
            float w = m.points[3, 0];

            //x = (A * x) / (D * z);
            //y = (B * y) / (D * z);


            //x = (x) * width;
            //y = (y) * height;


            //z = (C * z + E * w * E) / (D * z);
            //z = MathF.Log2(MathF.Max(1e-6f, 1.0f + w)) * 2.0f / MathF.Log2(100f + 1.0f) - 1.0f;
            //z = MathF.Log2(1 * z + 1) / MathF.Log2(1 * 100f + 1) * w;
            //Debug.WriteLine(z);

            return(new Vector3(x, y, z));
        }