Пример #1
0
void Quaternion::from_axis_angle(Vector3f v) {
    float theta = v.length();
    if(theta < 1.0e-12f) {
        q1 = 1.0f;
        q2=q3=q4=0.0f;
        return;
    }
    v /= theta;
    from_axis_angle(v,theta);
}
Пример #2
0
 /**
  * Rotation quaternion from vector
  *
  * The axis of rotation is given by vector direction and
  * the angle is given by the norm.
  *
  * @param vec rotation vector
  * @return quaternion representing the rotation
  */
 void from_axis_angle(Vector<Type, 3> vec) {
     Quaternion &q = *this;
     Type theta = vec.norm();
     if(theta < (Type)1e-10) {
         q(0) = (Type)1.0;
         q(1)=q(2)=q(3)=0;
         return;
     }
     vec /= theta;
     from_axis_angle(vec,theta);
 }