8
public class Matrix4Test
11
public void Matrix4_SixteenValueConstructor()
13
Matrix4 A = new Matrix4( 0, 1, 2, 3,
18
Assert.AreEqual(0, A.M11);
19
Assert.AreEqual(1, A.M12);
20
Assert.AreEqual(2, A.M13);
21
Assert.AreEqual(3, A.M14);
23
Assert.AreEqual(4, A.M21);
24
Assert.AreEqual(5, A.M22);
25
Assert.AreEqual(6, A.M23);
26
Assert.AreEqual(7, A.M24);
28
Assert.AreEqual(8, A.M31);
29
Assert.AreEqual(9, A.M32);
30
Assert.AreEqual(10, A.M33);
31
Assert.AreEqual(11, A.M34);
33
Assert.AreEqual(12, A.M41);
34
Assert.AreEqual(13, A.M42);
35
Assert.AreEqual(14, A.M43);
36
Assert.AreEqual(15, A.M44);
40
public void Matrix4_Matrix3Constructor()
42
Matrix3 B = new Matrix3( 1, 2, 3,
46
Matrix4 A = new Matrix4(B);
48
Assert.AreEqual(B.M11, A.M11);
49
Assert.AreEqual(B.M12, A.M12);
50
Assert.AreEqual(B.M13, A.M13);
52
Assert.AreEqual(B.M21, A.M21);
53
Assert.AreEqual(B.M22, A.M22);
54
Assert.AreEqual(B.M23, A.M23);
56
Assert.AreEqual(B.M31, A.M31);
57
Assert.AreEqual(B.M32, A.M32);
58
Assert.AreEqual(B.M33, A.M33);
62
public void Matrix4_FourVector4Constructor()
64
Vector4 V = new Vector4(1, 2, 3, 4);
65
Vector4 U = new Vector4(5, 6, 7, 8);
66
Vector4 S = new Vector4(9, 10, 11, 12);
67
Vector4 T = new Vector4(13, 14, 15, 16);
69
Matrix4 A = new Matrix4(V, U, S, T);
71
Assert.AreEqual(V.X, A.M11);
72
Assert.AreEqual(V.Y, A.M12);
73
Assert.AreEqual(V.Z, A.M13);
74
Assert.AreEqual(V.W, A.M14);
76
Assert.AreEqual(U.X, A.M21);
77
Assert.AreEqual(U.Y, A.M22);
78
Assert.AreEqual(U.Z, A.M23);
79
Assert.AreEqual(U.W, A.M24);
81
Assert.AreEqual(S.X, A.M31);
82
Assert.AreEqual(S.Y, A.M32);
83
Assert.AreEqual(S.Z, A.M33);
84
Assert.AreEqual(S.W, A.M34);
86
Assert.AreEqual(T.X, A.M41);
87
Assert.AreEqual(T.Y, A.M42);
88
Assert.AreEqual(T.Z, A.M43);
89
Assert.AreEqual(T.W, A.M44);
94
public void Matrix4_Equal_operator()
96
Matrix4 A = new Matrix4( 0, 1, 2, 3,
101
Matrix4 B = new Matrix4( 0, 1, 2, 3,
106
Assert.IsTrue(A == B);
110
public void Matrix4_Matrix4TimesMatrix4_operator()
112
Matrix4 A = new Matrix4( 0, 1, 2, 3,
117
Matrix4 B = new Matrix4( 0, 1, 2, 3,
122
Matrix4 expected = new Matrix4( 56, 62, 68, 74,
127
Matrix4 result = A * B;
128
Assert.IsTrue(expected == result);
132
public void Matrix4_Matrix4PlusMatrix4_operator()
134
Matrix4 A = new Matrix4( 0, 1, 2, 3,
139
Matrix4 B = new Matrix4( 0, 1, 2, 3,
144
Matrix4 expected = new Matrix4( 0, 2, 4, 6,
149
Matrix4 result = A + B;
150
Assert.IsTrue(expected == result);
154
public void Matrix4_Matrix4MinusMatrix4_operator()
156
Matrix4 A = new Matrix4( 0, 1, 2, 3,
161
Matrix4 B = new Matrix4( 0, 1, 2, 3,
166
Matrix4 expected = new Matrix4( 0, 0, 0, 0,
171
Matrix4 result = A - B;
172
Assert.IsTrue(expected == result);
176
public void Matrix4_Index_Operator()
178
Matrix4 A = new Matrix4();
195
Assert.AreEqual(0, A[0, 0]);
196
Assert.AreEqual(1, A[0, 1]);
197
Assert.AreEqual(2, A[0, 2]);
198
Assert.AreEqual(3, A[0, 3]);
199
Assert.AreEqual(4, A[1, 0]);
200
Assert.AreEqual(5, A[1, 1]);
201
Assert.AreEqual(6, A[1, 2]);
202
Assert.AreEqual(7, A[1, 3]);
203
Assert.AreEqual(8, A[2, 0]);
204
Assert.AreEqual(9, A[2, 1]);
205
Assert.AreEqual(10, A[2, 2]);
206
Assert.AreEqual(11, A[2, 3]);
207
Assert.AreEqual(12, A[3, 0]);
208
Assert.AreEqual(13, A[3, 1]);
209
Assert.AreEqual(14, A[3, 2]);
210
Assert.AreEqual(15, A[3, 3]);
214
public void Matrix4_Index_NegativeIndexException()
216
Matrix4 A = new Matrix4();
217
bool negativeIndexException = false;
224
negativeIndexException = true;
226
Assert.IsTrue(negativeIndexException);
228
negativeIndexException = false;
235
negativeIndexException = true;
237
Assert.IsTrue(negativeIndexException);
239
negativeIndexException = false;
246
negativeIndexException = true;
248
Assert.IsTrue(negativeIndexException);
252
public void Matrix4_Index_LargeIndexException()
254
Matrix4 A = new Matrix4();
255
bool largeIndexException = false;
262
largeIndexException = true;
264
Assert.IsTrue(largeIndexException);
266
largeIndexException = false;
273
largeIndexException = true;
275
Assert.IsTrue(largeIndexException);
277
largeIndexException = false;
284
largeIndexException = true;
286
Assert.IsTrue(largeIndexException);