Orient-a-Laue - Help & Theory
Core Functionality
- Simulation: Define a lattice and detector to predict a Laue pattern (virtual goniometer + polychromatic beam).
- Indexing: Load a real image, pick peaks, and solve the unknown crystal orientation; then simulate and overlay spots for verification.
- Orientation: Calculate the goniometer angles required to geometrically align a specific (h,k,l) plane normal with the detector normal, and apply them on demand.
The controls are organized into five tabs — System, Sample, Measure, Search, Orient — reflecting the order you'd typically move through a real experiment. The left panel is resizable (drag its right edge) and the app supports both dark and light themes (toggle icon, top right).
Two Orientations: how rotations are applied
Base Orientation (unknown): The sample's as-mounted orientation found by the search. Selecting a solution in the Search tab sets this as the internal base matrix, and also unlocks the Orient tab.
Goniometer Angles (knobs): The
X,Y,Zsliders in the System tab. They rotate on top of the Base Orientation and also respond to canvas drag. A Reset button next to the label zeros all three at once.
Total rotation used in simulation = Base then Goniometer (XYZ Euler). After you select a solution, the sliders are reset to 0 so the display shows the solved orientation. Moving a slider then offsets from that base.
The Orient tab's "Calculate Goniometer Angles" only previews the X/Y/Z needed to reach a target (h,k,l) — it does not move anything. The goniometer only changes when you press Set Orientation.
Typical workflow (indexing)
- Sample tab. Choose the Bravais lattice and enter cell parameters. The Calc. Spot Size slider controls how big simulated (yellow) spots are drawn — set it to
0to hide them entirely. - System tab. Set the X-ray source band (
λ_min–λ_max) and the detector Angle / Distance to match your experiment. The Goniometer Angles here start at 0,0,0 (use Reset to return to that at any time). - Measure → Load Image. The file name appears below the button. Loading a new image resets everything — center, scale, peaks, solutions, and the Orient tab all clear. If spots are white on black, check Invert Image.
- 1. Set Center. Click the beam center on the image.
- Set Scale. Drag the blue crosshair to a known reference point and enter its real
U (mm), V (mm)relative to the center. - Experimental Peaks. Click Find Peaks for automatic detection, or + Add Peaks… to place them by hand — the cursor becomes a crosshair, the button itself turns into Cancel, and you can keep clicking to add multiple points before pressing Cancel to stop. Peak Threshold (20–90%) sets how faint a spot can be and still count; dragging it live-reruns Find Peaks. Peak Marker Size is purely visual (mm,
0= hidden) and doesn't affect detection. - Search tab. Search Orientation enables once an image is loaded with center, scale, and at least 4 peaks. The first search after loading an image (or changing lattice/Bravais type) takes a few seconds to build an internal reflection library; later searches reuse it. Click a row in the results to select it — this sets the Base Orientation and unlocks the Orient tab.
- Orient tab (optional). Only usable after selecting a solution. Enter a target
(h,k,l)and click Calculate Goniometer Angles to preview the X/Y/Z needed to align that plane's normal with the detector normal. Click Set Orientation to actually apply those angles to the System tab's goniometer. - Report. The printer icon (top right, next to the theme toggle and help button) saves a PDF with parameters, the peak table, the best solution's matches, and a summary of all solutions.
UI reference (tabs)
System
- X-ray Source (Laue).
λ_min–λ_max(Å) define the polychromatic band. - Detector Geometry.
Angle (°)defines the detector plane's orientation relative to the beam (0° is transmission, 180° is back-scattering).Dist. (mm)is the distance from the sample to the detector plane's center. - Goniometer Angles (°). X/Y/Z act relative to the chosen Base Orientation; dragging the canvas adjusts Y/Z. The Reset button zeros all three.
Sample
- Lattice & parameters. Bravais choice enables the right fields (e.g., only
afor cubic;a,cfor tetragonal; monoclinic fixes α=γ=90°, etc.). - Calc. Spot Size. Physical size (mm) of the simulated (yellow) overlay spots.
0hides them.
Measure
- Load Image. The loaded file's name is shown below the button. Loading a different file resets center, scale, peaks, solutions, and the Orient tab.
- Set Center → Set Scale. After center, enter a second point's real coordinates (U, V) to establish px→mm.
- Experimental Peaks. Find Peaks runs automatic detection at the current threshold. + Add Peaks… enters a continuous placement mode (crosshair cursor); the same button becomes Cancel to exit it. Rows can be edited inline (the edited point highlights red on the image) or dragged directly.
- Peak Threshold (20–90%). How faint (as a fraction of the frame's brightest pixel) a spot can be and still be detected. Changing it live-reruns Find Peaks if an image, center, and scale are already set.
- Peak Marker Size. Purely visual (mm,
0= hidden); doesn't affect click/drag hit-testing, which stays reliable regardless of this setting.
Search
- Search Orientation is enabled only once an image is loaded with a valid center, scale, and at least 4 peaks; a hint below the button explains what's still missing.
- Results list up to 10 unique solution clusters: Score (lower is better) and Rot (X,Y,Z). Clicking a row selects it — this sets the Base Orientation and unlocks the Orient tab. Symmetry-equivalent orientations are automatically merged into single clusters (see Search Algorithm).
Orient
- Disabled until a solution has been selected in the Search tab.
- Calculate Goniometer Angles computes the X/Y/Z needed to geometrically align the chosen (h,k,l) plane normal (its reciprocal vector
g) parallel with the detector's normal vector, and shows them in the read-only fields. It does not move the goniometer.
• The target uses the current Detector Angle from the System tab as its alignment reference, and is valid across the full 0°–180° range. - Set Orientation applies the calculated angles to the System tab's goniometer. Nothing moves until you press this.
- Note: This is a purely geometric alignment — a diffraction spot will generally not appear at the detector center, since this doesn't solve for the Bragg condition.
Mathematical model
1) Unit cell → reciprocal basis
Given cell a,b,c and angles α,β,γ, direct vectors are
// direct basis (Å)
a = (a, 0, 0)
b = (b cosγ, b sinγ, 0)
c = (c cosβ, c (cosα − cosβ cosγ)/sinγ, V/(a b sinγ))
V = a b c √(1 − cos²α − cos²β − cos²γ + 2 cosα cosβ cosγ)
Reciprocal basis vectors (Å⁻¹) are
a* = (b × c)/V , b* = (c × a)/V , c* = (a × b)/V
Any reflection (h,k,l) maps to g₀ = h a* + k b* + l c*.
2) Systematic absences (Bravais rules)
| Type | Condition |
|---|---|
| P | all (h,k,l) allowed |
| I | h + k + l even |
| F | h, k, l all even or all odd |
| C | h + k even |
| R | −h + k + l ≡ 0 (mod 3) |
3) Orientation stacking
Reflections are rotated first by the Base Orientation U (from the solver), then by the goniometer Euler rotation R(X,Y,Z). The goniometer rotations are mathematically applied in the sequence: first around X, then around Y, and finally around Z.
g = R(X,Y,Z) · U · g₀
4) Laue condition, wavelength band, and detector hit
Beam points along +X. With unit wavevectors k̂_in = (1,0,0) and k̂_out, define the (normalized) scattering vector ĝ = k̂_out − k̂_in. For a given lattice vector g (Å⁻¹), elastic diffraction requires
2 k_in · g + |g|² = 0 , with k_in = (1/λ, 0, 0)
Solving for the required wavenumber gives
k = − |g|² / (2 gₓ)
- The polychromatic band is
k ∈ [1/λ_max, 1/λ_min]. Ifkfalls outside, the spot is culled.
The diffracted ray is k_out = g + (k,0,0). The detector plane is defined by its angle φ (0° to 180°) and distance D.
// Detector plane normal and u-axis (horizontal)
n̂ = (cosφ, sinφ, 0)
û = (-sinφ, cosφ, 0)
The intersection P_hit is found by solving t for the ray P(t) = t · k_out and the plane P · n̂ = D.
- This gives
t = D / (k_out · n̂). - A hit is valid only if
t > 0(intersection is in front of the sample, pointing toward the detector). - The (U,V) coordinates on the detector are the projection of
P_hit:
v = P_hit_z // Vertical coordinate is the Z component
u = P_hit · û // Horizontal coordinate
(x₂d, y₂d) = (u, v) // These are the plotted (mm) coordinates
5) Experimental geometry → scattering vectors
From a measured spot at detector coordinates (u_mm, v_mm) relative to the center, we reconstruct the 3D scattering vector.
// φ is the detector angle, D is distance
n̂ = (cosφ, sinφ, 0)
û = (-sinφ, cosφ, 0)
v̂ = (0, 0, 1)
// Reconstruct 3D spot position from (u,v)
P_center = D · n̂
P_hit = P_center + (u_mm · û) + (v_mm · v̂)
k̂_out = normalize( P_hit )
ĝ_exp = normalize( k̂_out − (1,0,0) ) // used for orientation solving
6) Pixel ↔ millimeter conversion
After you click the beam center (pixels) and place a scale point with known (mm), the app sets independent scale factors for U and V:
pixels_per_mm_x = (x_px − x0_px) / U_mm
pixels_per_mm_y = −(y_px − y0_px) / V_mm // minus because image Y is down
Orientation search (what "Search Orientation" does)
The search uses a Hough-transform-style voting scheme: it looks for a single rotation that explains many picked peaks simultaneously, rather than trusting any one pair of spots.
- Build a direction library (cached). Every
(h,k,l)with indices up to±8— filtered by the Bravais systematic-absence rule — is converted to a unit reciprocal-space direction. Building and sorting this library is the slow part, so it's cached and only rebuilt when the lattice or Bravais type changes. Expect the first search after loading an image (or changing the lattice) to take a few seconds; later searches reuse the cache and are much faster. - Reconstruct experimental directions. Each picked peak's detector position is converted to a scattering-vector direction
ĝ_exp— direction only, since the specific wavelength that produced any given spot isn't known (see §5 of the Mathematical Model). - Vote. A handful of peaks are tried in turn as a "reference" spot. For each candidate library direction as that spot's hypothesized
(h,k,l), the exact rotation angle that would align every other picked peak to some library direction is computed directly from geometry (a closed-form calculation, not a scan). Hypotheses where enough distinct peaks agree on the same angle become candidate orientations. - Refine. Each candidate is polished ICP-style: simulate the full pattern, match it against all picked peaks, refit the rotation using every matched pair (not just the original two), and repeat until it converges.
- Score, cluster, and rank. Refined candidates are scored by RMS position error and fraction of peaks matched. The algorithm then clusters solutions by comparing their simulated diffraction patterns. Solutions that produce identical spot patterns (e.g., due to symmetry) or are within ~3° of an already-kept solution are merged into a single cluster. The top 10 unique clusters are listed.
Why not just check every pair of low-index reflections?An earlier version of this tool did exactly that — seeding candidates from pairs of low-index reflections (
|h,k,l| ≤ 2) ranked by "simplicity." It worked for generic orientations but failed for patterns near a symmetric zone axis: thousands of spurious low-index pairs coincidentally matched the observed angles and crowded out the true match, which was often higher-index. Requiring several spots to agree on the same rotation, rather than trusting a single coincidental pair, is what fixes this.
Symmetry-equivalent solutions are clustered. A cubic lattice has 24 proper rotations indistinguishable from diffraction data alone. Because the algorithm compares the simulated spot patterns of candidate solutions, it recognizes when different Euler angles produce the same physical pattern on the detector and compacts these degenerate solutions into a single cluster.
Peak count matters. At least 4 peaks are required to enable a search, but the vote is far more reliable with 8–20, spread across different quadrants of the pattern rather than clustered together.
Peak finder details
- Grayscale image; optional inversion. Threshold is set by the Peak Threshold slider (20–90% of the frame's max intensity) in the Measure tab — lower it to catch fainter spots, raise it to ignore noise.
- Local-max test in a small neighborhood; excludes a central disk (~5 mm radius) around the beam center.
- Balanced selection across quadrants, generously capped (well above what the threshold will realistically return) so the threshold — not a hidden count limit — is what actually controls how many peaks you get.
- Changing the threshold live-reruns detection once an image, center, and scale exist.
- You can always refine by manually adding, editing, or dragging spots. Peak Marker Size controls their on-screen size only (mm,
0hides them) and never affects detection or clickability.
Report contents
Click the printer icon (top right) to generate the report.
- Detector snapshot with overlays.
- Simulation + analysis parameters (lattice, λ band, D, Angle, center/scale).
- Experimental peak list in (U, V) mm (+ raw pixels).
- Best solution details: each peak's assigned
(h,k,l), simulated (U, V) and error (mm). - All solutions summary.
Troubleshooting
No or poor solutions
- Verify Bravais type and lattice parameters (Sample tab).
- Check detector Distance and Angle in the System tab (e.g., 0° for transmission, 180° for back-scatter).
- Re-do center/scale carefully in the Measure tab; a wrong scale ruins the geometry.
- Use at least 4 peaks — ideally 8–20, spread across quadrants rather than clustered. Try Invert Image or lowering the Peak Threshold if the finder misses faint spots.
- Search Orientation stays disabled until an image, center, scale, and ≥4 peaks are all in place — the hint text under the button in the Search tab says exactly what's still missing.
- Symmetry-equivalent solutions (e.g., cubic degeneracies) are automatically clustered based on their spot patterns (see Search Algorithm). If you still see multiple distinct solutions with similar scores, they represent genuinely different diffraction patterns.
Clicking "Calculate Goniometer Angles" doesn't move anything
- This is intentional. Calculating only fills in the read-only X/Y/Z preview fields. The goniometer itself is only updated when you press Set Orientation right below it.
- The Orient tab is disabled entirely until you've selected a solution in the Search tab — there's no "current orientation" to rotate from otherwise.
A spot doesn't appear after orienting to (h,k,l)
- This is expected behavior. Orienting performs a purely geometric alignment, making the (h,k,l) plane normal parallel to the detector normal. It does not solve for the Bragg condition of an actual diffraction spot.
- A spot will only appear at the center if this geometric alignment also happens to satisfy the Bragg condition for a wavelength within your source's
λ_min–λ_maxrange (guaranteed only at 180°).
Conventions & hints
- Coordinate System: The incident beam is along the +X axis. The lab's vertical direction is +Z (mapping to the detector's +V coordinate). To form a right-handed system, +Y points to the left when looking along the beam (+X). The detector plane's position is defined by its Angle (0° = transmission, plane at
x = +D; 90° = side, plane aty = +D; 180° = back-scatter, plane atx = -D). - Rotation Convention (Right-Hand Screw Rule): Positive rotation angles follow a standard right-handed screw. If you look down an axis (from the origin toward the positive direction), a positive (+) rotation turns clockwise (driving the screw forward).
- Rotation Sequence: Goniometer angles are applied mathematically in the order: X, then Y, then Z.
- Peak and scale-point coordinates are in the detector's (U, V) system, in mm, established by Set Scale.
- (U, V) values can be edited directly in the Measure tab's peak list.
- Dragging the canvas rotates Y/Z goniometer axes; use the sliders in the System tab for precise values.
- Use a realistic λ band (e.g., 0.2–3.0 Å) and a correct D to reduce false solutions.
- The cursor changes with mode: a crosshair while adding peaks, a wait cursor while a search or report is running.
- The left panel is resizable — drag its right edge — and its width adapts if you resize the browser window.
- Dark/light theme is a per-browser preference (saved locally) via the toggle icon at top right, next to the report and help icons.