vector2xy#

classmethod SphericalProjection.vector2xy(v: Union[Vector3d, ndarray]) ndarray[source]#

Convert from cartesian to spherical coordinates according to the ISO 31-11 standard.

Parameters:
v

3D vector(s) on the form [[x0, y0, z0], [x1, y1, z1], ...].

Returns:
spherical_coordinates

Spherical coordinates theta, phi and r on the form [[theta1, phi1, r1], [theta2, phi2, r2], ...].

Examples

>>> import numpy as np
>>> from kikuchipy.projections import SphericalProjection
>>> v = np.random.random_sample(30).reshape((10, 3))
>>> theta, phi, r = SphericalProjection.vector2xy(v).T
>>> np.allclose(np.arccos(v[:, 2] / r), theta)
True
>>> np.allclose(np.arctan2(v[:, 1], v[:, 0]), phi)
True