[Numpy-discussion] New Feature added to rotate MeshGrid
Yash Tewatia
yashbsr3 at gmail.com
Tue Aug 31 06:07:14 EDT 2021
Hi, it is my first contribution to the open-source community, I have tried
to fix issue #19315, which is to add a new feature of rotating mesh grid in
NumPy. It would be great if I get improvements and suggestions for it.
Added functionality of rotating mesh grid which fixes #19315 issue, adds a
feature which works as follows
Parameters
-----------
xspan : Input_array
range of values of x in the unrotated matrix.
yspan : Input_array
range of values of y in the unrotated matrix.
angle : float or int
Angle of rotation, positive for clockwise rotation, negative for
anti-clockwise rotation.
boolRad : bool
True if the given angle is in Radians, False if given angle is
in Degrees.
Returns
--------
out : ndarray
A new nested array is generated by Einstein Summation after
rotation is applied.
Examples
----------
>>> xspan = np.linspace(-2*np.pi, 2*np.pi, 3)
>>> yspan = np.linspace(-2*np.pi, 2*np.pi, 3)
>>> arr = np.rotateMeshgrid(xspan,yspan,0.4)
>>> arr
array([[[-6.32689674, -0.04386455, 6.23916764],
[-6.28303219, 0. , 6.28303219],
[-6.23916764, 0.04386455, 6.32689674]],
[[-6.23916764, -6.28303219, -6.32689674],
[ 0.04386455, 0. , -0.04386455],
[ 6.32689674, 6.28303219, 6.23916764]]])
>>> arr = np.rotateMeshgrid(xspan,yspan,80,False)
>>> arr
array([[[ 6.9383701 , 6.24478659, 5.55120308],
[ 0.69358351, 0. , -0.69358351],
[-5.55120308, -6.24478659, -6.9383701 ]],
[[-5.55120308, 0.69358351, 6.9383701 ],
[-6.24478659, 0. , 6.24478659],
[-6.9383701 , -0.69358351, 5.55120308]]])
Code snippet:
(
https://user-images.githubusercontent.com/60055574/131483810-05012ab1-8971-4a94-8b1c-8f11d13b7c02.png
)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/numpy-discussion/attachments/20210831/5ab6fb97/attachment.html>
More information about the NumPy-Discussion
mailing list