i have a Vector3 represents an Orientation in 3D , how to convert it to the corresponding Quaternion ? is there any quick way ?
EDIT : i want to add an angular velocity vector to the Orientation Quaternion of the body
|
i have a Vector3 represents an Orientation in 3D , how to convert it to the corresponding Quaternion ? is there any quick way ? EDIT : i want to add an angular velocity vector to the Orientation Quaternion of the body |
||||
|
|
|
If your
On the other hand, if you're not storing an euler angle, but just the direction (or forward vector) of the camera/object, then bear in mind that generally a single 3D vector is not enough to store a complete orientation in 3D space unless you restrict one of the axes of rotation. A typical case is where your camera/object can't roll or flip around and the Up vector is always pointing in the upper direction, e.g. FPS camera. If that's the case, then you should create a rotation matrix from your forward vector, and then use the following static method:
As for creating that rotation matrix, I think something like this should work (I hope so, I'm a little rusty with cross products):
I think this may cause problems though if you try to look directly up or down, or close to those orientations, so you may need to handle those cases separatedly. |
|||||||||||||
|