get a vector from quaternion

termhn
Posts: 11
Joined: Wed Jun 29, 2011 3:49 pm

get a vector from quaternion

Post by termhn »

Hello all, I need to be able to get a btVector3 from a btQuaternion. I have no clue how to do this conversion? :?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: get a vector from quaternion

Post by dphil »

Did you check out the API? That would be the first place to look. If you want the rotation axis:

http://bulletphysics.com/Bullet/BulletF ... 98e73140c3

Code: Select all

btQuaternion quat = ...;
btVector3 rotAxis = quat.getAxis();
termhn
Posts: 11
Joined: Wed Jun 29, 2011 3:49 pm

Re: get a vector from quaternion

Post by termhn »

yep, looked all through the API. I tried the rotation axis, but it doesn't work :/ Also, is there a way to get the individual x,y,z,w values from a btQuaternion?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: get a vector from quaternion

Post by dphil »

Doesn't work? What do you mean? Is it (0,0,0)? In which case the quaternion probably wasn't defined right.
You can get the w component via quaternion->getW()
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: get a vector from quaternion

Post by Mako_energy02 »

One thing you really need to keep in mind when looking at the Bullet API doc's is that they don't show inherited members from base classes. So you really aren't seeing the full list of what the class can do if it inherits from anything. Be sure to look at any base classes as well to verify if the class has what you are looking for or not.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: get a vector from quaternion

Post by dphil »

Mako_energy02 wrote:One thing you really need to keep in mind when looking at the Bullet API doc's is that they don't show inherited members from base classes. So you really aren't seeing the full list of what the class can do if it inherits from anything. Be sure to look at any base classes as well to verify if the class has what you are looking for or not.
Good point, I occasionally forget that myself. Indeed, it seems btQuaternion inherits from btQuadWord, which has accessors for x/y/z/w, in x() and getX() formats (though for some reason getW(), specifically, is in btQuaternion and not btQuadWord...).