use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class Matrix4Test method testSetToRotationTwoVector3.
@Test
public void testSetToRotationTwoVector3() throws Exception {
final double[] expected = new double[] { 0d, -1d, 0d, 0d, 1d, 0d, 0d, 0d, 0d, 0d, 1d, 0d, 0d, 0d, 0d, 1d };
final Matrix4 m = new Matrix4();
final Vector3 v1 = new Vector3(1d, 0d, 0d);
final Vector3 v2 = new Vector3(0d, 1d, 0d);
final Matrix4 out = m.setToRotation(v1, v2);
assertNotNull(out);
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);
}
}
use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class Matrix4Test method testCreateScaleMatrixVector3.
@Test
public void testCreateScaleMatrixVector3() throws Exception {
final double[] expected = new double[] { 1d, 0d, 0d, 0d, 0d, 2d, 0d, 0d, 0d, 0d, 3d, 0d, 0d, 0d, 0d, 1d };
final Matrix4 out = Matrix4.createScaleMatrix(new Vector3(1d, 2d, 3d));
assertNotNull(out);
final double[] result = out.getDoubleValues();
assertNotNull(result);
for (int i = 0; i < expected.length; ++i) {
assertEquals(expected[i], result[i], 1e-14);
}
}
use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class Matrix4Test method testCreateTranslationMatrixVector3.
@Test
public void testCreateTranslationMatrixVector3() 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 out = Matrix4.createTranslationMatrix(new Vector3(1d, 2d, 3d));
assertNotNull(out);
final double[] result = out.getDoubleValues();
assertNotNull(result);
for (int i = 0; i < expected.length; ++i) {
assertEquals(expected[i], result[i], 1e-14);
}
}
use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class Matrix4Test method testGetTranslation.
@Test
public void testGetTranslation() throws Exception {
final double[] from = new double[] { // Col 0
1d, // Col 0
0d, // Col 0
0d, // Col 0
0d, // Col 1
0d, // Col 1
2d, // Col 1
0d, // Col 1
0d, // Col 2
0d, // Col 2
0d, // Col 2
3d, // Col 2
0d, // Col 3
1d, // Col 3
2d, // Col 3
3d, // Col 3
1d };
final Vector3 expected = new Vector3(1, 2, 3);
final Matrix4 m = new Matrix4(from);
final Vector3 out = m.getTranslation();
assertNotNull(out);
assertTrue(expected.equals(out, 1e-14));
}
use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.
the class ChaseCameraFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
mCameraOffset = new Vector3();
super.onCreate(savedInstanceState);
}
Aggregations