Search in sources :

Example 91 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class Matrix4Test method testSetToTranslationFromVector3.

@Test
public void testSetToTranslationFromVector3() throws Exception {
    final double[] expected = new double[] { 1d, 0d, 0d, 0d, 0d, 1d, 0d, 0d, 0d, 0d, 1d, 0d, 1d, 2d, 3d, 1d };
    final Matrix4 m = new Matrix4();
    m.zero();
    final Matrix4 out = m.setToTranslation(new Vector3(1, 2, 3));
    assertNotNull(out);
    assertTrue(out == m);
    final double[] result = m.getDoubleValues();
    assertNotNull(result);
    for (int i = 0; i < expected.length; ++i) {
        assertEquals(expected[i], result[i], 1e-14);
    }
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 92 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class Matrix4Test method testTranslateWithVector3.

@Test
public void testTranslateWithVector3() throws Exception {
    final double[] expected = new double[] { // Col 0
    1d, // Col 0
    0d, // Col 0
    0d, // Col 0
    0d, // Col 1
    0d, // Col 1
    1d, // Col 1
    0d, // Col 1
    0d, // Col 2
    0d, // Col 2
    0d, // Col 2
    1d, // Col 2
    0d, // Col 3
    1d, // Col 3
    2d, // Col 3
    3d, // Col 3
    1d };
    final Matrix4 m = new Matrix4();
    m.identity();
    final Matrix4 out = m.translate(new Vector3(1, 2, 3));
    assertNotNull(out);
    assertTrue(out == m);
    final double[] result = m.getDoubleValues();
    assertNotNull(result);
    for (int i = 0; i < expected.length; ++i) {
        assertEquals(expected[i], result[i], 1e-14);
    }
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 93 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class Matrix4Test method testGetScalingInVector3.

@Test
public void testGetScalingInVector3() throws Exception {
    final double[] from = new double[] { 1d, 0d, 0d, 0d, 0d, 2d, 0d, 0d, 0d, 0d, 3d, 0d, 0d, 0d, 0d, 1d };
    final Vector3 expected = new Vector3(1, 2, 3);
    final Vector3 setIn = new Vector3(0, 0, 0);
    final Matrix4 m = new Matrix4(from);
    final Vector3 out = m.getScaling(setIn);
    assertNotNull(out);
    assertTrue(out == setIn);
    assertTrue(expected.equals(out, 1e-14));
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 94 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class Matrix4Test method testSetAllFromPositionScaleRotation.

@Test
public void testSetAllFromPositionScaleRotation() throws Exception {
    final double[] expected = new double[] { 0.6603582554517136, 1.4039252336448595, -0.26724299065420565, 0d, -0.55803738317757, 1.3932710280373835, 0.4511214953271028, 0d, 0.5027570093457944, -0.2977570093457944, 0.8515732087227414, 0d, 2d, 3d, 4d, 1d };
    final Quaternion rotation = new Quaternion(0.8958236433584459, -0.16744367165578425, -0.2148860452915898, -0.3516317104771469);
    final Vector3 position = new Vector3(2d, 3d, 4d);
    final Vector3 scale = new Vector3(1d, 2d, 1d);
    final Matrix4 m = new Matrix4();
    final Matrix4 out = m.setAll(position, scale, rotation);
    assertNotNull(out);
    assertSame(out, m);
    final double[] result = out.getDoubleValues();
    assertNotNull(result);
    for (int i = 0; i < expected.length; ++i) {
        assertEquals("Result: " + Arrays.toString(result), expected[i], result[i], 1e-14);
    }
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 95 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class QuaternionTest method testGetXAxis.

@Test
public void testGetXAxis() throws Exception {
    final Quaternion q = new Quaternion();
    q.fromAngleAxis(Axis.X, 10);
    q.multiply((new Quaternion()).fromAngleAxis(Axis.Y, 30));
    q.multiply((new Quaternion()).fromAngleAxis(Axis.Z, 40));
    final Vector3 v = q.getXAxis();
    assertNotNull(v);
    assertEquals(0.6634139481689384, v.x, 1e-14);
    assertEquals(0.6995333323392336, v.y, 1e-14);
    assertEquals(-0.2655843563187949, v.z, 1e-14);
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Aggregations

Vector3 (org.rajawali3d.math.vector.Vector3)166 SmallTest (android.test.suitebuilder.annotation.SmallTest)106 Test (org.junit.Test)106 Material (org.rajawali3d.materials.Material)9 SkeletonJoint (org.rajawali3d.animation.mesh.SkeletalAnimationFrame.SkeletonJoint)6 Matrix4 (org.rajawali3d.math.Matrix4)6 Object3D (org.rajawali3d.Object3D)5 BoundingBox (org.rajawali3d.bounds.BoundingBox)5 DiffuseMethod (org.rajawali3d.materials.methods.DiffuseMethod)4 Quaternion (org.rajawali3d.math.Quaternion)4 ArrayList (java.util.ArrayList)3 DirectionalLight (org.rajawali3d.lights.DirectionalLight)3 ParsingException (org.rajawali3d.loader.ParsingException)3 FileNotFoundException (java.io.FileNotFoundException)2 FloatBuffer (java.nio.FloatBuffer)2 Stack (java.util.Stack)2 BoneVertex (org.rajawali3d.animation.mesh.SkeletalAnimationChildObject3D.BoneVertex)2 BoneWeight (org.rajawali3d.animation.mesh.SkeletalAnimationChildObject3D.BoneWeight)2 BoundingSphere (org.rajawali3d.bounds.BoundingSphere)2 IBoundingVolume (org.rajawali3d.bounds.IBoundingVolume)2