Repository navigation
Draw regions and paths on 3-D panels - #81
Merged
Merged
Conversation
Plot3D.add_patch draws a filled region (or, with closed=False, a path) over the geometry. Edges follow great circles about the data centre by default, which is exactly the shape a flat detector's straight edge makes on a sphere, so four corners give a detector's footprint. frame="world" keeps a patch fixed while set_rotation turns the data under it; frame="data" turns it with the data. The renderer splits each patch at the plane through the centre facing the camera and draws the back half dimmer and dashed. Where a geodesic patch is cut there, the fill follows the sphere's silhouette instead of a chord. Labels anchor on the patch's surface, with a halo chosen to contrast with the label colour. The Kikuchi sphere example now shows both frames: the detector footprint (world) and the (111) trace (data).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #81 +/- ##
==========================================
+ Coverage 91.22% 91.24% +0.02%
==========================================
Files 41 41
Lines 4910 4991 +81
==========================================
+ Hits 4479 4554 +75
- Misses 431 437 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Stacked on #80 (needs the model rotation for
frame="world"to mean anything); retarget tomainonce that merges.Why
To mark the part of a sphere a detector sees, a grain's spread on a pole sphere, or the trace of a lattice plane, a 3-D panel needs regions that sit on the surface: edges that follow the sphere, the far side visibly behind, and a choice between belonging to the object and belonging to the instrument.
What
Plot3D.add_patch(points, *, frame="data"|"world", closed=True, geodesic=True, facecolor, edgecolor, alpha, back_alpha, linewidth, label, name) -> Patch3D, plusremove_patch,patches, andPatch3D.set(...)/.remove(). Light pushes only (no geometry resend).geodesic=True(default): Python joins corners by great-circle arcs about the centre of the data bounds in ≤2° steps, interpolating radius. Four corners make a detector's footprint, because a flat detector's straight edges are great circles on the sphere. Opposite points and points at the centre are rejected with a clear message.frame="world"uses the camera alone, so the patch stays put whileset_rotationturns the data under it;"data"turns with it.back_alpha, dashed. Where a geodesic patch is cut, the fill follows the silhouette arc rather than a chord across the disc; the outline draws only the patch's own edges. Labels anchor on the patch's surface (front-most point for a full great circle), with a black/white halo picked against the label colour.Tests
tests/test_plot3d/test_patches.py: geodesic edges stay on the sphere at ≤2° steps, straight/open variants, validation, set/remove as light pushes, name replacement; Playwright: a "data" patch moves underset_rotationand a "world" patch does not, and a far-side patch is drawn dimmer.test_plot3d+test_examples: 172 passed.