/** * Multiplies this quaternion by the inverse of quaternion q1 and places * the value into this quaternion. The value of the argument quaternion * is preserved (this = this * q^-1). * @param q1 the other quaternion */ public final void mulInverse(Quat4f q1) { Quat4f tempQuat = new Quat4f(q1); tempQuat.inverse(); this.mul(tempQuat); }
/** * Multiplies quaternion q1 by the inverse of quaternion q2 and places * the value into this quaternion. The value of both argument quaternions * is preservered (this = q1 * q2^-1). * @param q1 the first quaternion * @param q2 the second quaternion */ public final void mulInverse(Quat4f q1, Quat4f q2) { Quat4f tempQuat = new Quat4f(q2); tempQuat.inverse(); this.mul(q1, tempQuat); }
@Override public @Nonnull Pair<? extends IBakedModel, Matrix4f> handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType) { Pair<? extends IBakedModel, Matrix4f> perspective = parent.handlePerspective(cameraTransformType); double r = (EnderIO.proxy.getTickCount() % 360) + Minecraft.getMinecraft().getRenderPartialTicks(); TRSRTransformation transformOrig = new TRSRTransformation(perspective.getRight()); Quat4f leftRot = transformOrig.getLeftRot(); Quat4f yRotation = new Quat4f(); yRotation.set(new AxisAngle4d(0, 1, 0, Math.toRadians(r * speed))); leftRot.mul(yRotation); TRSRTransformation transformNew = new TRSRTransformation(transformOrig.getTranslation(), leftRot, transformOrig.getScale(), transformOrig.getRightRot()); return Pair.of(perspective.getLeft(), transformNew.getMatrix()); }
private static Multimap<Orientation, XYZRotation> calculateXyzRotations(Map<Matrix3f, Orientation> fromMatrix) { final Multimap<Orientation, XYZRotation> toXYZRotation = HashMultimap.create(); for (Rotation x : Rotation.values()) for (Rotation y : Rotation.values()) for (Rotation z : Rotation.values()) { final XYZRotation rotation = new XYZRotation(x, y, z); Quat4f q = new Quat4f(0, 0, 0, 1); Quat4f tmp = new Quat4f(); tmp.set(new AxisAngle4f(0, 0, 1, z.angle)); q.mul(tmp); tmp.set(new AxisAngle4f(0, 1, 0, y.angle)); q.mul(tmp); tmp.set(new AxisAngle4f(1, 0, 0, x.angle)); q.mul(tmp); Matrix3f m = new Matrix3f(); m.set(q); roundMatrixElements(m); final Orientation orientation = fromMatrix.get(m); Preconditions.checkNotNull(orientation, rotation); toXYZRotation.put(orientation, rotation); } return toXYZRotation; }