yt.utilities.math_utils.rotate_vector_3D

yt.utilities.math_utils.rotate_vector_3D(a, dim, angle)[source]

Rotates the elements of an array around an axis by some angle.

Given an array of 3D vectors a, this rotates them around a coordinate axis by a clockwise angle. An alternative way to think about it is the coordinate axes are rotated counterclockwise, which changes the directions of the vectors accordingly.

Parameters:

a : array

An array of 3D vectors with dimension Nx3.

dim : integer

A integer giving the axis around which the vectors will be rotated. (x, y, z) = (0, 1, 2).

angle : float

The angle in radians through which the vectors will be rotated clockwise.

Examples

>>> a = np.array([[1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1], [3, 4, 5]])
>>> b = rotate_vector_3D(a, 2, np.pi/2)
>>> print b
[[  1.00000000e+00  -1.00000000e+00   0.00000000e+00]
[  6.12323400e-17  -1.00000000e+00   1.00000000e+00]
[  1.00000000e+00   6.12323400e-17   1.00000000e+00]
[  1.00000000e+00  -1.00000000e+00   1.00000000e+00]
[  4.00000000e+00  -3.00000000e+00   5.00000000e+00]]