Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
planes2.data[np.isnan(planes2.data)] = 0
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
def _get_large_cell_normals(s1, s2):
dp = get_distinguished_points(s1, s2)
normals = Rodrigues.zero(dp.shape + (2,))
planes1 = dp.axis * np.tan(dp.angle.data / 4)
planes2 = -dp.axis * np.tan(dp.angle.data / 4) ** -1
planes2.data[np.isnan(planes2.data)] = 0
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
def from_symmetry(cls, s1, s2=C1):
"""The set of unique (mis)orientations of a symmetrical object.
Parameters
----------
s1, s2 : Symmetry
"""
s1, s2 = get_proper_groups(s1, s2)
large_cell_normals = _get_large_cell_normals(s1, s2)
disjoint = s1 & s2
fundamental_sector = disjoint.fundamental_sector()
fundamental_sector_normals = Rotation.from_neo_euler(
AxAngle.from_axes_angles(fundamental_sector, np.pi)
)
normals = Rotation(
np.concatenate([large_cell_normals.data, fundamental_sector_normals.data])
)
orientation_region = cls(normals)
vertices = orientation_region.vertices()
if vertices.size:
orientation_region = orientation_region[
np.any(
np.isclose(orientation_region.dot_outer(vertices).data, 0), axis=1
)
]
return orientation_region