geometry
The pure maths of a closed race track drawn as a curve. It turns control points into a smooth closed Catmull-Rom loop, resamples it evenly, and derives frames, arc length, checkpoint gates (gate 1 is the start/finish line) and a staggered two-column grid behind the line. It makes…
geometry
The pure maths of a closed race track drawn as a curve. It turns control points into a smooth closed Catmull-Rom loop, resamples it evenly, and derives frames, arc length, checkpoint gates (gate 1 is the start/finish line) and a staggered two-column grid behind the line. It makes no engine calls, so every peer computes the same track from the same points and the test suite can check it directly. RaceTrack, build, Racer, RaceAI and api all read tracks through it.
Functions
track(points, opts?): a whole track from control points:samples,tangents,rights,s,length,spacing,width,gates,grid,control. Options:width,checkpoints,spacing,gridSlots,reverse.at(track, dist): point, forward and rightdistmetres along the track (wraps; negative goes back from the start).nearest(track, pos, hint?): nearest sample index, arc length at it and signed lateral offset right of the centre;hintsearches near a known index first.curvatures(track, span?): signed curvature (1/m, + turns right) at each sample.resample(ctrl, spacing): evenly spaced points along the closed smooth curve throughctrl.encodePoints(points)/decodePoints(s): points to and from the"x,y,z;x,y,z"string RaceTrack syncs.yawOf(dir): yaw in radians turning the engine's forward (-Z) ontodir.yawQuat(yaw): quaternion {x, y, z, w} for a yaw.flatNorm(v),toVec(p): helpers: a horizontal unit vector, and a vector from {x,y,z} or a vector.
Scoped to this part · feeds back into the world's score.