use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class Vector3Test method testConstructorDoublesXyz.
@Test
public void testConstructorDoublesXyz() throws Exception {
final Vector3 v = new Vector3(1d, 2d, 3d);
assertNotNull(v);
assertEquals(1d, v.x, 0);
assertEquals(2d, v.y, 0);
assertEquals(3d, v.z, 0);
}
use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class Vector3Test method testIsUnitWithMargin.
@Test
public void testIsUnitWithMargin() throws Exception {
assertTrue(Vector3.X.isUnit(0.1));
assertTrue(Vector3.Y.isUnit(0.1));
assertTrue(Vector3.Z.isUnit(0.1));
assertFalse((new Vector3(1d)).isUnit(0.1));
assertFalse((new Vector3(0d)).isUnit(0.1));
assertTrue((new Vector3(0.95d, 0d, 0d)).isUnit(0.316227766016838));
assertFalse((new Vector3(0.95d, 0d, 0d)).isUnit(0.05));
}
use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class Vector3Test method testProjectFromDoubleArrayMatrix.
@Test
public void testProjectFromDoubleArrayMatrix() throws Exception {
final double[] m = new double[] { 1d, 0d, 0d, 0d, 0d, 1d, 0d, 0d, 0d, 0d, 1d, 1d, 0d, 0d, 0d, 0d };
Vector3 v = new Vector3(2d, 3d, 4d);
final Vector3 out = v.project(m);
assertNotNull(out);
assertSame(out, v);
assertEquals(0.5, out.x, 1e-14);
assertEquals(0.75, out.y, 1e-14);
assertEquals(1d, out.z, 1e-14);
}
use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class Vector3Test method testCrossFromDoublesXyz.
@Test
public void testCrossFromDoublesXyz() throws Exception {
final Vector3 u = new Vector3(1d, 2d, 3d);
final Vector3 out = u.cross(4d, 5d, 6d);
assertNotNull(out);
assertTrue(out == u);
assertEquals(-3d, u.x, 0);
assertEquals(6d, u.y, 0);
assertEquals(-3d, u.z, 0);
}
use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class Vector3Test method testCrossFromVector3.
@Test
public void testCrossFromVector3() throws Exception {
final Vector3 u = new Vector3(1d, 2d, 3d);
final Vector3 v = new Vector3(4d, 5d, 6d);
final Vector3 out = u.cross(v);
assertNotNull(out);
assertTrue(out == u);
assertEquals(-3d, u.x, 0);
assertEquals(6d, u.y, 0);
assertEquals(-3d, u.z, 0);
}
Aggregations