4 ms·
Imagine you are creating a 3D flight or space simulator. You would need to use the quaternion system to avoid your camera/craft from experiencing gimbal lock.
by hi_hi 2y ago
Imagine you are creating a 3D flight or space simulator. You would need to use the quaternion system to avoid your camera/craft from experiencing gimbal lock.
It can have other uses for things like inverse kinematics too.
- fc417fc802 2y agoNever having done anything aviation simulation related I've never properly understood this. At least for a simple camera I've done that with something that resembled a spherical coordinate system (although maybe not following the usual conventions) and it didn't experience gimbal lock. Effectively the axes rotate with you. It's also very intuitive to work with the code, although probably not very efficient compared to other approaches (but hey it's a camera it's not like there's 10k of them). Once you have the camera orientation you can derive a corresponding rotation matrix to apply to the scene geometry. I guess what I'm trying to ask is if there's any reason other than efficiency not to do something like that when modeling craft and the like?
- cwillu 2y agoHow do you represent the viewports roll angle?
- fc417fc802 2y agoSuppose unit X is viewport direction and unit Y is viewport horizontal. Since the axes follow you with each rotation the viewport direction is always the X unit vector even after rotation. So the viewport roll angle is a rotation about X. Future user control inputs (ie a 4th rotation step) happen in this rotated space, and then you normalize the result so you only ever need 3 instead of 4 rotations. It's been several years since I did this so hopefully I didn't mess up the explanation. Again I realize it isn't computationally efficient but there's only the one camera and it let me have code that was minimal and easy to reason about. Presumably if I were simulating 10k airplanes or whatever this wouldn't be a good idea.