I am trying to implement obstacle avoidance behavior from the paper steering behaviours for autonomous agents. What I am stuck at is how do i convert global coordinates (2d) to local coordinates for my character?
Basically Say I am at 1,0 and the enemy is 10,0. I would like to move the origin to 1,0 so I get 9,0 as the enemy coordinates.
What I ended up doing,
to translate to local,
[1 0 -tx] [x]
[0 1 -ty] x [y]
[0 0 1] [1]
then back to global using,
[1 0 tx] [x]
[0 1 ty] x [y]
[0 0 1] [1]
tx,ty is the local char coords and x,y is the enemy char coords.
Just subtract the points.
Relative = Position – moved axis point.
(10,0) – (1,0) = (9,0)
Displacement
Edit:
Using an Affine transformation to convert the entire x,y plane:
Just for numeric issues, lets choose another perspective point: (3,7)
Transformation matrix