Expand description
Two-body elastic kinematics, direction rotation and planar surface refraction. Pure functions, no state.
Functionsยง
- gamma
- Kinematic factor
gamma = 4 M1 M2 / (M1 + M2)^2. - lab_
angles - Laboratory deflection of projectile and recoil for a centre-of-mass
scattering angle
thetaand mass ratiomu = M1 / M2. - lab_
projectile_ sc - Lab deflection of the projectile, as
(sin psi, cos psi), from the half-angle sine and cosine of the centre-of-mass angle (s = sin(theta/2),c = cos(theta/2),s^2 + c^2 = 1) andmu = M1 / M2. - normalize
- Normalise a vector to unit length.
- refract_
out - Planar surface barrier at a face with outward normal along
x(sign ofdir[0]gives which face). - refract_
out_ normal refract_outthrough a face with outward unit normalnormal(any orientation, not only the planarxfaces): the normal component of the momentum is reduced, the tangential components are unchanged. The particle must be moving outward (dir . normal > 0) to escape.- rotate
- Rotate unit vector
uby polar anglepolar(fromu) at azimuthazimuthaboutu. The azimuth is measured in a frame built fromuand the coordinate axis least aligned with it; since the azimuth is drawn uniformly the choice of frame does not matter, it only has to be fixed so results are reproducible. - rotate_
sc rotatewith the polar and azimuthal angles given as(sin, cos)pairs, so a caller that already has them (the collision code gets the lab deflection from the half-angle tangent, without an inverse trigonometric call) pays for nosin_cos.- sin_
cos_ turns (sin, cos)of the angle2 pi uforuin[0, 1), the azimuth of a collision drawn as a fraction of a turn.