本文整理汇总了C#中Matrix44类的典型用法代码示例。如果您正苦于以下问题:C# Matrix44类的具体用法?C# Matrix44怎么用?C# Matrix44使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Matrix44类属于命名空间,在下文中一共展示了Matrix44类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: mul
public void mul(Matrix44 other)
{
float []result;
result = new float[16];
result[0 + 0*4] = Matrix44.vectorDot4(array[0 + 0*4], array[1 + 0*4], array[2 + 0*4], array[3 + 0*4], other.array[0 + 0*4], other.array[0 + 1*4], other.array[0 + 2*4], other.array[0 + 3*4]);
result[1 + 0*4] = Matrix44.vectorDot4(array[0 + 0*4], array[1 + 0*4], array[2 + 0*4], array[3 + 0*4], other.array[1 + 0*4], other.array[1 + 1*4], other.array[1 + 2*4], other.array[1 + 3*4]);
result[2 + 0*4] = Matrix44.vectorDot4(array[0 + 0*4], array[1 + 0*4], array[2 + 0*4], array[3 + 0*4], other.array[2 + 0*4], other.array[2 + 1*4], other.array[2 + 2*4], other.array[2 + 3*4]);
result[3 + 0*4] = Matrix44.vectorDot4(array[0 + 0*4], array[1 + 0*4], array[2 + 0*4], array[3 + 0*4], other.array[3 + 0*4], other.array[3 + 1*4], other.array[3 + 2*4], other.array[3 + 3*4]);
result[0 + 1*4] = Matrix44.vectorDot4(array[0 + 1*4], array[1 + 1*4], array[2 + 1*4], array[3 + 1*4], other.array[0 + 0*4], other.array[0 + 1*4], other.array[0 + 2*4], other.array[0 + 3*4]);
result[1 + 1*4] = Matrix44.vectorDot4(array[0 + 1*4], array[1 + 1*4], array[2 + 1*4], array[3 + 1*4], other.array[1 + 0*4], other.array[1 + 1*4], other.array[1 + 2*4], other.array[1 + 3*4]);
result[2 + 1*4] = Matrix44.vectorDot4(array[0 + 1*4], array[1 + 1*4], array[2 + 1*4], array[3 + 1*4], other.array[2 + 0*4], other.array[2 + 1*4], other.array[2 + 2*4], other.array[2 + 3*4]);
result[3 + 1*4] = Matrix44.vectorDot4(array[0 + 1*4], array[1 + 1*4], array[2 + 1*4], array[3 + 1*4], other.array[3 + 0*4], other.array[3 + 1*4], other.array[3 + 2*4], other.array[3 + 3*4]);
result[0 + 2*4] = Matrix44.vectorDot4(array[0 + 2*4], array[1 + 2*4], array[2 + 2*4], array[3 + 2*4], other.array[0 + 0*4], other.array[0 + 1*4], other.array[0 + 2*4], other.array[0 + 3*4]);
result[1 + 2*4] = Matrix44.vectorDot4(array[0 + 2*4], array[1 + 2*4], array[2 + 2*4], array[3 + 2*4], other.array[1 + 0*4], other.array[1 + 1*4], other.array[1 + 2*4], other.array[1 + 3*4]);
result[2 + 2*4] = Matrix44.vectorDot4(array[0 + 2*4], array[1 + 2*4], array[2 + 2*4], array[3 + 2*4], other.array[2 + 0*4], other.array[2 + 1*4], other.array[2 + 2*4], other.array[2 + 3*4]);
result[3 + 2*4] = Matrix44.vectorDot4(array[0 + 2*4], array[1 + 2*4], array[2 + 2*4], array[3 + 2*4], other.array[3 + 0*4], other.array[3 + 1*4], other.array[3 + 2*4], other.array[3 + 3*4]);
result[0 + 3*4] = Matrix44.vectorDot4(array[0 + 3*4], array[1 + 3*4], array[2 + 3*4], array[3 + 3*4], other.array[0 + 0*4], other.array[0 + 1*4], other.array[0 + 2*4], other.array[0 + 3*4]);
result[1 + 3*4] = Matrix44.vectorDot4(array[0 + 3*4], array[1 + 3*4], array[2 + 3*4], array[3 + 3*4], other.array[1 + 0*4], other.array[1 + 1*4], other.array[1 + 2*4], other.array[1 + 3*4]);
result[2 + 3*4] = Matrix44.vectorDot4(array[0 + 3*4], array[1 + 3*4], array[2 + 3*4], array[3 + 3*4], other.array[2 + 0*4], other.array[2 + 1*4], other.array[2 + 2*4], other.array[2 + 3*4]);
result[3 + 3*4] = Matrix44.vectorDot4(array[0 + 3*4], array[1 + 3*4], array[2 + 3*4], array[3 + 3*4], other.array[3 + 0*4], other.array[3 + 1*4], other.array[3 + 2*4], other.array[3 + 3*4]);
array = result;
}
示例2: Transform
public static Vector4 Transform(Vector4 v, Matrix44 m)
{
Vector4 vector4_1 = new Vector4();
for (int index = 0; index < 4; ++index)
vector4_1[index] = (float)((double)v[0] * (double)m[0][index] + (double)v[1] * (double)m[1][index] + (double)v[2] * (double)m[2][index] + (double)v[3] * (double)m[3][index]);
Vector4 vector4_2;
(vector4_2 = vector4_1)[0] = vector4_2[0] / vector4_1[3];
Vector4 vector4_3;
(vector4_3 = vector4_1)[1] = vector4_3[1] / vector4_1[3];
Vector4 vector4_4;
(vector4_4 = vector4_1)[2] = vector4_4[2] / vector4_1[3];
return vector4_1;
}
示例3: TestOperator_Addition_iv
public void TestOperator_Addition_iv ()
{
for(Int32 i = 0; i < 100; ++i)
{
var a = GetNextRandomMatrix44();
var b = GetNextRandomMatrix44();
var expected = new Matrix44(
a.R0C0 + b.R0C0,
a.R0C1 + b.R0C1,
a.R0C2 + b.R0C2,
a.R0C3 + b.R0C3,
a.R1C0 + b.R1C0,
a.R1C1 + b.R1C1,
a.R1C2 + b.R1C2,
a.R1C3 + b.R1C3,
a.R2C0 + b.R2C0,
a.R2C1 + b.R2C1,
a.R2C2 + b.R2C2,
a.R2C3 + b.R2C3,
a.R3C0 + b.R3C0,
a.R3C1 + b.R3C1,
a.R3C2 + b.R3C2,
a.R3C3 + b.R3C3
);
this.TestAddition(a, b, expected);
}
}
示例4: ICall_Material_SetValueMatrix44
private static extern void ICall_Material_SetValueMatrix44(MaterialInstance self, String paramName, ref Matrix44 value);
示例5: Render
internal void Render(Graphics zGfx, String pass, Matrix44 zView, Matrix44 zProjection)
{
if (!passState.ContainsKey (pass))
return;
zGfx.SetCullMode (CullMode.None);
zGfx.SetActive ((VertexBuffer)null);
zGfx.SetActive ((IndexBuffer)null);
zGfx.SetActive ((Texture)null, 0);
shader.SetVariable ("View", zView);
shader.SetVariable ("Projection", zProjection);
zGfx.SetActive (shader, VertexPositionTextureColour.Default.VertexDeclaration);
_render_batch(zGfx, pass);
}
示例6: TestOperator_Multiplication_ii
public void TestOperator_Multiplication_ii ()
{
for(Int32 i = 0; i < 100; ++i)
{
var a = GetNextRandomMatrix44();
var b = GetNextRandomMatrix44();
var c = new Matrix44(
(a.R0C0 * b.R0C0) + (a.R0C1 * b.R1C0) +
(a.R0C2 * b.R2C0) + (a.R0C3 * b.R3C0),
(a.R0C0 * b.R0C1) + (a.R0C1 * b.R1C1) +
(a.R0C2 * b.R2C1) + (a.R0C3 * b.R3C1),
(a.R0C0 * b.R0C2) + (a.R0C1 * b.R1C2) +
(a.R0C2 * b.R2C2) + (a.R0C3 * b.R3C2),
(a.R0C0 * b.R0C3) + (a.R0C1 * b.R1C3) +
(a.R0C2 * b.R2C3) + (a.R0C3 * b.R3C3),
(a.R1C0 * b.R0C0) + (a.R1C1 * b.R1C0) +
(a.R1C2 * b.R2C0) + (a.R1C3 * b.R3C0),
(a.R1C0 * b.R0C1) + (a.R1C1 * b.R1C1) +
(a.R1C2 * b.R2C1) + (a.R1C3 * b.R3C1),
(a.R1C0 * b.R0C2) + (a.R1C1 * b.R1C2) +
(a.R1C2 * b.R2C2) + (a.R1C3 * b.R3C2),
(a.R1C0 * b.R0C3) + (a.R1C1 * b.R1C3) +
(a.R1C2 * b.R2C3) + (a.R1C3 * b.R3C3),
(a.R2C0 * b.R0C0) + (a.R2C1 * b.R1C0) +
(a.R2C2 * b.R2C0) + (a.R2C3 * b.R3C0),
(a.R2C0 * b.R0C1) + (a.R2C1 * b.R1C1) +
(a.R2C2 * b.R2C1) + (a.R2C3 * b.R3C1),
(a.R2C0 * b.R0C2) + (a.R2C1 * b.R1C2) +
(a.R2C2 * b.R2C2) + (a.R2C3 * b.R3C2),
(a.R2C0 * b.R0C3) + (a.R2C1 * b.R1C3) +
(a.R2C2 * b.R2C3) + (a.R2C3 * b.R3C3),
(a.R3C0 * b.R0C0) + (a.R3C1 * b.R1C0) +
(a.R3C2 * b.R2C0) + (a.R3C3 * b.R3C0),
(a.R3C0 * b.R0C1) + (a.R3C1 * b.R1C1) +
(a.R3C2 * b.R2C1) + (a.R3C3 * b.R3C1),
(a.R3C0 * b.R0C2) + (a.R3C1 * b.R1C2) +
(a.R3C2 * b.R2C2) + (a.R3C3 * b.R3C2),
(a.R3C0 * b.R0C3) + (a.R3C1 * b.R1C3) +
(a.R3C2 * b.R2C3) + (a.R3C3 * b.R3C3));
this.TestMultiplication(a, b, c);
}
}
示例7: TestMultiplication
// Test Operator: Multiplication //-----------------------------------//
/// <summary>
/// Helper method for testing multiplication.
/// </summary>
void TestMultiplication (Matrix44 a, Matrix44 b, Matrix44 expected )
{
// This test asserts the following:
// a * b == expected
Matrix44 result_1b; Matrix44.Multiply(ref a, ref b, out result_1b);
Assert.That(result_1b, Is.EqualTo(expected));
#if (VARIANTS_ENABLED)
var result_1a = a * b;
Assert.That(result_1a, Is.EqualTo(expected));
#endif
}
示例8: TestOperator_Negation_i
public void TestOperator_Negation_i ()
{
Double r = 3432;
Double s = -6218;
Double t = -3432;
Double u = 6218;
var a = new Matrix44(
r, s, t, u,
r, s, t, u,
r, s, t, u,
r, s, t, u);
var b = new Matrix44(
u, t, s, r,
u, t, s, r,
u, t, s, r,
u, t, s, r);
var c = new Matrix44(
t, u, r, s,
t, u, r, s,
t, u, r, s,
t, u, r, s);
var d = new Matrix44(
s, r, u, t,
s, r, u, t,
s, r, u, t,
s, r, u, t);
this.TestNegation(a, c);
this.TestNegation(b, d);
}
示例9: TestOperator_Subtraction_iii
public void TestOperator_Subtraction_iii ()
{
for(Int32 i = 0; i < 100; ++i)
{
var a = GetNextRandomMatrix44();
var b = GetNextRandomMatrix44();
var expected = new Matrix44(
a.R0C0 - b.R0C0,
a.R0C1 - b.R0C1,
a.R0C2 - b.R0C2,
a.R0C3 - b.R0C3,
a.R1C0 - b.R1C0,
a.R1C1 - b.R1C1,
a.R1C2 - b.R1C2,
a.R1C3 - b.R1C3,
a.R2C0 - b.R2C0,
a.R2C1 - b.R2C1,
a.R2C2 - b.R2C2,
a.R2C3 - b.R2C3,
a.R3C0 - b.R3C0,
a.R3C1 - b.R3C1,
a.R3C2 - b.R3C2,
a.R3C3 - b.R3C3
);
this.TestSubtraction(a, b, expected);
}
}
示例10: TestStaticFn_Transpose_i
public void TestStaticFn_Transpose_i ()
{
Matrix44 startMatrix = new Matrix44(
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
Matrix44 testMatrix = startMatrix;
Matrix44 testMatrixExpectedTranspose = new Matrix44(
0, 4, 8, 12,
1, 5, 9, 13,
2, 6, 10, 14,
3, 7, 11, 15);
// RUN THE STATIC VERSION OF THE FUNCTION
Matrix44 resultMatrix = Matrix44.Identity;
Matrix44.Transpose(ref testMatrix, out resultMatrix);
Assert.That(resultMatrix, Is.EqualTo(testMatrixExpectedTranspose));
}
示例11: TestStaticFn_CreateFromQuaternion_ii
public void TestStaticFn_CreateFromQuaternion_ii ()
{
Quaternion q = new Quaternion (
(Double) (-0.163863438188094),
(Double) (0.7106071968472370),
(Double) (0.6722283804612080),
(Double) (-0.127652614217613));
Matrix44 m; Matrix44.CreateFromQuaternion(ref q, out m);
Matrix44 expected = new Matrix44 ();
expected.R0C0 = (Double) (-0.9137071674171720);
expected.R0C1 = (Double) (-0.4045084971874740);
expected.R0C2 = (Double) (-0.0388855746211755);
expected.R0C3 = 0;
expected.R1C0 = (Double) (-0.0612616567188929);
expected.R1C1 = (Double) (0.0425155562553572);
expected.R1C2 = (Double) (0.9972158426801860);
expected.R1C3 = 0;
expected.R2C0 = (Double) (-0.4017290400587740);
expected.R2C1 = (Double) (0.9135454576426010);
expected.R2C2 = (Double) (-0.0636276291718221);
expected.R2C3 = 0;
expected.R3C0 = 0;
expected.R3C1 = 0;
expected.R3C2 = 0;
expected.R3C3 = 1;
AssertEqualWithinReason (m, expected);
}
示例12: TestStaticFn_CreateFromQuaternion_i
public void TestStaticFn_CreateFromQuaternion_i ()
{
Double yaw; Maths.Pi(out yaw); yaw /= (Double) 4;
Double pitch; Maths.Pi(out pitch); pitch /= (Double) (-8);
Double roll; Maths.Pi(out roll); roll /= (Double) 2;
Quaternion q; Quaternion.CreateFromYawPitchRoll(ref yaw, ref pitch, ref roll, out q);
q.Normalise();
Matrix44 m; Matrix44.CreateFromQuaternion(ref q, out m);
Matrix44 expected = new Matrix44 ();
expected.R0C0 = (Double) (-0.270598);
expected.R0C1 = (Double) 0.9238795;
expected.R0C2 = (Double) (-0.270598);
expected.R0C3 = 0;
expected.R1C0 = (Double) (-0.7071067);
expected.R1C1 = 0;
expected.R1C2 = (Double) 0.7071067;
expected.R1C3 = 0;
expected.R2C0 = (Double) 0.6532815;
expected.R2C1 = (Double) 0.3826834;
expected.R2C2 = (Double) 0.6532815;
expected.R2C3 = 0;
expected.R3C0 = 0;
expected.R3C1 = 0;
expected.R3C2 = 0;
expected.R3C3 = 1;
AssertEqualWithinReason (m, expected);
}
示例13: TestConstant_Identity_i
public void TestConstant_Identity_i ()
{
Matrix44 result = Matrix44.Identity;
Matrix44 expected = new Matrix44 (
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
AssertEqualWithinReason(result, expected);
} [Test]
示例14: TestMemberFn_ToString
public void TestMemberFn_ToString ()
{
Matrix44 a = new Matrix44(
42, -17, 13, -44,
46, -23, -22, 90,
34, -21, 52, 33,
88, -12, -78, 50);
String result = a.ToString();
String expected =
"{ " +
"{R0C0:42 R0C1:-17 R0C2:13 R0C3:-44} " +
"{R1C0:46 R1C1:-23 R1C2:-22 R1C3:90} " +
"{R2C0:34 R2C1:-21 R2C2:52 R2C3:33} " +
"{R3C0:88 R3C1:-12 R3C2:-78 R3C3:50} " +
"}";
Assert.That(result, Is.EqualTo(expected));
}
示例15: Test_Constructors
public void Test_Constructors ()
{
{
// Test default values
Matrix44 a = new Matrix44();
Assert.That(a, Is.EqualTo(Matrix44.Zero));
}
{
Double a = -18759;
Double b = 345;
Double c = 774;
Double d = -3431;
Double e = -55;
Double f = 47;
Double g = 45;
Double h = 3461;
Double i = -4;
Double j = 453;
Double k = -3;
Double l = -3441;
Double m = -189;
Double n = 5;
Double o = -87;
Double p = 341;
Matrix44 expected = new Matrix44(
a, b, c, d,
e, f, g, h,
i, j, k, l,
m, n, o, p);
Assert.That(expected.R0C0, Is.EqualTo(a));
Assert.That(expected.R0C1, Is.EqualTo(b));
Assert.That(expected.R0C2, Is.EqualTo(c));
Assert.That(expected.R0C3, Is.EqualTo(d));
Assert.That(expected.R1C0, Is.EqualTo(e));
Assert.That(expected.R1C1, Is.EqualTo(f));
Assert.That(expected.R1C2, Is.EqualTo(g));
Assert.That(expected.R1C3, Is.EqualTo(h));
Assert.That(expected.R2C0, Is.EqualTo(i));
Assert.That(expected.R2C1, Is.EqualTo(j));
Assert.That(expected.R2C2, Is.EqualTo(k));
Assert.That(expected.R2C3, Is.EqualTo(l));
Assert.That(expected.R3C0, Is.EqualTo(m));
Assert.That(expected.R3C1, Is.EqualTo(n));
Assert.That(expected.R3C2, Is.EqualTo(o));
Assert.That(expected.R3C3, Is.EqualTo(p));
}
}