@Test public void testOrthonormal() { final Matrix3 mat3 = new Matrix3(); assertTrue(mat3.isOrthonormal()); // just rotation mat3.applyRotationX(MathUtils.QUARTER_PI); assertTrue(mat3.isOrthonormal()); // non-uniform scale mat3.setIdentity(); mat3.scaleLocal(new Vector3(1, 2, 3)); assertFalse(mat3.isOrthonormal()); // non-uniform scale + rotation mat3.setIdentity(); mat3.scaleLocal(new Vector3(1, 2, 3)); mat3.applyRotationX(MathUtils.QUARTER_PI); assertFalse(mat3.isOrthonormal()); }
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); if (current.getButtonsReleasedSince(previous).contains(_dragButton)) { _rotateStore.setIdentity(); if (_interactMatrix != InteractMatrix.Local) { setRingRotations(Matrix3.IDENTITY); } } // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag if (_lastDragSpatial instanceof InteractRing) { _lastRing = (InteractRing) _lastDragSpatial; final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final ReadOnlyQuaternion rot = getNewAxisRotation(_lastRing, oldMouse, current, camera, manager); final Transform transform = manager.getSpatialState().getTransform(); rot.toRotationMatrix(_calcMat3).multiply(transform.getMatrix(), _calcMat3); transform.setRotation(_calcMat3); // apply our filters, if any, now that we've made updates. applyFilters(manager); } }
worker.setIdentity(); worker.setIdentity().applyRotationX(MathUtils.QUARTER_PI).applyPost(expected, expected); worker.setIdentity().applyRotation(MathUtils.QUARTER_PI, 1, 0, 0).applyPost(rotated, rotated); assertTrue(rotated.distance(expected) <= MathUtils.EPSILON); worker.setIdentity().applyRotationY(MathUtils.QUARTER_PI).applyPost(expected, expected); worker.setIdentity().applyRotation(MathUtils.QUARTER_PI, 0, 1, 0).applyPost(rotated, rotated); assertTrue(rotated.distance(expected) <= MathUtils.EPSILON); worker.setIdentity().applyRotationZ(MathUtils.QUARTER_PI).applyPost(expected, expected); worker.setIdentity().applyRotation(MathUtils.QUARTER_PI, 0, 0, 1).applyPost(rotated, rotated); assertTrue(rotated.distance(expected) <= MathUtils.EPSILON);
assertTrue(Matrix3.isValid(mat3)); for (int i = 0; i < 9; i++) { mat3.setIdentity(); mat3.setValue(i / 3, i % 3, Double.NaN); assertFalse(Matrix3.isValid(mat3)); mat3.setIdentity(); mat3.setValue(i / 3, i % 3, Double.POSITIVE_INFINITY); assertFalse(Matrix3.isValid(mat3)); mat3.setIdentity(); assertTrue(Matrix3.isValid(mat3));
mat3A.setIdentity(); mat3A.fromFloatBuffer(fb, false); assertTrue(0 == mat3A.getM00()); db.flip(); mat3A.setIdentity(); mat3A.fromDoubleBuffer(db); assertTrue(0 == mat3A.getM00()); mat3A.setIdentity(); mat3A.fromDoubleBuffer(db, false); assertTrue(0 == mat3A.getM00());
_absUpVector.zero(); _abUpMinUp.zero(); _rotMatrix.setIdentity(); initializeParticles(_numParticles);
_absUpVector.zero(); _abUpMinUp.zero(); _rotMatrix.setIdentity(); initializeParticles(_numParticles);
@Test public void testFromArray() { final double[] values = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; final Matrix3 mat3A = new Matrix3(); // row major mat3A.fromArray(values); assertTrue(0 == mat3A.getM00()); assertTrue(1 == mat3A.getM01()); assertTrue(2 == mat3A.getM02()); assertTrue(3 == mat3A.getM10()); assertTrue(4 == mat3A.getM11()); assertTrue(5 == mat3A.getM12()); assertTrue(6 == mat3A.getM20()); assertTrue(7 == mat3A.getM21()); assertTrue(8 == mat3A.getM22()); // column major mat3A.setIdentity(); mat3A.fromArray(values, false); assertTrue(0 == mat3A.getM00()); assertTrue(3 == mat3A.getM01()); assertTrue(6 == mat3A.getM02()); assertTrue(1 == mat3A.getM10()); assertTrue(4 == mat3A.getM11()); assertTrue(7 == mat3A.getM12()); assertTrue(2 == mat3A.getM20()); assertTrue(5 == mat3A.getM21()); assertTrue(8 == mat3A.getM22()); }
assertTrue(2.2 == mat3C.getM22()); mat3C.setIdentity(); assertTrue(mat3C.isIdentity()); mat3C.setIdentity(); mat3C.set(0.0, 0.1, 0.2, 2.0, 2.1, 2.2, 4.0, 4.1, 4.2); for (int x = 0; x < 3; x++) {