简体   繁体   中英

what's meaning of '1.0f' at glm::dvec for glm::angleAxis?

When calculate quaternion like below,

Could you somebody explain what's the meaning of 1.0f means..?

I thought it might be 90degree of x axis.

 glm::angleAxis(3.141592... / 2, glm::dvec3(1.0f, 0.0f, 0.0f)))

The glm::angleAxis method constructs a quaternion for a rotation around an axis. The parameters are:

  • The angle in radians
  • The axis around which the rotation should happen.

Your example does indeed construct a 90° rotation (=PI/2) around the x-axis ([1,0,0]). If you want 90° around z-axis, then you would have to change the axis to [0,0,1] and so on.

If you see how quaternion works they define orientation along or with respect to one axis. As with normal euler angle rotation you are using three angles along three axis to define rotation ( Please see not orientation) that might lead to rotation pattern such that two axes could end up parallel to each other and you lose one degree of freedom for rotation this is typically gimbal lock problem. So quaternions define orientation and for that they use only one reference vector. The function you are using is defining that vector along x axis. I hope this is clear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM