Bragg Diffraction API
X-ray crystallography maths as an API, computed locally and deterministically. The angle endpoint applies Bragg’s law, n·λ = 2·d·sinθ, to give the diffraction angle θ and the experimentally plotted 2θ from a crystal’s inter-planar spacing and the X-ray wavelength, defaulting to the common Cu Kα source at 0.15406 nm and reporting the highest observable order ⌊2d/λ⌋ — a 0.2 nm plane spacing diffracts Cu Kα to θ ≈ 22.65°, a 2θ peak near 45.3°. The spacing endpoint inverts the law, d = n·λ/(2·sinθ), reading the lattice spacing straight off a measured XRD peak — the everyday job of indexing a diffraction pattern, so a 2θ of 31.77° for table salt gives the 0.2814 nm (200) spacing. The wavelength endpoint solves λ = 2·d·sinθ/n to identify or calibrate the source. Lengths are entered in nanometres or ångström and angles in degrees, and any diffraction order n is supported. Everything is computed locally and deterministically, so it is instant and private. Ideal for materials-science, crystallography, mineralogy, XRD, semiconductor and solid-state-physics app developers, lattice-spacing and pattern-indexing tools, and laboratory software. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is reflection-geometry Bragg diffraction with the 2d factor; for optical double-slit and grating diffraction use a wave-optics diffraction API.
api.oanor.com/bragg-api