Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_from_axes_angles(axis, angle, expected_axis):
ax = AxAngle.from_axes_angles(axis, angle)
assert np.allclose(ax.axis.data, expected_axis)
assert np.allclose(ax.angle.data, abs(angle))
def axangle(request):
return AxAngle(request.param.data)
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
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)
Examples
--------
>>> from math import pi
>>> v = Vector3d((0, 1, 0))
>>> axis = Vector3d((0, 0, 1))
>>> angles = [0, pi/4, pi/2, 3*pi/4, pi]
>>> v.rotate(axis=axis, angle=angles)
"""
from orix.quaternion.rotation import Rotation
from orix.vector.neo_euler import AxAngle
axis = Vector3d.zvector() if axis is None else axis
angle = 0 if angle is None else angle
q = Rotation.from_neo_euler(AxAngle.from_axes_angles(axis, angle))
return q * self
normals[:, 0] = planes1
normals[:, 1] = planes2
normals: Rotation = Rotation.from_neo_euler(normals).flatten().unique(
antipodal=False
)
if not normals.size:
return normals
_, inv = normals.axis.unique(return_inverse=True)
axes_unique = []
angles_unique = []
for i in np.unique(inv):
n = normals[inv == i]
axes_unique.append(n.axis.data[0])
angles_unique.append(n.angle.data.max())
normals = Rotation.from_neo_euler(
AxAngle.from_axes_angles(np.array(axes_unique), angles_unique)
)
return normals