Skip to content

Commit 68c246d

Browse files
committed
update changelog and cleanup example for from_path_ends
1 parent a3ffb06 commit 68c246d

File tree

5 files changed

+63
-52
lines changed

5 files changed

+63
-52
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Added
3434
An example of a custom projection is the :class:`~orix.plot.StereographicPlot`.
3535
This function replaces the previous behavior of relying on a side-effect of importing
3636
the :mod:`orix.plot` module, which also registered the projections.
37+
- :func:`~orix.quaternion.Rotation.from_path_ends` returns evenly spaced points
38+
mapping the shortest path betwen two or more rotations.
3739

3840
Changed
3941
-------

examples/plotting/paths_through_orientation_space.py renamed to examples/plotting/visualizing_crystallographic_paths.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
r"""
22
=========================================
3-
Plot Paths In Rotation and Vector Space
3+
Visualizing crystallographic paths
44
=========================================
5-
This example shows how paths though either rotation or vector space
6-
can be plotted using ORIX. These are the shortest paths through their
7-
respective spaces, and thus not always straight lines in euclidean
8-
projections (axis-angle, stereographic, etc.).
5+
6+
This example shows how define and plot paths through either
7+
rotation or vector space.This is akin to describing crystallographic
8+
fiber textures in metallurgy, or the shortest arcs connecting points on
9+
the surface of a unit sphere.
10+
11+
In both cases, "shortest" is defined as the route that minimizes the
12+
movement required to transform from point to point, which is typically
13+
not a stright line when plotted into a euclidean projection
14+
(axis-angle, stereographic, etc.).
15+
916
This functionality is available in :class:`~orix.vector.Vector3d`,
1017
:class:`~orix.quaternions.Rotation`,
1118
:class:`~orix.quaternions.Orientation`,
12-
and :class:`~orix.quaternions.Misorientation`.
13-
"""
19+
and :class:`~orix.quaternions.Misorientation`."""
1420

1521
from matplotlib import cm
1622
import matplotlib.pyplot as plt
@@ -31,16 +37,18 @@
3137
fig = plt.figure(figsize=(6, 6))
3238
n_steps = 30
3339

34-
# ========= #
40+
# ============ #
3541
# Example 1: Plotting multiple paths into a user defined axis
36-
# ========= #
42+
3743
# This subplot shows several paths through the cubic (m3m) fundamental zone
3844
# created by rotating 20 randomly chosen points 30 degrees around the z axis.
3945
# these paths are drawn in rodrigues space, which is an equal-angle projection
4046
# of rotation space. As such, notice how all lines tracing out axial rotations
4147
# are straight, but lines starting closer to the center of the fundamental zone
4248
# appear shorter.
49+
4350
# the sampe paths are then also plotted on an Inverse Pole Figure (IPF) plot.
51+
4452
rod_ax = fig.add_subplot(2, 2, 1, projection="rodrigues", proj_type="ortho")
4553
ipf_ax = fig.add_subplot(2, 2, 2, projection="ipf", symmetry=Oh)
4654

@@ -86,20 +94,22 @@
8694
ipf_ax.set_title(r"IPF, multiple paths ")
8795

8896

89-
# %%
90-
# ========= #
97+
# ============ #
9198
# Example 2: Plotting a path using `Rotation.scatter'
92-
# ========= #
9399
# This subplot traces the path of an object rotated 90 degrees around the
94100
# X axis, then 90 degrees around the Y axis.
101+
95102
rots = Orientation.from_axes_angles(
96103
[[1, 0, 0], [1, 0, 0], [0, 1, 0]], [0, 90, 90], degrees=True, symmetry=C1
97104
)
98105
rots[2] = rots[1] * rots[2]
99106
path = Orientation.from_path_ends(rots, steps=n_steps)
100107
# create a list of RGBA color values for a gradient red line and blue line
101108
path_colors = np.vstack(
102-
[cm.Reds(np.linspace(0.5, 1, n_steps)), cm.Blues(np.linspace(0.5, 1, n_steps))]
109+
[
110+
cm.Reds(np.linspace(0.5, 1, n_steps)),
111+
cm.Blues(np.linspace(0.5, 1, n_steps)),
112+
]
103113
)
104114

105115
# Here, we instead use the in-built plotting tool from
@@ -108,11 +118,10 @@
108118
path.scatter(figure=fig, position=[2, 2, 3], marker=">", c=path_colors)
109119
fig.axes[2].set_title(r"Axis-Angle, two $90^\circ$ rotations")
110120

111-
# %%
112121

113-
# ========= #
122+
# ============ #
114123
# Example 3: paths in stereographic plots
115-
# ========= #
124+
116125
# This is similar to the second example, but now vectors are being rotated
117126
# 30 degrees around the [1,1,1] axis on a stereographic plot.
118127

orix/quaternion/misorientation.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -277,33 +277,33 @@ def from_scipy_rotation(
277277
def from_path_ends(
278278
cls, points: Misorientation, closed: bool = False, steps: int = 100
279279
) -> Misorientation:
280-
"""Return misorientations tracing the shortest path (ignoring
281-
symmetry) between two or more consecutive points.
280+
"""Return misorientations tracing the shortest path between
281+
two or more consecutive points.
282282
283283
Parameters
284284
----------
285285
points
286-
Two or more misorientations that define waypoints along
287-
a path through rotation space (SO3).
286+
Two or more misorientations that define points along the
287+
path.
288288
closed
289-
Option to add a final trip from the last waypoint back to
289+
Option to add a final trip from the last point back to
290290
the first, thus closing the loop. The default is False.
291291
steps
292-
Number of misorientations to return along the path
293-
between each pair of waypoints. The default is 100.
292+
Number of misorientations to return between each point
293+
along the path defined by `points`. The default is 100.
294294
295295
Returns
296296
-------
297297
path
298-
misorientations that map a path between the given waypoints.
298+
regularly spaced misorientations following the shortest
299+
path.
299300
300-
Note
301-
-------
302-
This function traces a path between points in SO(3), in which there
303-
is one and only one direct path between every point. The equivalent
304-
is not well-defined for misorientations, which define multiple
305-
symmetrically-equivalent points in SO(3) with non-equivalent paths
306-
between them.
301+
Notes
302+
-----
303+
This function traces the shortest path between points without
304+
any regard to symmetry. Concept of "shortest path" is not
305+
well-defined for misorientations, which can define multiple
306+
symmetrically equivalent points with non-equivalent paths.
307307
"""
308308
# Confirm `points` are misorientations.
309309
if type(points) is not cls:

