zRotate method

Map<String, Matrix4> zRotate(
  1. Vector3 point,
  2. double angle
)
  • Rotate camera around its direction axis passing by a given point by a given angle
  • point The point where the rotation axis is passing trough
  • angle Angle in radians
  • returns The computed transormation matix

Implementation

Map<String, Matrix4> zRotate(Vector3 point, double angle) {
    _rotationMatrix.makeRotationAxis(_rotationAxis, angle);
    _translationMatrix.makeTranslation(-point.x, -point.y, -point.z);

    _m4_1.makeTranslation(point.x, point.y, point.z);
    _m4_1.multiply(_rotationMatrix);
    _m4_1.multiply(_translationMatrix);

    _v3_1
        .setFromMatrixPosition(_gizmoMatrixState)
        .sub(point); //vector from rotation center to gizmos position
    _v3_2
        .setFrom(_v3_1)
        .applyAxisAngle(_rotationAxis, angle); //apply rotation
    _v3_2.sub(_v3_1);

    _m4_2.makeTranslation(_v3_2.x, _v3_2.y, _v3_2.z);

    setTransformationMatrices(_m4_1, _m4_2);
    return _transformation;
  }