Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coordinate transformations #4014

Closed
RudolfWeeber opened this issue Nov 26, 2020 · 1 comment
Closed

Coordinate transformations #4014

RudolfWeeber opened this issue Nov 26, 2020 · 1 comment

Comments

@RudolfWeeber
Copy link
Contributor

RudolfWeeber commented Nov 26, 2020

In context with #3960, coordinate transforms are needed.
In the particular case, Cartesian -> cylindrical with basis vectors and origin not identical.

To my understanding, the most general solution is to split this into

  1. translation to align the origins
  2. basis transform to align the basis vectors
  3. convert Cartesian to cylindrical coordinates for matching basis vectors. I.e. theta=0 would refer to the x axis, theta=pi/2 to the y-axis and z =z.

  1. is probably not worth a function, since it is vector subtraction.

  2. The second part can be done most general (supporting also non-orthogonal coordinates)
    using a transformation matrix containing the new basis vectors (as columns, i guess)
    This only requires matrix vector product which is in the utils library.
    https://en.wikipedia.org/wiki/Change_of_basis

  3. theta using atan2 (the one that can deal with four quadrants, r=sqrt(x^2+y^2), z=z

The reverse would look like:
x = r cos(theta), y = r sin(theta), z=z

To reverse 2., the caller has to use the original basis transform with the inverse transformation matrix.
Matrix inversion can be taken from boost::qvm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant