spinor-lib · three.js demos

Five interactive scenes. Every number on screen is computed by spinor_lib (PyTorch) in demos/api.py and sent to the browser as JSON; three.js only draws. The list under each card names the library functions doing the work.

1 · Bloch sphere & the double cover

Rotate a spin-½ state about any axis and watch its Bloch arrow return after 360° while the spinor itself comes back negated, needing 720°. Includes a Larmor-precession cloud of 150 spins.

generate_su2_rotation · rotate · bloch_vector · inner_product · su2_to_quaternion · su2_to_so3

2 · Dirac's belt trick

A belt twisted by 360° or 720°, untwisted by a homotopy computed on the unit quaternions. With two twists the buckle never rotates; with one it is forced to flip over. The lifted path in SU(2) is shown alongside.

generate_su2_rotation · su2_to_quaternion · quaternion_to_su2 · su2_to_so3

3 · Relativistic aberration of the sky

A boost is an SL(2,C) matrix acting on Weyl spinors. Apply it to 1500 stars and the sky grid: stars bunch up ahead, blueshift, and circles stay circles. Fly at up to 0.99 c.

generate_boost · rapidity_from_velocity · from_bloch_vector · weyl_current · sl2c_to_lorentz

4 · Two qubits: entanglement shrinks the arrows

Build cos θ|00⟩ + sin θ|11⟩ with a rotation and a CNOT, then trace out each qubit. The reduced Bloch vectors sink into the ball as concurrence rises; local rotations move them without changing entanglement.

tensor_product · embed_operator · reduced_density_matrix · concurrence · entanglement_entropy · purity

5 · Learning a rotation live

Watch QuaternionRotation recover a hidden SU(2) rotation from noisy before/after pairs by gradient descent, one optimiser step at a time, with the loss curve and the learned frame converging.

QuaternionRotation · fidelity · autograd · Adam · su2_to_so3