Search in sources :

Example 6 with Vector3

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

the class Vector3Test method testMultiplyAndCreateFromTwoVector3.

@Test
public void testMultiplyAndCreateFromTwoVector3() throws Exception {
    final Vector3 v1 = new Vector3(1d, 2d, 3d);
    final Vector3 v2 = new Vector3(2d, 3d, 4d);
    final Vector3 v = Vector3.multiplyAndCreate(v1, v2);
    assertNotNull(v);
    assertEquals(2d, v.x, 0);
    assertEquals(6d, v.y, 0);
    assertEquals(12d, v.z, 0);
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 7 with Vector3

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

the class Vector3Test method testRotateBy.

@Test
public void testRotateBy() throws Exception {
    final Quaternion q = new Quaternion();
    final Vector3 v = new Vector3(Vector3.X);
    v.multiply(2.0);
    final Vector3 out = q.multiply(v);
    assertNotNull(out);
    assertTrue(out != v);
    assertEquals(Double.doubleToRawLongBits(2d), Double.doubleToRawLongBits(out.x));
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out.y));
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out.z));
    q.fromAngleAxis(Axis.Z, 45.0);
    final Vector3 out1 = q.multiply(v);
    assertNotNull(out1);
    assertTrue(out1 != v);
    assertEquals(1.4142135623730951, out1.x, 1e-14);
    assertEquals(1.4142135623730951, out1.y, 1e-14);
    assertEquals(Double.doubleToRawLongBits(0d), Double.doubleToRawLongBits(out1.z));
    q.fromAngleAxis(1d, 0d, 1d, 45d);
    q.normalize();
    final Vector3 out2 = q.multiply(v);
    assertNotNull(out2);
    assertTrue(out2 != v);
    assertEquals(1.7071067811865477, out2.x, 1e-14);
    assertEquals(0.9999999999999998, out2.y, 1e-14);
    assertEquals(0.29289321881345237, out2.z, 1e-14);
}
Also used : Quaternion(org.rajawali3d.math.Quaternion) Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 8 with Vector3

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

the class Vector3Test method testDistanceTo2FromVector3.

@Test
public void testDistanceTo2FromVector3() throws Exception {
    final Vector3 v1 = new Vector3(0d, 1d, 2d);
    final Vector3 v2 = new Vector3(3d, 5d, 7d);
    final double distance1 = v1.distanceTo2(v2);
    final double distance2 = v2.distanceTo2(v1);
    assertEquals(50d, distance1, 0);
    assertEquals(50d, distance2, 0);
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 9 with Vector3

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

the class Vector3Test method testSubtractDoublesXyz.

@Test
public void testSubtractDoublesXyz() throws Exception {
    final Vector3 v = new Vector3(1.1d, 2.2d, 3.3d);
    final Vector3 out = v.subtract(0.1d, 0.2d, 0.3d);
    assertNotNull(out);
    assertTrue(out == v);
    assertEquals(1d, v.x, 0);
    assertEquals(2d, v.y, 0);
    assertEquals(3d, v.z, 0);
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 10 with Vector3

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

the class Vector3Test method testCrossAndCreate.

@Test
public void testCrossAndCreate() throws Exception {
    final Vector3 u = new Vector3(1d, 2d, 3d);
    final Vector3 v = new Vector3(4d, 5d, 6d);
    final Vector3 t = Vector3.crossAndCreate(u, v);
    assertNotNull(t);
    assertEquals(-3d, t.x, 0);
    assertEquals(6d, t.y, 0);
    assertEquals(-3d, t.z, 0);
}
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