Expand description
Distance, angle, mass and time newtypes and their unit conversions.
The game mixes several distance units: real meters, GameParams BigWorld units (1 unit = 30 m), replay world units (1 unit = 15 m, what packet positions and radii are in), ship-model units (1 unit = 15 m, used by hull geometry), plus kilometers and millimeters. These newtypes keep units honest at the type level; cross-unit arithmetic and comparison convert to a common unit.
BigWorldDistance and WorldDistance are two different spaces that a
name alone will not keep apart, and they differ by exactly 2. Read each
type’s doc before reaching for either.
Degrees and Radians serve the same purpose for angles: GameParams
states ricochet, normalization and impact angles in degrees, while every
trigonometric step wants radians.
Structs§
- BigWorld
Distance - Distance in the coordinate units GameParams uses (1 unit = 30 meters):
consumable
distShip/distTorpedo, projectilemaxDist, and the other range fields read off the ship dict. - Degrees
- An angle in degrees. GameParams states every angle in degrees.
- Kilograms
- Mass in kilograms.
- Km
- Distance in kilometers.
- Meters
- Distance in meters.
- Meters
PerSecond - Speed in meters per second (shell muzzle velocity).
- Millimeters
- Distance in millimeters.
- Radians
- An angle in radians. Trigonometry is only defined on this type, so a value
in degrees cannot reach
cos/sinwithout an explicit conversion. - Seconds
- A duration in seconds.
- Ship
Model Distance - Distance in ship-model coordinate units (1 unit = 15 meters). Hull geometry
uses this space:
.visualnode matrices, the.skel_extnodes hung off them, and the meshes they position. - World
Distance - Distance in the coordinate units a replay packet stream is in (1 unit = 15 meters): entity positions, shell impact points, and any offset between two of them.