void SteeringAgent::truncateVelocity(cocos2d::Vec2& velocity) const {

	if (velocity.length() > m_maxSpeed) {
		
		velocity.normalize();
		velocity *= m_maxSpeed;
	}
}
 inline void MovingEntity::setHeading(const cocos2d::Vec2& heading)
 {
     // TODO: try and catch exception.
     if(heading.getLengthSq() < kMathEpsilon) return ;
     
     _heading = heading;
     _heading.normalize();
     _side = _heading.getPerp();
 }
void SteeringAgent::truncateSteeringForce(cocos2d::Vec2& force) const {

	if (force.length() > m_maxForce) {

		force.normalize();
		force *= m_maxForce;
	}

	if (force.length() > m_velocity.length()) {
		force = getForward() * m_maxForce;
	}
}