orix/quaternion/orientation.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -356,33 +356,32 @@ def from_scipy_rotation(
356356
def from_path_ends(
357357
cls, points: Orientation, closed: bool = False, steps: int = 100
358358
) -> Misorientation:
359-
"""Return orientations tracing the shortest path (ignoring
360-
symmetry) between two or more consecutive points.
359+
"""Return orientations tracing the shortest path between two
360+
or more consecutive points.
361361
362362
Parameters
363363
----------
364364
points
365-
Two or more orientations that define waypoints along
366-
a path through rotation space (SO3).
365+
Two or more orientations that define points along the
366+
path.
367367
closed
368-
Option to add a final trip from the last waypoint back to
368+
Option to add a final trip from the last point back to
369369
the first, thus closing the loop. The default is False.
370370
steps
371-
Number of orientations to return along the path
372-
between each pair of waypoints. The default is 100.
371+
Number of orientations to return between each point
372+
along the path defined by `points`. The default is 100.
373373
374374
Returns
375375
-------
376376
path
377-
orientations that map a path between the given waypoints.
377+
regularly spaced orientations following the shortest path.
378378
379-
Note
380-
-------
381-
This function traces a path between points in SO(3), in which there
382-
is one and only one direct path between every point. The equivalent
383-
is not well-defined for orientations, which define multiple
384-
symmetrically-equivalent points in SO(3) with non-equivalent paths
385-
between them.
379+
Notes
380+
-----
381+
This function traces the shortest path between points without
382+
any regard to symmetry. Concept of "shortest path" is not
383+
well-defined for orientations, which can define multiple
384+
symmetrically equivalent points with non-equivalent paths.
386385
"""
387386
if type(points) is not cls:
388387
raise TypeError(

orix/quaternion/quaternion.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,21 +697,22 @@ def from_path_ends(
697697
) -> Quaternion:
698698
"""Return quaternions tracing the shortest path between two or
699699
more consecutive points.
700+
700701
Parameters
701702
----------
702703
points
703-
Two or more quaternions that define points along a path
704-
through rotation space (SO3).
704+
Two or more quaternions that define points along the path.
705705
closed
706-
Option to add a final trip from the last waypoint back to
706+
Option to add a final trip from the last point back to
707707
the first, thus closing the loop. The default is False.
708708
steps
709-
Number of quaternions to return along the path between each
710-
pair of waypoints. The default is 100.
709+
Number of quaternions to return between each point along
710+
the path defined by `points`. The default is 100.
711+
711712
Returns
712713
-------
713714
path
714-
quaternions that map a path between the given waypoints.
715+
regularly spaced quaternions following the shortest path.
715716
"""
716717
points = points.flatten()
717718
n = points.size

0 commit comments

Comments
 (0)