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

Fix rotation matrix and __mul__ op #25

Merged
merged 2 commits into from May 15, 2016
Merged

Fix rotation matrix and __mul__ op #25

merged 2 commits into from May 15, 2016

Conversation

sgillies
Copy link
Member

The dot product of a rotation matrix and vector was right, but separately these were wrong.

The dot product of a rotation matrix and vector was right, but
separately these were wrong.
@coveralls
Copy link

coveralls commented May 14, 2016

Coverage Status

Coverage remained the same at 98.052% when pulling 484ac5f on fix-matrix-mult-op into 0cd1cf2 on master.

@sgillies
Copy link
Member Author

This PR has the __mul__ bug fix found by @ToddSmall and also gets the right-handed sense of rotation right. Here's a 90 degree ccw rotation of a unit vector example using numpy:

>>> from affine import Affine
>>> import numpy as np
>>> am = np.array(Affine.rotation(90.0)).reshape(3,3)
>>> am
array([[ 0., -1.,  0.],
       [ 1.,  0.,  0.],
       [ 0.,  0.,  1.]])
>>> point = np.array([1.0, 0.0, 1.0])
>>> np.dot(am, point)
array([  0.,  1.,   1.])

/cc @perrygeo @ToddSmall @mwtoews

@ToddSmall ToddSmall mentioned this pull request May 14, 2016
@mwtoews
Copy link
Contributor

mwtoews commented May 15, 2016

Looks good. Here is one suggestion to consider for affine/__init__.py, line 229:

:param angle: Rotation angle in degrees, counter-clockwise about the pivot.

@sgillies sgillies mentioned this pull request May 15, 2016
@perrygeo
Copy link

@sgillies Looks great - it's nice to have the rotation direction defined explicitly.

Could we also add @ToddSmall's test for associativity? https://github.com/sgillies/affine/pull/24/files#diff-3ebc029e55f312af9ae346c6433cd770R364

@coveralls
Copy link

coveralls commented May 15, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 2dc816d on fix-matrix-mult-op into b4234ea on master.

@sgillies sgillies merged commit b896af9 into master May 15, 2016
@sgillies sgillies deleted the fix-matrix-mult-op branch May 15, 2016 19:44
@sgillies sgillies added this to the 2.0 milestone May 15, 2016
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

Successfully merging this pull request may close these issues.

None yet

4 participants