-
Notifications
You must be signed in to change notification settings - Fork 189
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
Semantics for AffineTransform composition is reversed #1195
Comments
For prior art, see https://gdal.org/api/raster_c_api.html#_CPPv424GDALComposeGeoTransformsPKdPKdPd. |
But I don't understand, why do you say it's right-to-left? It looks left-to-right to me ( |
Sorry I should have mentioned that the final assert here fails. |
FIX: #1195 e.g. for "conventional" https://gdal.org/api/raster_c_api.html#_CPPv424GDALComposeGeoTransformsPKdPKdPd ``` /// The resulting geotransform is the equivalent to padfGT1 and then padfGT2 being applied to a point. /// Parameters: /// padfGT1 -- the first geotransform, six values. /// padfGT2 -- the second geotransform, six values. /// padfGTOut -- the output geotransform, six values, may safely be the same array as padfGT1 or padfGT2. void GDALComposeGeoTransforms(const double *padfGeoTransform1, const double *padfGeoTransform2, double *padfGeoTransformOut) ``` Note: `padfGT1` **and then** `padfGT2`, previously we were effectively doing `padfGT2` **and then** `padfGT1`. I also simplified some of the examples to have more understandable input/output. I'm not good enough at mental matrix math to know what to expect from a rotated skew.
FIX: #1195 e.g. for "conventional" https://gdal.org/api/raster_c_api.html#_CPPv424GDALComposeGeoTransformsPKdPKdPd ``` /// The resulting geotransform is the equivalent to padfGT1 and then padfGT2 being applied to a point. /// Parameters: /// padfGT1 -- the first geotransform, six values. /// padfGT2 -- the second geotransform, six values. /// padfGTOut -- the output geotransform, six values, may safely be the same array as padfGT1 or padfGT2. void GDALComposeGeoTransforms(const double *padfGeoTransform1, const double *padfGeoTransform2, double *padfGeoTransformOut) ``` Note: `padfGT1` **and then** `padfGT2`, previously we were effectively doing `padfGT2` **and then** `padfGT1`. I also simplified some of the examples to have more understandable input/output. I'm not good enough at mental matrix math to know what to expect from a rotated skew.
Fixed in #1196 - please take a look. Thank you for catching this and providing a test! |
FIX: #1195 e.g. for "conventional" https://gdal.org/api/raster_c_api.html#_CPPv424GDALComposeGeoTransformsPKdPKdPd ``` /// The resulting geotransform is the equivalent to padfGT1 and then padfGT2 being applied to a point. /// Parameters: /// padfGT1 -- the first geotransform, six values. /// padfGT2 -- the second geotransform, six values. /// padfGTOut -- the output geotransform, six values, may safely be the same array as padfGT1 or padfGT2. void GDALComposeGeoTransforms(const double *padfGeoTransform1, const double *padfGeoTransform2, double *padfGeoTransformOut) ``` Note: `padfGT1` **and then** `padfGT2`, previously we were effectively doing `padfGT2` **and then** `padfGT1`. I also simplified some of the examples to have more understandable input/output. I'm not good enough at mental matrix math to know what to expect from a rotated skew.
Fantastic, thanks for the quick fix! 😃 |
When composing multiple AffineTransforms, one would expect that the composed transform is the equivalent of applying the individual transforms from left to right. Instead it is the same as applying right to left.
The solution would be to reverse the matrix multiplication of the compose() function. Alternatively this could be made clear in the docs as there may be people that depend on this right to left behaviour.
Sample code
The text was updated successfully, but these errors were encountered: