8    *
this = FromRPY(rpy.x, rpy.y, rpy.z);
 
 
   20    w = cy * cp * cr + sy * sp * sr;
 
   21    v.x = cy * cp * sr - sy * sp * cr;
 
   22    v.y = cy * sp * cr + sy * cp * sr;
 
   23    v.z = sy * cp * cr - cy * sp * sr;
 
 
   29    f32 len = 
squaredNorm() > std::numeric_limits<f32>::epsilon() ? norm() : 0.0f;
 
 
   41    f32 t0 = std::max(0.0f, (from.
dot(to) + 1) * 2.0f);
 
   44    if (t0 <= std::numeric_limits<f32>::epsilon()) {
 
   47        const f32 inv = 1.0f / t0;
 
   49        v = from.cross(to) * inv;
 
 
   57    Quatf res = *
this * vec;
 
   60    ret.v.x = (res.v.y * conj.v.z + (res.v.x * conj.w + res.w * conj.v.x)) - res.v.z * conj.v.y;
 
   61    ret.v.y = (res.v.z * conj.v.x + (res.v.y * conj.w + res.w * conj.v.y)) - res.v.x * conj.v.z;
 
   62    ret.v.z = (res.v.x * conj.v.y + (res.v.z * conj.w + res.w * conj.v.z)) - res.v.y * conj.v.x;
 
 
   71    Quatf res = conj * vec;
 
   74    ret.v.x = (res.v.y * v.z + (res.v.x * w + res.w * v.x)) - res.v.z * v.y;
 
   75    ret.v.y = (res.v.z * v.x + (res.v.y * w + res.w * v.y)) - res.v.x * v.z;
 
   76    ret.v.z = (res.v.x * v.y + (res.v.z * w + res.w * v.z)) - res.v.y * v.x;
 
 
   85    f32 dot_ = std::max(-1.0f, std::min(1.0f, 
dot(q1)));
 
   86    bool bDot = dot_ < 0.0f;
 
   87    dot_ = Mathf::abs(dot_);
 
   89    f32 acos = Mathf::acos(dot_);
 
   93    if (Mathf::abs(
sin) < 0.00001f) {
 
   96        f32 invSin = 1.0f / 
sin;
 
  106    return Quatf(s * w + t * q1.w, s * v + t * q1.v);
 
 
  112    const f32 half_angle = angle * 0.5f;
 
 
  121    f32 _w = -(v.
dot(vec));
 
  122    f32 _x = (w * vec.x + v.y * vec.z) - v.z * vec.y;
 
  123    f32 _y = (w * vec.y + v.z * vec.x) - v.x * vec.z;
 
  124    f32 _z = (w * vec.z + v.x * vec.y) - v.y * vec.x;
 
  126    return Quatf(_w, _x, _y, _z);
 
  129Quatf Quatf::multSwap(
const Quatf &q)
 const {
 
  130    f32 _w = ((w * q.w - v.x * q.v.x) - v.y * q.v.y) - v.z * q.v.z;
 
  131    f32 _x = (v.y * q.v.z + (v.x * q.w + w * q.v.x)) - v.z * q.v.y;
 
  132    f32 _y = (v.z * q.v.x + (v.y * q.w + w * q.v.y)) - v.x * q.v.z;
 
  133    f32 _z = (v.x * q.v.y + (v.z * q.w + w * q.v.z)) - v.y * q.v.x;
 
  135    return Quatf(_w, _x, _y, _z);
 
  138void Quatf::read(Stream &stream) {
 
  140    w = stream.read_f32();
 
  150Quatf Quatf::FromRPY(f32 r, f32 p, f32 y) {
 
 
A quaternion, used to represent 3D rotation.
 
void normalise()
Scales the quaternion to a unit length.
 
Vector3f rotateVector(const Vector3f &vec) const
Rotates a vector based on the quat.
 
f32 squaredNorm() const
Computes .
 
Quatf slerpTo(const Quatf &q2, f32 t) const
Performs spherical linear interpolation.
 
void setAxisRotation(f32 angle, const Vector3f &axis)
Set the quat given angle and axis.
 
f32 dot(const Quatf &q) const
Computes  .
 
Vector3f rotateVectorInv(const Vector3f &vec) const
Rotates a vector on the inverse quat.
 
void setRPY(const Vector3f &rpy)
Sets roll, pitch, and yaw.
 
Quatf conjugate() const
Computes .
 
void makeVectorRotation(const Vector3f &from, const Vector3f &to)
Captures rotation between two vectors.
 
f32 dot(const Vector3f &rhs) const
The dot product between two vectors.
 
void read(Stream &stream)
Initializes a Vector3f by reading 12 bytes from the stream.