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

Use scipy rotation matrices instead of by hand transformation #2097

Closed
StFroese opened this issue Oct 13, 2022 · 4 comments · Fixed by #2098
Closed

Use scipy rotation matrices instead of by hand transformation #2097

StFroese opened this issue Oct 13, 2022 · 4 comments · Fixed by #2098

Comments

@StFroese
Copy link
Member

I think this would be easier to read if we use something like
R.from_rotvec(vec).as_matrix() from scipy.

cos_z = sin(altitude)
sin_z = cos(altitude)
cos_az = cos(azimuth)
sin_az = sin(azimuth)
trans = np.array(
[
[cos_z * cos_az, -cos_z * sin_az, -sin_z],
[sin_az, cos_az, np.zeros_like(sin_z)],
[sin_z * cos_az, -sin_z * sin_az, cos_z],
],
dtype=np.float64,
)

@maxnoe
Copy link
Member

maxnoe commented Oct 13, 2022

Does that support broadcasting many angles? That wa sthe problem the last time I tried to simplify that code.

@StFroese
Copy link
Member Author

StFroese commented Oct 13, 2022

The documentation says: rotvec : array_like, shape (N, 3) or (3,)
matrix : ndarray, shape (3, 3) or (N, 3, 3)
Should work for many angles

@maxnoe
Copy link
Member

maxnoe commented Oct 13, 2022

Rotation.from_euler('zy', [az.to_value(u.rad), zen.to_value(u.rad)]).as_matrix()

@StFroese
Copy link
Member Author

But has to be -zen because of Corsika coords

@StFroese StFroese linked a pull request Oct 13, 2022 that will close this issue
kosack added a commit that referenced this issue Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants