protected Matrix transformModelView(Matrix modelView, IDelegateView view) { if (disableHeadTransform) { return modelView; } Vec4 translation = RiftUtils.toVec4(eyePoses[eye].Position); double translationScale = getHeadTranslationScale(view); Quaternion rotation = RiftUtils.toQuaternion(eyePoses[eye].Orientation); Matrix translationM = Matrix.fromTranslation(translation.multiply3(-translationScale)); Matrix rotationM = Matrix.fromQuaternion(rotation.getInverse()); return rotationM.multiply(translationM.multiply(modelView)); }
/** * Linearly interpolates between two angles. * * @param amount the interpolant. * @param value1 the first <code>Angle</code>. * @param value2 the second <code>Angle</code>. * @return a new <code>Angle</code> between <code>value1</code> and <code>value2</code>. */ public static Angle mix(double amount, Angle value1, Angle value2) { if (value1 == null || value2 == null) { String message = Logging.getMessage("nullValue.AngleIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (amount < 0) return value1; else if (amount > 1) return value2; Quaternion quat = Quaternion.slerp( amount, Quaternion.fromAxisAngle(value1, Vec4.UNIT_X), Quaternion.fromAxisAngle(value2, Vec4.UNIT_X)); Angle angle = quat.getRotationX(); if (Double.isNaN(angle.degrees)) return null; return angle; }