Sunday, 26 May 2013

How to smoothly rotate a vector in a direction?

I'm looking for an easy way to achieve the following:
Object A, B
{
    Vector2D position;
    Vector2D orientation;
}

update(elapsed)
{
    //rotate A's orientation in B's direction by x * elapsed degrees
    //until A's orientation equals the direction from A to B
}
I am trying to align object A with an object B. Object A should rotate in B's direction by certain degrees/sec, e.g. max 45/sec.
I calculate the direction from A to B with normalize(B.position - A.position), but I don't know how to rotate A's orientation vector stepwise in B's direction.

No comments:

Post a Comment