Ejemplo n.º 1
0
        public static float4x4 ProjectiveFromToV4F(ref float4 F0, ref float4 F1, ref float4 F2, ref float4 F3, ref float4 F4,
            ref float4 T0, ref float4 T1, ref float4 T2, ref float4 T3, ref float4 T4)
        {
            float4x4 P = new float4x4(
                F1.x, F1.y, F1.z, F1.w,
                F2.x, F2.y, F2.z, F2.w,
                F3.x, F3.y, F3.z, F3.w,
                F4.x, F4.y, F4.z, F4.w
                );

            float4x4 Q = new float4x4(
                T1.x, T1.y, T1.z, T1.w,
                T2.x, T2.y, T2.z, T2.w,
                T3.x, T3.y, T3.z, T3.w,
                T4.x, T4.y, T4.z, T4.w
                );

            return float4x4.Zero;
        }
Ejemplo n.º 2
0
        public static float4x4 View(ref float4 from, ref float4 at, ref float4 world_up, float roll)
        {
            //			float4 view_dir = (at - from);  view_dir.Unit();
            //			float4 right =(world_up^view_dir);
            //			float4 up = (view_dir^right);
            float4 view_dir = (at - from); view_dir.Unit();
            float4 right = (view_dir ^ world_up); right.Unit();
            float4 up = (right ^ view_dir);

            //			up.Unit();
            /*
                    float4x4 view = new float4x4(			
                        right[0],		right[1],		right[2],		0,
                        up[0],			up[1],			up[2],			0,
                        view_dir[0],	view_dir[1],	view_dir[2],	0,
                        -(right*(from-float4.set(0, 0, 0, 1))),
                        -(up*(from-float4.set(0, 0, 0, 1))),
                        -(view_dir*(from-float4.set(0, 0, 0, 1))), 1);
        */
            float4x4 view = new float4x4(
                right[0], up[0], view_dir[0], 0,
                right[1], up[1], view_dir[1], 0,
                right[2], up[2], view_dir[2], 0,
                -(right * from),
                -(up * from),
                -(view_dir * from), 1);

            // Set roll
            if (roll != 0f)
            {
                view = float4x4.RotateZ(-roll) * view;
            }

            return view;
        }
Ejemplo n.º 3
0
        //public static float4x4 RotateAbout(ref float4 P, ref float4 V, float angle)
        //{
        //    double theta = DegreesToRadians * angle;
        //    float s = (float)Math.Sin(0.5 * theta) / V.Length;
        //    Quaternion Q = new Quaternion(s * V.x, s * V.y, s * V.z, (float)Math.Cos(0.5 * angle));
        //    return Q.GetMatrix();
        //}

        public static float4x4 AffineFromToV4F(ref float4 F0, ref float4 F1, ref float4 F2, ref float4 F3,
            ref float4 T0, ref float4 T1, ref float4 T2, ref float4 T3)
        {
            float4x4 A = new float4x4(
                F0.x, F0.y, F0.z, F0.w,
                F1.x, F1.y, F1.z, F1.w,
                F2.x, F2.y, F2.z, F2.w,
                F3.x, F3.y, F3.z, F3.w
                );

            float4x4 B = new float4x4(
                T0.x, T0.y, T0.z, T0.w,
                T1.x, T1.y, T1.z, T1.w,
                T2.x, T2.y, T2.z, T2.w,
                T3.x, T3.y, T3.z, T3.w
                );

            return A.Inverse * B;
        }
Ejemplo n.º 4
0
        //static
        // Locate the row in A with the largest value in the 
        // c'th column.  Only columns between min and max-1 are
        //considered.

        private void Pivot(ref float4x4 T, int c, int[] R, int min, int max)
        {
            int r, pivot, tmp;

            pivot = min;
            for (r = min + 1; r < max; r++)
                if (Math.Abs(T[R[r], c]) > Math.Abs(T[R[pivot], c]))
                    pivot = r;
            if (pivot != min)
            {
                tmp = R[pivot]; R[pivot] = R[min]; R[min] = tmp;
            }
        }