public void Update(GameTime gameTime, GraphicsDevice graphics)
        {
            steering = Steering.None();

            //atualizar posição e orientação
            movementInfo.position    += movementInfo.velocity * gameTime.ElapsedGameTime.Milliseconds;
            movementInfo.orientation += movementInfo.rotation * gameTime.ElapsedGameTime.Milliseconds;

            //aplicar atrito
            movementInfo.velocity *= 0.95f;
            movementInfo.rotation *= 0.95f;

            //calcular novo movimento
            steering = velocity.Update(movementInfo, target.getMovementInfo());

            movementInfo.velocity += steering.linear;
            movementInfo.rotation += steering.angular;

            //garantir velocidade máxima
            if (movementInfo.velocity.Length() > maxSpeed)
            {
                movementInfo.velocity.Normalize();
                movementInfo.velocity *= maxSpeed;
            }

            base.Update(graphics);
        }
        protected override Steering getSteering()
        {
            Steering steering = new Steering();

            //não mexer se o alvo não se mexe
            if (target.velocity.Length() == 0)
            {
                return(Steering.None());
            }

            //acelerar e tentar obter a velicidade desejada
            steering.linear  = target.velocity - origin.velocity;
            steering.linear /= timeToTarget;

            //não acelerar demasiado
            if (steering.linear.Length() > maxAcceleration)
            {
                steering.linear.Normalize();
                steering.linear *= maxAcceleration;
            }

            steering.angular = 0;

            return(steering);
        }
        protected override Steering getSteering()
        {
            Steering steering = new Steering();

            //calcular distancia da rotacao
            float rotation = origin.orientation - target.orientation;

            //normalizar rotação entre -PI e PI
            rotation = Utils.normAngle(rotation);
            //calcular distancia (angulo) absoluta
            float rotationSize = Math.Abs(rotation);

            float targetRotation = 0;

            //já chegamos?
            if (rotationSize < targetRadius)
            {
                return(Steering.None());
            }

            //estamos muito longe?
            if (rotationSize > slowRadius)
            {
                targetRotation = maxRotation;
            }
            else
            {
                targetRotation = maxRotation * rotationSize / slowRadius;
            }

            //rotação de destino combina velocidade com direção
            targetRotation *= Utils.signal(rotation);

            //aceleração necessária para obter rotação desejada
            steering.angular  = targetRotation - rotation;
            steering.angular /= timeToTarget;

            //mas não fazer a rotação demasiado rápida
            float angularAcceleration = Math.Abs(steering.angular);

            if (angularAcceleration > maxAngAccel)
            {
                steering.angular /= angularAcceleration;
                steering.angular *= maxAngAccel;
            }

            steering.linear = Vector3.Zero;
            return(steering);
        }
        public void Update(GameTime gameTime, GraphicsDevice graphics)
        {

            //atualizar posição e orientação
            movementInfo.position += movementInfo.velocity * gameTime.ElapsedGameTime.Milliseconds;
            movementInfo.orientation += movementInfo.rotation * gameTime.ElapsedGameTime.Milliseconds;

            //aplicar atrito
            movementInfo.velocity *= 0.95f;
            movementInfo.rotation *= 0.95f;

            //calcular novo movimento
            steering = Steering.None();

            if (Keyboard.GetState().IsKeyDown(Keys.W))
            {
                //Frente
                steering.linear = Vector3.Normalize(Utils.orientationToVector(movementInfo.orientation));
            }
            if (Keyboard.GetState().IsKeyDown(Keys.S))
            {
                //Trás
                steering.linear = -Vector3.Normalize(Utils.orientationToVector(movementInfo.orientation));
            }
            if (Keyboard.GetState().IsKeyDown(Keys.A))
            {
                //Virar à esquerda
                steering.angular = -0.0001f;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.D))
            {
                //Virar à direita
                steering.angular = 0.0001f;
            }

            movementInfo.velocity += steering.linear;
            movementInfo.rotation += steering.angular;

            //garantir velocidade máxima
            if (movementInfo.velocity.Length() > maxSpeed)
            {
                movementInfo.velocity.Normalize();
                movementInfo.velocity *= maxSpeed;
            }

            base.Update(graphics);
            
        }