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

ENH: Create 2DTransfrom.py #12723

Closed
wants to merge 4 commits into from
Closed

ENH: Create 2DTransfrom.py #12723

wants to merge 4 commits into from

Conversation

Yukti-09
Copy link

Picking up from

numpy/numpy#17089
#12693
numpy/numpy#17043

I have added transformations in 2D.

Comment on lines 11 to 18
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
Copy link
Contributor

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

Copy link
Author

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.

@tylerjereddy tylerjereddy added scipy.spatial enhancement A new feature or improvement labels Aug 15, 2020
@tylerjereddy tylerjereddy changed the title Create 2DTransfrom.py ENH: Create 2DTransfrom.py Aug 15, 2020
@tylerjereddy
Copy link
Contributor

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.

@nmayorov
Copy link
Contributor

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 Rotation2D class seems like a mismatch between API complexity and simplicity of the subject. I don't think its sane.

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 Transform class (combining Rotation + translation), which can be represented as 4D matrix if desired.

@Yukti-09
Copy link
Author

Yukti-09 commented Aug 19, 2020

@nmayorov
I have created an issue for the same #12693
2D rotation matrices are used very frequently in linear algebra. It would be great if one could give the angle as input and get a rotation matrix. scipy does not have a function that does the same as of now.

@rgommers rgommers deleted the branch scipy:master January 3, 2022 16:32
@rgommers rgommers closed this Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement scipy.spatial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants