예제 #1
0
 public float4x4(float4 r0, float4 r1, float4 r2, float4 r3)
 {
     M11 = r0.x; M12 = r0.y; M13 = r0.z; M14 = r0.w;
     M21 = r1.x; M22 = r1.y; M23 = r1.z; M24 = r1.w;
     M31 = r2.x; M32 = r2.y; M33 = r2.z; M34 = r2.w;
     M41 = r3.x; M42 = r3.y; M43 = r3.z; M44 = r3.w;
 }
예제 #2
0
 /// <summary>
 /// Construct a new matrix from 4 vectors representing each row
 /// </summary>
 /// <param name="row0">Top row of the matrix</param>
 /// <param name="row1">2nd row of the matrix</param>
 /// <param name="row2">3rd row of the matrix</param>
 /// <param name="row3">Bottom row of the matrix</param>
 public Matrix4(float4 row0, float4 row1, float4 row2, float4 row3)
 {
     Row0 = row0;
     Row1 = row1;
     Row2 = row2;
     Row3 = row3;
 }
예제 #3
0
 public float4x3(float4 r0, float4 r1, float4 r2)
 {
     M11 = r0.x; M12 = r1.x; M13 = r2.x;
     M21 = r0.y; M22 = r1.y; M23 = r2.y;
     M31 = r0.z; M32 = r1.z; M33 = r2.z;
     M41 = r0.w; M42 = r1.w; M43 = r2.w;
 }
예제 #4
0
 public void RasterPos(float4 vec)
 {
     gl.glRasterPos4f(vec.x, vec.y, vec.z, vec.w);
 }
예제 #5
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;
        }
예제 #6
0
        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;
        }
예제 #7
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;
     quaterion Q = new quaterion(s * V.x, s * V.y, s * V.z, (float)Math.Cos(0.5 * angle));
     return Q.GetMatrix();
 }
예제 #8
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;
        }
예제 #9
0
 public static float4x4 Scale(ref float4 s)
 {
     return new float4x4(
         s.x, 0, 0, 0,
         0, s.y, 0, 0,
         0, 0, s.z, 0,
         0, 0, 0, 1
         );
 }
예제 #10
0
        public static float4 Plane(ref float4 p1, ref float4 p2, ref float4 p3)
        {
            float4 a = p2 - p1;
            float4 b = p2 - p3;
            float4 pln = b ^ a;
            pln.w = -pln * p1;

            return pln;
        }
예제 #11
0
 public float3x4(float4 R1, float4 R2, float4 R3)
 {
     M11 = R1.x; M12 = R1.y; M13 = R1.z; M14 = R1.w;
     M21 = R2.x; M22 = R2.y; M23 = R2.z; M24 = R2.w;
     M31 = R3.x; M32 = R3.y; M33 = R3.z; M34 = R3.w;
 }
예제 #12
0
        float4 ReadFloat4(BinaryReader reader)
        {
            float4 newFloat4 = new float4();

            newFloat4.x = reader.ReadSingle();
            newFloat4.y = reader.ReadSingle();
            newFloat4.z = reader.ReadSingle();
            newFloat4.w = reader.ReadSingle();

            return newFloat4;
        }
예제 #13
0
파일: GL.cs 프로젝트: Wiladams/NewTOAPIA
 public static void Color4(float4 vec)
 {
     gl.glColor4f(vec.x, vec.y, vec.z, vec.w);
 }
예제 #14
0
파일: GL.cs 프로젝트: Wiladams/NewTOAPIA
 public static void Vertex(float4 vec)
 {
     gl.glVertex4d(vec.x, vec.y, vec.z, vec.w);
 }
예제 #15
0
        public static float4 VectorFrom3Points(ref float4 p1, ref float4 p2, ref float4 p3)
        {
            float4 a = p2 - p1;
            float4 b = p2 - p3;
            float4 n = b ^ a;

            n.Unit();
            return n;
        }
예제 #16
0
 public void Color4(float4 vec)
 {
     gl.glColor4f(vec.x, vec.y, vec.z, vec.w);
     // Don't check for error, because this is called between
     // glBegin()/glEnd()
     //CheckException();
 }
예제 #17
0
 public static float4x4 Translate(ref float4 t)
 {
     return new float4x4(
         1, 0, 0, 0,
         0, 1, 0, 0,
         0, 0, 1, 0,
         t.x, t.y, t.z, 1
         );
 }
예제 #18
0
 public void Material(GLFace face, MaterialParameter pname, float4 parameters)
 {
     gl.glMaterialfv((int)face, (int)pname, (float[])parameters);
     // Don't check for error, because this is called between
     // glBegin()/glEnd()
     //CheckException();
 }
예제 #19
0
 public static float4 Crs4(float4 a, float4 b, float4 c)
 {
     return new float4(
         a.z * b.y * c.w - a.y * b.z * c.w - a.z * b.w * c.y + a.w * b.z * c.y + a.y * b.w * c.z - a.w * b.y * c.z,
         -(a.z * b.x * c.w) + a.x * b.z * c.w + a.z * b.w * c.x - a.w * b.z * c.x - a.x * b.w * c.z + a.w * b.x * c.z,
         a.y * b.x * c.w - a.x * b.y * c.w - a.y * b.w * c.x + a.w * b.y * c.x + a.x * b.w * c.y - a.w * b.x * c.y,
         -(a.z * b.y * c.x) + a.y * b.z * c.x + a.z * b.x * c.y - a.x * b.z * c.y - a.y * b.x * c.z + a.x * b.y * c.z);
 }