/** * Sets the value of this axis-angle to the rotational component of the passed matrix. If the * specified matrix has no rotational component, the value of this AxisAngle4f is set to an angle * of 0 about an axis of (0,1,0). * * @param m1 the matrix4f */ public final void set(Matrix4f m1) { Matrix3f m3f = new Matrix3f(); m1.get(m3f); x = m3f.m21 - m3f.m12; y = m3f.m02 - m3f.m20; z = m3f.m10 - m3f.m01; double mag = x * x + y * y + z * z; if (mag > EPS) { mag = Math.sqrt(mag); double sin = 0.5 * mag; double cos = 0.5 * (m3f.m00 + m3f.m11 + m3f.m22 - 1.0); angle = (float) Math.atan2(sin, cos); double invMag = 1.0 / mag; x = (float) (x * invMag); y = (float) (y * invMag); z = (float) (z * invMag); } else { x = 0.0f; y = 1.0f; z = 0.0f; angle = 0.0f; } }