Repository navigation
feat: Orientation from Euler angles, dot, dotOuter and distanceMatrix - #44
Merged
Merged
Conversation
The orix misorientation pins gain orderedZoneAngle and orderedZoneReduced per draw: orix 0.15.0 runs its own Misorientation.reduce loop with OrientationRegion.from_symmetry(end, start) instead of (start, end). The script asserts that this returns the smallest angle on every draw. Every existing field of the fixture is unchanged (same seed, same draws); the file only gains the two fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
orix 0.15.0 takes end * M * start and stops at the first one inside OrientationRegion.from_symmetry(start, end), whose distinguished points are start . end. The smallest angle of end * M * start lies in the Voronoi cell of the identity among end . start, the inverse set. The two agree only when the product set is a group; for 432 with 622 and 23 with 3 the zone holds no equivalent on some draws and the loop falls through to its last pair. With the zone built as from_symmetry(end, start) the same orix loop returns the smallest angle on every draw. The kit already returns the smallest angle; the parity test now compares it with that orix loop on every draw (angle atol 1e-4, the orix test tolerance; reduced matrix 1e-9 where the minimum is unique) instead of falling back to brute force where orix is not minimal. The DEVIATION note and docs/open-items.md name the cause. Done: the reduce disagreement is diagnosed and pinned. Next: the Orientation API gaps of the same issue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (orix 0.15.0) New public API on Orientation, each the orix 0.15.0 function of the same name: - Orientation(euler:symmetry:direction:) and Orientation.EulerDirection: orix Orientation.from_euler, Bunge radians through eu2qu, labToCrystal (default) or crystalToLab. - dot(_:): orix Orientation.dot, the largest |<other * self^-1, s>| over the proper operators. - Orientation.dotOuter(_:_:): orix dot_outer. - Orientation.distanceMatrix(_:): orix get_distance_matrix, arccos(2 d^2 - 1) with the dot rounded to 12 decimals and clamped as orix kernel does. All three dot functions refuse two different groups with differentSymmetry, as angle(with:) does: orix two-group dot searches sym1.outer(sym2), the inverse of the set its equivalents need, the same cause as the Misorientation.reduce DEVIATION. Pins: tools/pins/orix/orientation-api-pins.py (36 Euler triplets with the gimbal-lock and half-turn edges, both directions; the 12 class/setting entries with symmetry-equivalent pairs). OrixOrientationAPITests holds them at orix tolerances (from_euler atol 1e-4, the rest np.allclose defaults); measured worst 3.3e-16 and 8.9e-16. The consumer check calls the new API from outside the package. Done: from_euler, dot, dot_outer and get_distance_matrix for one group are held. Next: the orientation (Rodrigues) fundamental zone of the same issue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#43 landed on main as a squash. docs/open-items.md conflicted on the orix API gaps item: kept this branch rewrite (from_euler, dot, dotOuter and distanceMatrix for one group are held). The diff against main equals the diff this PR had against #43. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Paul · project thread
Part of #13. Stacked on #43 (its two commits are included here; merge #43 first). Remaining on the
issue: the orientation (Rodrigues) fundamental zone, and dot products across two different groups (see below).
New public API (additive, no migration)
Each is the orix 0.15.0 function of the same name, on
Orientation:Orientation(euler:symmetry:direction:)withOrientation.EulerDirection(labToCrystal, the default and Bungeconvention, or
crystalToLab): orixfrom_euler, Bunge radians througheu2qu. ThrowsinvalidRotationfor anon-finite angle.
dot(_:): orixOrientation.dot, the largest|<other * self^-1, s>|over the proper operators.Orientation.dotOuter(_:_:): orixdot_outer,[i][j] = a[i].dot(b[j]).Orientation.distanceMatrix(_:): orixget_distance_matrix,arccos(2 d^2 - 1)with the dot rounded to 12 decimalsand clamped, as orix kernel does (an equivalent pair is exactly 0).
The three dot functions throw
differentSymmetryfor two different groups, asangle(with:)already does. orix allowsit, but its two-group dot searches
sym1.outer(sym2), which with equivalentsS * Mis the inverse of the set it needs:for 432 with 622 and 23 with 3 it differs from the largest dot over equivalent pairs by up to 0.08 (200-draw check). This
is the same cause as the
Misorientation.reducedisagreement in #43, so it is listed as not held rather than copied.Tests
tools/pins/orix/orientation-api-pins.py(orix 0.15.0): 36 Bunge triplets with the gimbal-lock and half-turn edges, inboth directions; the 12 class/setting entries, six and five orientations each, with symmetry-equivalent pairs.
OrixOrientationAPITests(unit target, so the per-push gate runs it): red before the API existed (did not compile),green after. orix tolerances:
from_euleratol 1e-4 (test_from_euler_symmetry), the rest np.allclose defaults.Measured worst: matrix 3.3e-16, dot 4.4e-16, distance 8.9e-16.
swift test -c release --skip DiffractoKitParityTestsgreen;tools/consumer-check/run.sh730 of 730, including thenew calls.
docs/parity.mdOrientation row updated;docs/open-items.mdkeeps the fundamental zone and the two-group case.🤖 Generated with Claude Code