def fundamental_sector(self): from orix.vector.neo_euler import AxAngle from orix.vector.spherical_region import SphericalRegion symmetry = self.antipodal symmetry = symmetry[symmetry.angle > 0] axes, order = symmetry.get_highest_order_axis() if order > 6: return Vector3d.empty() axis = Vector3d.zvector().get_nearest(axes, inclusive=True) r = Rotation.from_neo_euler( AxAngle.from_axes_angles(axis, 2 * np.pi / order)) diads = symmetry.diads nearest_diad = axis.get_nearest(diads) if nearest_diad.size == 0: nearest_diad = axis.perpendicular n1 = axis.cross(nearest_diad).unit n2 = -(r * n1) next_diad = r * nearest_diad n = Vector3d.stack((n1, n2)).flatten() sr = SphericalRegion(n.unique()) inside = symmetry[symmetry.axis < sr] if inside.size == 0: return sr axes, order = inside.get_highest_order_axis() axis = axis.get_nearest(axes) r = Rotation.from_neo_euler( AxAngle.from_axes_angles(axis, 2 * np.pi / order)) nearest_diad = next_diad n1 = axis.cross(nearest_diad).unit n2 = -(r * n1) n = Vector3d(np.concatenate((n.data, n1.data, n2.data))) sr = SphericalRegion(n.unique()) return sr
class SphericalProjection: """Spherical projection of a cartesian vector according to the ISO 31-11 standard [SphericalWolfram]_. References ---------- .. [SphericalWolfram] Weisstein, Eric W. "Spherical Coordinates," *From MathWorld--A Wolfram Web Resource*, url: https://mathworld.wolfram.com/SphericalCoordinates.html """ spherical_region = SphericalRegion([0, 0, 1]) @classmethod def project(cls, v: Union[Vector3d, np.ndarray]) -> np.ndarray: """Convert from cartesian to spherical coordinates according to the ISO 31-11 standard [SphericalWolfram]_. 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.spherical_projection import ( ... SphericalProjection ... ) >>> v = np.random.random_sample(30).reshape((10, 3)) >>> theta, phi, r = SphericalProjection.project(v) >>> np.allclose(np.arccos(v[: 2] / r), theta) True >>> np.allclose(np.arctan2(v[:, 1], v[:, 2]), phi) True """ return _get_polar(v)
def spherical_region(request): return SphericalRegion(request.param)