//------------------------------------------------------------------------------- // @ IvQuat::Rotate() //------------------------------------------------------------------------------- // Rotate vector by quaternion // Assumes quaternion is normalized! //------------------------------------------------------------------------------- IvVector3 IvQuat::Rotate( const IvVector3& vector ) const { ASSERT( IsUnit() ); float pMult = w*w - x*x - y*y - z*z; float vMult = 2.0f*(x*vector.x + y*vector.y + z*vector.z); float crossMult = 2.0f*w; return IvVector3( pMult*vector.x + vMult*x + crossMult*(y*vector.z - z*vector.y), pMult*vector.y + vMult*y + crossMult*(z*vector.x - x*vector.z), pMult*vector.z + vMult*z + crossMult*(x*vector.y - y*vector.x) ); } // End of IvQuat::Rotate()
Unit* Entity::ToUnit() { if (IsUnit()) return dynamic_cast<Unit*>(this); return nullptr; }
/** * @see IsUnit * @see Normalize */ bool IsNormal(T eps = T(0)) const { return IsUnit(eps); }