// Get the roll euler angle in radians, which is the rotation around the z axis. Requires that this quaternion is normalized. // return the rotation around the z axis in radians (between -PI and +PI) func (self *Quaternion) GetRollRad() float32 { pole := self.GetGimbalPole() if pole == 0 { return utils.Atan2(2*(self.w*self.z+self.y*self.x), 1-2*(self.x*self.x+self.z*self.z)) } return float32(pole) * 2 * utils.Atan2(self.y, self.w) }
// Get the yaw euler angle in radians, which is the rotation around the y axis. Requires that this quaternion is normalized. // return the rotation around the y axis in radians (between -PI and +PI) func (self *Quaternion) GetYawRad() float32 { if self.GetGimbalPole() == 0 { return utils.Atan2(2*(self.y*self.w+self.x*self.z), 1-2*(self.y*self.y+self.x*self.x)) } return 0 }