Created
February 20, 2012 21:04
-
-
Save profelis/1871413 to your computer and use it in GitHub Desktop.
Matrix3D test with my bug fixes (mtest)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test.geom; | |
import massive.munit.util.Timer; | |
import massive.munit.Assert; | |
import massive.munit.async.AsyncFactory; | |
import nme.geom.Matrix3D; | |
import nme.geom.Vector3D; | |
/** | |
* Auto generated MassiveUnit Test Class for nme.geom.Matrix3D | |
* tested for neko, js, flash9 | |
*/ | |
class Matrix3DTest | |
{ | |
var m1:Matrix3D; | |
var m2:Matrix3D; | |
public function new() | |
{ | |
} | |
@BeforeClass | |
public function beforeClass():Void | |
{ | |
} | |
@AfterClass | |
public function afterClass():Void | |
{ | |
} | |
@Before | |
public function setup():Void | |
{ | |
} | |
@After | |
public function tearDown():Void | |
{ | |
} | |
@Test | |
public function testPrependAndDecompose():Void | |
{ | |
trace("prepend"); | |
m1 = new Matrix3D(); | |
m2 = new Matrix3D(); | |
m1.prependTranslation(100, 200, 300); | |
m1.prependRotation(30, new Vector3D(1, 0, 0)); | |
m1.prependRotation(45, new Vector3D(0, 1, 0)); | |
m1.prependRotation(60, new Vector3D(0, 0, 1)); | |
m1.prependScale(3, 4, 5); | |
m2.recompose(m1.decompose()); | |
var d1 = m1.decompose(); | |
var d2 = m2.decompose(); | |
trace(d1); | |
trace(d2); | |
Assert.isTrue(d1[0].nearEquals(d2[0], 0.00001)); | |
Assert.isTrue(d1[1].nearEquals(d2[1], 0.00001)); | |
Assert.isTrue(d1[2].nearEquals(d2[2], 0.00001)); | |
} | |
@Test | |
public function testAppendAndDecompose():Void | |
{ | |
trace("append"); | |
m1 = new Matrix3D(); | |
m2 = new Matrix3D(); | |
m1.appendTranslation(100, 200, 300); | |
m1.appendRotation(30, new Vector3D(1, 0, 0)); | |
m1.appendRotation(45, new Vector3D(0, 1, 0)); | |
m1.appendRotation(60, new Vector3D(0, 0, 1)); | |
m1.appendScale(3, 4, 5); | |
m2.recompose(m1.decompose()); | |
var d1 = m1.decompose(); | |
var d2 = m2.decompose(); | |
trace(d1); | |
trace(d2); | |
Assert.isTrue(d1[0].nearEquals(d2[0], 0.00001)); | |
Assert.isTrue(d1[1].nearEquals(d2[1], 0.00001)); | |
Assert.isTrue(d1[2].nearEquals(d2[2], 0.00001)); | |
} | |
@Test | |
public function testTransform():Void | |
{ | |
trace("testTransform"); | |
m1 = new Matrix3D(); | |
m1.prependTranslation(100, 200, 300); | |
m1.prependRotation(30, new Vector3D(1, 0, 0)); | |
m1.prependRotation(45, new Vector3D(0, 1, 0)); | |
m1.prependRotation(60, new Vector3D(0, 0, 1)); | |
m1.prependScale(3, 4, 5); | |
m1.rawData[3] = 1; | |
m1.rawData[7] = 2; | |
m1.rawData[11] = 3; | |
var v:Vector3D = new Vector3D(1000, -3000, 2000); | |
trace(m1.transformVector(v)); | |
Assert.isTrue(m1.transformVector(v).nearEquals(new Vector3D(15580.1962890625, -2077.12158203125, -2559.75732421875), 0.001)); // very big epsilon :( | |
} | |
@Test | |
public function testScale():Void | |
{ | |
trace("testScale"); | |
m1 = new Matrix3D(); | |
m1.appendScale( -1, 2, 3); | |
var s = m1.decompose()[2]; | |
Assert.isTrue(s.equals(new Vector3D(1, 2, -3))); | |
m1 = new Matrix3D(); | |
m1.appendScale( -1, -2, 3); | |
s = m1.decompose()[2]; | |
Assert.isTrue(s.equals(new Vector3D(1, 2, 3))); | |
m1 = new Matrix3D(); | |
m1.appendScale( -1, 2, -3); | |
s = m1.decompose()[2]; | |
Assert.isTrue(s.equals(new Vector3D(1, 2, 3))); | |
m1 = new Matrix3D(); | |
m1.appendScale( -1, -2, -3); | |
s = m1.decompose()[2]; | |
Assert.isTrue(s.equals(new Vector3D(1, 2, -3))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment