/** * Sets this matrix to the rotation indicated by the given angle and axis of rotation. Note: This method creates an * object, so use fromAngleNormalAxis when possible, particularly if your axis is already normalized. * * @param angle * the angle to rotate (in radians). * @param axis * the axis of rotation. * @return this matrix for chaining * @throws NullPointerException * if axis is null. */ public Matrix3 fromAngleAxis(final double angle, final ReadOnlyVector3 axis) { final Vector3 normAxis = Vector3.fetchTempInstance(); axis.normalize(normAxis); fromAngleNormalAxis(angle, normAxis); Vector3.releaseTempInstance(normAxis); return this; }
/** * Sets this matrix to the rotation indicated by the given angle and axis of rotation. Note: This method creates an * object, so use fromAngleNormalAxis when possible, particularly if your axis is already normalized. * * @param angle * the angle to rotate (in radians). * @param axis * the axis of rotation. * @return this matrix for chaining * @throws NullPointerException * if axis is null. */ public Matrix3 fromAngleAxis(final double angle, final ReadOnlyVector3 axis) { final Vector3 normAxis = Vector3.fetchTempInstance(); axis.normalize(normAxis); fromAngleNormalAxis(angle, normAxis); Vector3.releaseTempInstance(normAxis); return this; }
public MovePlanarWidget withDefaultHandle(final double radius, final double height, final ReadOnlyColorRGBA color) { final Cylinder handle = new Cylinder("handle", 2, 16, radius, height, true); handle.setDefaultColor(color); switch (_plane) { case XZ: handle.setRotation(new Matrix3().fromAngleNormalAxis(MathUtils.HALF_PI, Vector3.UNIT_X)); break; case YZ: handle.setRotation(new Matrix3().fromAngleNormalAxis(MathUtils.HALF_PI, Vector3.UNIT_Y)); break; default: // do nothing break; } handle.updateModelBound(); withHandle(handle); return this; }
private void applyDx(final double dx, final Camera camera) { _workerMatrix.fromAngleNormalAxis(_mouseRotateSpeed * dx, _upAxis); _workerMatrix.applyPost(camera.getLeft(), _workerStoreA); camera.setLeft(_workerStoreA); _workerMatrix.applyPost(camera.getDirection(), _workerStoreA); camera.setDirection(_workerStoreA); _workerMatrix.applyPost(camera.getUp(), _workerStoreA); camera.setUp(_workerStoreA); }
private void applyDx(final double dx, final Camera camera) { _workerMatrix.fromAngleNormalAxis(_mouseRotateSpeed * dx, _upAxis); _workerMatrix.applyPost(camera.getLeft(), _workerStoreA); camera.setLeft(_workerStoreA); _workerMatrix.applyPost(camera.getDirection(), _workerStoreA); camera.setDirection(_workerStoreA); _workerMatrix.applyPost(camera.getUp(), _workerStoreA); camera.setUp(_workerStoreA); }
setLayoutData(BorderLayoutData.EAST); setLayout(new RowLayout(false)); _titleLabel.setRotation(new Matrix3().fromAngleNormalAxis(-MathUtils.HALF_PI, Vector3.UNIT_Z)); break; case RIGHT: remove(_titleLabel); add(_titleLabel); _titleLabel.setRotation(new Matrix3().fromAngleNormalAxis(MathUtils.HALF_PI, Vector3.UNIT_Z)); break; case TOP:
private void applyDY(final double dy, final Camera camera) { // apply dy angle change to direction vector _workerMatrix.fromAngleNormalAxis(_mouseRotateSpeed * dy, camera.getLeft()); _workerMatrix.applyPost(camera.getDirection(), _workerStoreA); camera.setDirection(_workerStoreA); // do we want to constrain our vertical angle? if (isClampVerticalAngle()) { // check if we went out of bounds and back up final double angleV = MathUtils.HALF_PI - _workerStoreA.smallestAngleBetween(_upAxis); if (angleV > getMaxVerticalAngle() || angleV < getMinVerticalAngle()) { // clamp the angle to our range final double newAngle = MathUtils.clamp(angleV, getMinVerticalAngle(), getMaxVerticalAngle()); // take the difference in angles and back up the direction vector _workerMatrix.fromAngleNormalAxis(-(newAngle - angleV), camera.getLeft()); _workerMatrix.applyPost(camera.getDirection(), _workerStoreA); camera.setDirection(_workerStoreA); // figure out new up vector by crossing direction and left. camera.getDirection().cross(camera.getLeft(), _workerStoreA); camera.setUp(_workerStoreA); return; } } // just apply to up vector _workerMatrix.applyPost(camera.getUp(), _workerStoreA); camera.setUp(_workerStoreA); }
private void applyDY(final double dy, final Camera camera) { // apply dy angle change to direction vector _workerMatrix.fromAngleNormalAxis(_mouseRotateSpeed * dy, camera.getLeft()); _workerMatrix.applyPost(camera.getDirection(), _workerStoreA); camera.setDirection(_workerStoreA); // do we want to constrain our vertical angle? if (isClampVerticalAngle()) { // check if we went out of bounds and back up final double angleV = MathUtils.HALF_PI - _workerStoreA.smallestAngleBetween(_upAxis); if (angleV > getMaxVerticalAngle() || angleV < getMinVerticalAngle()) { // clamp the angle to our range final double newAngle = MathUtils.clamp(angleV, getMinVerticalAngle(), getMaxVerticalAngle()); // take the difference in angles and back up the direction vector _workerMatrix.fromAngleNormalAxis(-(newAngle - angleV), camera.getLeft()); _workerMatrix.applyPost(camera.getDirection(), _workerStoreA); camera.setDirection(_workerStoreA); // figure out new up vector by crossing direction and left. camera.getDirection().cross(camera.getLeft(), _workerStoreA); camera.setUp(_workerStoreA); return; } } // just apply to up vector _workerMatrix.applyPost(camera.getUp(), _workerStoreA); camera.setUp(_workerStoreA); }