Lets say I have an object, and that object has a quaternion representing its orientation.
Currently, I can rotate on all 3 axes without gimbal lock, however, each rotation on any axis SHOULD rotate the other 2 axes of rotation.
What I mean by this is if I pitch an object towards the camera, but then yaw the object 90 degrees away, pitching the object will still rotate it relative to where it was before, not where it is now.
Here's a visual example of my problem:
I'm using quaternions and not euler rotations because these objects can rotate on all 3 axes, and I don't want to gimbal lock/reach singularity
I rotate my object's orientation quaternion like this:
orientation = Quaternion(Vector(0,1,0),angle) * orientation;
I then trigger a rebuilding of my object's vectors, and apply it to them (after transforming the object relative to 3D space origin point):
Quaternion Point = Quaternion(( orientation * (Vertex) ) * (orientation.inverse()));
vertices[x] = QVector3D(round(Point.v.x),round(Point.v.y),round(Point.v.z));
And when I multiply my quaternions by other quaternions, this is the multiplication operator's function:
Quaternion Quaternion::operator*(Quaternion& q) const
{
Quaternion r;
//"w" is the angle, "v" is the vector
r.w = w*q.w - glm::dot(v, q.v);
r.v = v*q.w + q.v*w + glm::cross(v,q.v);
//r.normalize();
return r;
}
I swear to god, I'm only posting because this topic is confusing me to no end. Solidifying this system will be make me unfathomably happy.