0

Here's a problem that's been wrecking my brain for a while.

Given: I have two coordinate spaces: the global space G, and a local space A, and I know the position and rotation of A relative to G.

Question: How can I programmatically calculate the position and rotation of G relative to A?

On graph paper, I can calculate this by hand:

  • if A relative to G is (4, 1) 90deg, then G relative to A is (-1, -4) -90deg
  • if A relative to G is (5, 0) 0deg, then G relative to A is (-5, 0) 0deg

... but I'm having trouble transferring this calculation to software.

David M
  • 53
  • 6
  • https://en.wikipedia.org/wiki/Rotation_of_axes – Ripi2 Nov 24 '18 at 13:54
  • construct 4x4 homogenous matrix representing the transform from G to A and just invert it ....see [Understanding 4x4 homogenous transform matrices](https://stackoverflow.com/questions/28075743/how-do-i-compose-a-rotation-matrix-with-human-readable-angles-from-scratch/28084380?s=1|67.5068#28084380) – Spektre Nov 25 '18 at 09:05

1 Answers1

0

In matrix form,

y = R x + t

where R is the rotation matrix and t the translation of the origin.

The reverse way,

x = R' (y - t) = R' y + (- R' t)

where R' is the inverse of R, and also its transpose.