The library¶
lusine's library is a set of kernels: small laws written once in Trait, which a game calls by name, such as lusine.laws.drag. They are grouped into layers by what they are about. Each kernel's page shows its Trait source first, then checks what it computes.
Camera¶
Moving a game's camera: following a target, orbiting it, looking and walking in the first person.
- The follow camera's eye
- The first-person camera's line of sight
- The orbit camera's eye
- The first-person camera's step
Display¶
Turning a value into a colour to show: a grey level, a heat ramp.
Error¶
The seeded error: random draws that are the same on every run, from a seed, a step, a stream's name and an index.
- The seeded error's draw: 32 bits for a seed, a step, a key and an index
- The seeded error's finalizer: 32 bits mixed, the host's bit for bit
- Three 32-bit values hashed into one: the seeded error's hash
- [A draw as a uniform: the top 24 bits, in 0, 1)
- The seeded error's draw, live
- The seeded error's finalizer, live
- The seeded error's hash, live
- A draw as a uniform, live
Events¶
Noticing things between steps: the step a state turns on, and how much two intervals overlap.
Finance¶
Markets and money: returns and volatility, bonds and yields, options and their sensitivities, matching orders and a factor model's fair value.
- Accrual: simple interest
- The annualised volatility
- A bond's present value
- A bond's yield from its price
- Crossing price: the resting order's
- Black and Scholes's d1
- Black and Scholes's d2
- Modified duration
- The EWMA variance
- The factor model's fair value
- Fill: price-time priority
- The factor model's implied correlation
- The log return
- The Nelson-Siegel curve
- Fitting the Nelson-Siegel curve
- The normal distribution
- The normal density
- Delta: a European option's value against its stock's price
- Gamma: a European option's delta against its stock's price
- Rho: a European option's value against the interest rate
- Theta: a European option's value as calendar time passes
- Black-Scholes: a European option's value
- Vega: a European option's value against the volatility
- The realised variance
- The decay a sample
- Accrual, live
- The annualised volatility, live
- A bond's price, live
- The crossing price, live
- Black and Scholes's d₁, live
- Black and Scholes's d₂, live
- A bond's duration, live
- The EWMA variance, live
- The factor model's fair value, live
- A fill by price-time priority, live
- The log return, live
- The Nelson-Siegel curve, live
- The normal distribution, live
- The normal density, live
- An option's delta, live
- An option's gamma, live
- An option's rho, live
- An option's theta, live
- A European option's value, live
- An option's vega, live
- The realised variance, live
Integrator¶
Moving bodies through time, a step at a time: velocity Verlet, semi-implicit Euler, contacts, impacts, rolling and turning.
- Restitution and friction at a contact
- Drag and gravity: the terminal velocity, at any stiffness
- Impact: two bodies meeting
- The kick: velocity Verlet, second order, an orbit kept, and reversible
- The kick-drift: velocity Verlet's first half
- Stepping an orientation
- The pendulum constraint
- Rolling resistance: slowed to rest, never reversed
- Semi-implicit Euler: first order, and the energy kept
- Restitution and friction at a contact, live
- Drag and gravity, stepped implicitly, live
- Two bodies meeting, live
- Velocity Verlet, live
- The kick-drift, live
- The pendulum constraint, live
- Rolling resistance, live
- Semi-implicit Euler, live
Kinematics¶
Orientation: turning a vector into or out of a body's frame, and a rolling ball's spin.
- A rolling sphere's spin
- Turning a vector
- Turning a vector back
- A rolling sphere's spin, live
- Turning a vector, live
- Turning a vector back, live
Laws¶
Physical laws: gravity and drag, buoyancy, diffusion, elasticity, erosion, pressure, spin and lift, and the standard atmosphere.
- Air exchange
- A reaction's rate constant
- A harmonic bond
- Bulk viscosity
- Buoyancy
- The Coriolis term
- Exchange over a level: diffusion, to the unit
- Gravity and linear drag
- A solid's stress from its strain
- Erosion of a cohesive bed
- A spinning ball's lift coefficient
- The Magnus force
- The Lennard-Jones pair force
- The pressure of a column
- Quadratic drag
- Thermal radiation
- Relaxation toward a profile, in whole steps
- A particle settling through a fluid
- The spin ratio
- The standard atmosphere
- The standard temperature
- Air exchange, live
- A reaction's rate constant, live
- A harmonic bond, live
- Bulk viscosity, live
- Buoyancy, live
- The Coriolis term, live
- Diffusion to the unit, live
- Gravity and linear drag, live
- A solid's stress from its strain, live
- Erosion of a cohesive bed, live
- A spinning ball's lift coefficient, live
- The Magnus force, live
- The Lennard-Jones pair force, live
- The pressure of a column, live
- Quadratic drag, live
- A particle settling through a fluid, live
- The spin ratio, live
- The standard atmosphere, live
- The standard temperature, live
Light¶
Light across a lattice: a directional beam and point sources, with the shadows what stands between casts.
Motion¶
Movement on a lattice by propose and grant: each item asks to move, and each place goes to one.
Properties¶
A material's properties derived from the library's tables: densities and mixtures, the speed of sound, optics, heat flow, and kinetic energy.
- The absorption coefficient: 4πk over the wavelength
- Acoustic impedance: density times the speed of sound
- Fresnel reflectance at an angle, for a conductor or a dielectric
- Reflectance at normal incidence from the complex refractive index
- The density of a gas
- Kinetic energy: half the mass times the speed squared
- The specific heat of a gas mixture
- The density of a condensed mixture
- The molar mass of a mixture
- The Reynolds number
- The speed of sound in a bar: the square root of stiffness over density
- Thermal diffusivity: conductivity over heat capacity per volume
- The absorption coefficient, live
- Acoustic impedance, live
- Fresnel reflectance at an angle, live
- Reflectance at normal incidence, live
- The density of a gas, live
- Kinetic energy, live
- The specific heat of a gas mixture, live
- The density of a condensed mixture, live
- The molar mass of a mixture, live
- The Reynolds number, live
- The speed of sound in a bar, live
- Thermal diffusivity, live
Radiation¶
A black body's light: Planck's law, the power it radiates, and where its spectrum peaks.
- Planck's law: a black body's spectral radiance
- The Stefan–Boltzmann law: the power a black body radiates
- Wien's displacement law: where a black body's spectrum peaks
Rays¶
The rays a source or a direction casts across a lattice, the cells each passes through.
Render¶
Drawing a scene by tracing rays: a camera's rays, what they hit, how surfaces shade, shadows, the sky, haze, surface noise and tone mapping.
- A grass blade from its cell
- The nearest grass blade along a ray
- Bumps
- A pinhole camera's ray
- A ray meeting a region of the ground
- Aerial perspective
- A point in a box
- A point in a cylinder
- A point in a sphere
- Between two steps: lerp
- A ball's contact shadow
- Oren and Nayar's rough diffuse
- Physically based shading
- A renderer's roughness from a surface's GGX alpha
- Fresnel's reflectance by Schlick
- A fibrous surface's sheen
- The sky's radiance
- The sky's light on a surface
- Slerp
- A ray meeting a sphere
- A hard shadow
- A soft shadow
- Tone mapping
- A ray meeting a triangle
- Value noise
- Waves
Sky¶
The sky over a world: the sun, the moon and the stars, sidereal time, and gravity at a height.
- Gravity at an altitude: the inverse square of the distance from the centre
- Equatorial to horizontal
- The moon's position
- The Moon's latitude
- The Moon's longitude
- The moon's phase
- Sidereal time
- The star field
- The sun's position
- Surface gravity: GM over the radius squared
Sound¶
Sound: a sound field across a lattice and a loudness meter.
Space¶
Finding the items near each other: every pair within a radius.
Statistics¶
Summaries over a table: the weighted mean.
Stochastic¶
Chance and spread for a step of any length, from what holds over a period.