Beispiel #1
0
  // Fatory Methods
  public static Matrix3 rotation(Vector3 axis, final float angle) {
    if (angle == 0) return Identity;
    axis = axis.unit();
    if (!axis.isFinite()) throw new RuntimeException();

    final float c = GMath.cos(angle), s = GMath.sin(angle);
    return axis.mul(1 - c).mul(axis).add(Identity, c).add(axis.mul(s).tilda());
  }
Beispiel #2
0
 public static Quaternion makeRotation(Quaternion result, float theta, Vector axis) {
   float halfTheta = theta / 2;
   float sinHalfTheta = GMath.sin(halfTheta);
   result.w = GMath.cos(halfTheta);
   result.x = axis.getX() * sinHalfTheta;
   result.y = axis.getY() * sinHalfTheta;
   result.z = axis.getZ() * sinHalfTheta;
   return result;
 }