示例#1
0
bool MathTestBench::test_m4_inverse(void)
{
    bool pass = 0x0;
    
    //Test
    
    printTestLine("Matrix4.inverse", pass);
    return pass;
}
示例#2
0
bool MathTestBench::test_m4_orthoNormalInverse(void)
{
    bool pass = 0x0;
    
    //Test
    
    printTestLine("Matrix4.orthonormalInverse", pass);
    return pass;
}
示例#3
0
bool MathTestBench::test_v3_magnitude_2(void)
{
    bool pass = 0x0;
    
    Vector3 a(0, 0, 0);
    float b = a.magnitude();
    
    pass = approx(b, 0);
    
    printTestLine("Vector3.magnitude (zero length)", pass);
    return pass;
}
示例#4
0
bool MathTestBench::test_v3_magnitude(void)
{
    bool pass = 0x0;
    
    Vector3 a(3, 0, 4);
    float b = a.magnitude();
    
    pass = approx(b, 5);
    
    printTestLine("Vector3.magnitude", pass);
    return pass;
}
示例#5
0
bool MathTestBench::test_v4_dehomogenize(void)
{
    bool pass = 0x0;
    
    Vector4 a(10, 20, 30, 10);
    Vector4 b = a.dehomogenize();
    
    pass = approx(b[0], 1) && approx(b[1], 2) && approx(b[2], 3) && approx(b[3],1);
    
    printTestLine("Vector4.dehomogenize", pass);
    return pass;
}
示例#6
0
bool MathTestBench::test_v3_scale(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    Vector3 b = a.scale(2.0);
    
    pass = approx(b[0], 2) && approx(b[1], 4) && approx(b[2], 6);
    
    printTestLine("Vector3.scale", pass);
    return pass;
}
示例#7
0
bool MathTestBench::test_v3_negate(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    Vector3 b = a.negate();
    
    pass = approx(b[0], -1) && approx(b[1], -2) && approx(b[2], -3);
    
    printTestLine("Vector3.negate", pass);
    return pass;
}
示例#8
0
bool MathTestBench::test_m4_inverse(void)
{
    bool pass = 0x0;
    
    //Test
    Matrix4 a(4,0,0,0,0,0,2,0,0,1,2,0,1,0,0,1);
    Matrix4 b(0.25,0,0,0,0,-1.0,1,0,0,0.5,0,0,-0.25,0,0,1);
    Matrix4 answer = a * b;
    pass = approx(answer.m[0][0],1) && approx(answer.m[1][1],1) && approx(answer.m[2][2],1) && approx(answer.m[3][3],1);
    printTestLine("Matrix4.inverse", pass);
    return pass;
}
示例#9
0
bool MathTestBench::test_v4_op_plus(void)
{
    bool pass = 0x0;
    
    Vector4 a(1, 2, 3, 1);
    Vector4 b(9, 8, 7, 0);
    Vector4 c = a + b;
    
    pass = approx(c[0], 10) && approx(c[1], 10) && approx(c[2], 10) && approx(c[3], 1);
    
    printTestLine("Vector4.(+)", pass);
    return pass;
}
示例#10
0
bool MathTestBench::test_v3_normalize_2(void)
{
    bool pass = 0x0;
    
    Vector3 a(0, 0, 0);
    Vector3 b = a.normalize();
    
    float r = 0.0;
    pass = approx(b[0], r) && approx(b[1], r) && approx(b[2], r);
    
    printTestLine("Vector3.normalize (zero length)", pass);
    return pass;
}
示例#11
0
bool MathTestBench::test_v3_op_minus(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    Vector3 b(9, 8, 7);
    Vector3 c = a - b;
    
    pass = approx(c[0], -8) && approx(c[1], -6) && approx(c[2], -4);
    
    printTestLine("Vector3.(-)", pass);
    return pass;
}
示例#12
0
//Vector 3 Tests
bool MathTestBench::test_v3_add(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    Vector3 b(9, 8, 7);
    Vector3 c = a.add(b);
    
    pass = approx(c[0], 10) && approx(c[1], 10) && approx(c[2], 10);
    
    printTestLine("Vector3.add", pass);
    return pass;
}
示例#13
0
bool MathTestBench::test_v3_angle(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 0, 0);
    Vector3 b(0, 0, 1);
    float c = a.angle(b);
    
    pass = approx(c, PI_OVER_2);
    
    printTestLine("Vector3.angle", pass);
    return pass;
}
示例#14
0
bool MathTestBench::test_v3_dot(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    Vector3 b(-3, 4, -5);
    float c = a.dot(b);
    
    pass = approx(c, -10);
    
    printTestLine("Vector3.dot", pass);
    return pass;
}
示例#15
0
bool MathTestBench::test_v3_op_star_f(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    float b = 13.1;
    Vector3 c = a * b;
    
    pass = approx(c[0], 13.1) && approx(c[1], 26.2) && approx(c[2], 39.3);
    
    printTestLine("Vector3.(*)(float)", pass);
    return pass;
}
示例#16
0
bool MathTestBench::test_v3_multiply_f(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    float b = 13.1;
    Vector3 c = a.multiply(b);
    
    pass = approx(c[0], 13.1) && approx(c[1], 26.2) && approx(c[2], 39.3);
    
    printTestLine("Vector3.multiply(float)", pass);
    return pass;
}
示例#17
0
bool MathTestBench::test_v3_op_star_v(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    Vector3 b(9, 8, 7);
    Vector3 c = a * b;
    
    pass = approx(c[0], 9) && approx(c[1], 16) && approx(c[2], 21);
    
    printTestLine("Vector3.(*)(Vector3)", pass);
    return pass;
}
示例#18
0
bool MathTestBench::test_v3_multiply_v(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    Vector3 b(9, 8, 7);
    Vector3 c = a.multiply(b);
    
    pass = approx(c[0], 9) && approx(c[1], 16) && approx(c[2], 21);
    
    printTestLine("Vector3.multiply(Vector3)", pass);
    return pass;
}
示例#19
0
bool MathTestBench::test_v4_subtract(void)
{
    bool pass = 0x0;
    
    Vector4 a(1, 2, 3, 1);
    Vector4 b(9, 8, 7, 1);
    Vector4 c = a.subtract(b);
    
    pass = approx(c[0], -8) && approx(c[1], -6) && approx(c[2], -4) && approx(c[3], 0);
    
    printTestLine("Vector4.subtract", pass);
    return pass;
}
示例#20
0
bool MathTestBench::test_v4_op_minus(void)
{
    bool pass = 0x0;
    
    Vector4 a(1, 2, 3, 1);
    Vector4 b(9, 8, 7, 1);
    Vector4 c = a - b;
    
    pass = approx(c[0], -8) && approx(c[1], -6) && approx(c[2], -4) && approx(c[3], 0);
    
    printTestLine("Vector4.(-)", pass);
    return pass;
}
示例#21
0
bool MathTestBench::test_v3_cross(void)
{
    bool pass = 0x0;
    
    Vector3 a(0, 0, 1);
    Vector3 b(1, 0, 0);
    Vector3 c = a.cross(b);
    
    pass = approx(c[0], 0) && approx(c[1], 1) && approx(c[2], 0);
    
    printTestLine("Vector3.cross", pass);
    return pass;
}
示例#22
0
bool MathTestBench::test_v3_normalize(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 1, 1);
    float r = 1.0 / a.magnitude();
    Vector3 b = a.normalize();
    
    pass = approx(b[0], r) && approx(b[1], r) && approx(b[2], r);
    
    printTestLine("Vector3.normalize", pass);
    return pass;
}
示例#23
0
bool MathTestBench::test_v3_subtract(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    Vector3 b(9, 8, 7);
    Vector3 c = a.subtract(b);
    
    pass = approx(c[0], -8) && approx(c[1], -6) && approx(c[2], -4);
    
    printTestLine("Vector3.subtract", pass);
    return pass;
}
示例#24
0
bool MathTestBench::test_v3_op_plus(void)
{
    bool pass = 0x0;
    
    Vector3 a(1, 2, 3);
    Vector3 b(9, 8, 7);
    Vector3 c = a + b;
    
    pass = approx(c[0], 10) && approx(c[1], 10) && approx(c[2], 10);
    
    printTestLine("Vector3.(+)", pass);
    return pass;
}
示例#25
0
bool MathTestBench::test_m4_op_star_v3(void)
{
    bool pass = 0x0;
    
    Matrix4 a(1,0,0,0,0,2,0,0,0,0,3,0,0,0,0,1);
    Vector3 b(6, 7, 8);
    
    Vector3 c = a * b;
    
    pass = approx(c[0], 6) && approx(c[1], 14) && approx(c[2], 24);
    
    printTestLine("Matrix4.(*)(Matrix4)", pass);
    return pass;
}
示例#26
0
bool MathTestBench::test_m4_multiply_v3(void)
{
    bool pass = 0x0;
    
    Matrix4 a(1,0,0,0,0,2,0,0,0,0,3,0,0,0,0,1);
    Vector3 b(6, 7, 8);
    
    Vector3 c = a.multiply(b);
    
    pass = approx(c[0], 6) && approx(c[1], 14) && approx(c[2], 24);
    
    printTestLine("Matrix4.multiply(Vector3)", pass);
    return pass;
}
示例#27
0
bool MathTestBench::test_m4_op_star_m4(void)
{
    bool pass = 0x0;
    
    Matrix4 a(1,0,0,0,0,2,0,0,0,0,3,0,0,0,0,1);
    Matrix4 b(5,0,0,0,0,6,0,0,0,0,7,0,0,0,0,1);
    
    Matrix4 c = a * b;
    
    pass = approx(c.get(0, 0), 5) && approx(c.get(1, 1), 12) && approx(c.get(2, 2), 21) && approx(c.get(3, 3), 1);
    
    printTestLine("Matrix4.(*)(Matrix4)", pass);
    return pass;
}
示例#28
0
bool MathTestBench::test_m4_makeTranslate_f3(void)
{
    bool pass = 0x0;
    
    Matrix4 a;
    a.makeTranslate(2.0, 3.0, 4.0);
    
    Vector4 b(1, 1, 1, 1);
    
    b = a * b;
    
    pass = approx(b[0], 3) && approx(b[1], 4) && approx(b[2], 5);
    
    printTestLine("Matrix4.makeTranslate(float, float ,float)", pass);
    return pass;
}
示例#29
0
bool MathTestBench::test_m4_makeScale_f(void)
{
    bool pass = 0x0;
    
    Matrix4 a;
    a.makeScale(2.0);
    
    Vector4 b(1, 2, 3, 0);
    
    b = a * b;
    
    pass = approx(b[0], 2) && approx(b[1], 4) && approx(b[2], 6);
    
    printTestLine("Matrix4.makeScale(float)", pass);
    return pass;
}
示例#30
0
bool MathTestBench::test_m4_makeRotateZ(void)
{
    bool pass = 0x0;
    
    Matrix4 a;
    a.makeRotateZ(PI_OVER_2);
    
    Vector4 b(1, 0, 0, 0);
    
    b = a * b;
    
    pass = approx(b[0], 0) && approx(b[1], 1) && approx(b[2], 0);
    
    printTestLine("Matrix4.makeRotateZ", pass);
    return pass;
}