I've been messing around in OpenGL, and JBullet for the last few days. After a lot of tinkering I finally managed to fix quite a few bugs in JBullet, and make it usable for some demos. Issue I'm currently having is I can't manage to convert the translation into Degrees, so far I've had the best results with Quaternions, to Radians with the following code:
public Vector3f getRadians(Quat4f quat) {
Vector3f v = new Vector3f();
//float scale = (float) Math.abs(quat.x * quat.y * quat.z); //Apparently the scale of the angle, thought without I get a almost perfect result on the X-Axis
float angle = (float) Math.abs(Math.acos(quat.w)) * 2.0f;
v.x = angle * Math.round(quat.x);
v.y = angle * Math.round(quat.y);
v.z = angle * Math.round(quat.z);
return v;
}
It's worth noting that my only success would be on the X-Axis of the Quaternion, and that's with no translation on any other axis. Not to mention it's off by anywhere from 0-6 Degrees.
I'm really not sure this is what you want, but from glm::gtx::quaternion :
inline valType roll
(
detail::tquat<valType> const & q
)
{
return atan2(valType(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z);
}
template <typename valType>
inline valType pitch
(
detail::tquat<valType> const & q
)
{
return atan2(valType(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z);
}
template <typename valType>
inline valType yaw
(
detail::tquat<valType> const & q
)
{
return asin(valType(-2) * (q.x * q.z - q.w * q.y));
}
So, in a more readable form :
float roll = atan2(valType(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z);
float pitch = atan2(valType(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z);
float yaw = asin(valType(-2) * (q.x * q.z - q.w * q.y));
vec3 EulerAngles = vec3(pitch, yaw, roll);