-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
ENH: Create 2DTransfrom.py #12723
ENH: Create 2DTransfrom.py #12723
Conversation
arr = np.empty([2, 2]) | ||
|
||
arr[0][0] = math.cos(angle) | ||
arr[0][1] = -math.sin(angle) | ||
arr[1][0] = math.sin(angle) | ||
arr[1][1] = math.cos(angle) | ||
|
||
return arr #This returns a rotation matrix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is going to be worth including (anywhere) in scipy, it's probably worth makign it broadcasting:
c = np.cos(angle)
s = np.sin(angle)
arr = np.empty(c.shape + (2, 2), dtype=c.dtype)
arr[..., 0, 0] = c
arr[..., 0, 1] = -s
arr[..., 1, 0] = s
arr[..., 1, 1] = c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the required changes.
Before making more detailed suggestions, I'm curious what @nmayorov thinks about the 2D transformations idea given all their work on the 3D/quaternion stuff in SciPy. |
Well, 2D rotations are much more simple and universally described by a single angle. Can be seen as a 3D rotations around Z (for example) axis. Providing As for the provided simple implementation -- I guess I'm about neutral on its inclusion (after implementation and docstring cleanups). There are some discussions about providing rotations in N-dimensions in a selected plane. I think it's not often used and too abstract (besides linear algebra maybe, but they definitely don't want to use scipy in their compiled code) As for rotation as part of 4D transformation matrix in homogeneous coordinates -- maybe we could go with |
Picking up from
numpy/numpy#17089
#12693
numpy/numpy#17043
I have added transformations in 2D.