Repository navigation
CARLA point distance
extensions.carla.curve_distance compares finite stored Float64 points.
The fixed-s lane query uses this private arithmetic.
It does not change Map queries, geometry evaluation, or trigonometry.
It does not certify the minimum of a continuous curve.
The first path bounds both squared distances after a common positive scale. Adjacent Float64 values bound each potentially inexact elementary operation. Zero and subnormal values receive adjacent representable bounds too. Disjoint bounds decide the order. Overlapping bounds use exact binary products. No epsilon or rounded squared norm converts a positive gap to a tie.
The exact path cancels the common query-square terms. For each coordinate, it sums aa - bb - 2aq + 2bq. It separates the positive and negative products into fixed-size integer accumulators. The sign of their exact difference decides the order.
Each finite Float64 has at most 53 significand bits. Products use four 32-bit limbs, with UInt64 intermediates and explicit carries. The smallest binary product has unit 2^-2148. Each accumulator has 132 limbs, or 4,224 bits. This includes the finite product exponent range, the factor of two, and the sum carry. No floating-point product decides an ambiguous comparison.
The output norm divides component gaps by their largest magnitude before squaring. It multiplies the square root by that scale at the end. A distinct stored point therefore cannot acquire a false zero from a squared-distance underflow. Only the chosen lane's output norm is required.
Near the finite limit, an exact squared-norm comparison checks representability. A true norm above the largest finite Float64 raises an error. This includes a calculation that rounds down to the largest finite value. An in-range norm whose reconstruction overflows returns the largest finite value. The output is an approximation, not a correctly rounded or interval-valued norm API.
Integer geometry and a reproducible Fraction corpus check the comparison. The corpus includes 100 finite binary input triples across the Float64 exponent range. It includes true ties, subnormal perturbations, sign changes, and finite-limit carries. Exact bisection gives a norm bracket independent of the native implementation. The output controls permit four additional ULPs around that bracket. Nonfinite inputs and out-of-range norms must raise.
tools/generate_carla_distance_controls.mojo writes the point corpus, and --check replays it.
Run tools/capture_carla_fixed_s_controls.mojo to capture geometry seeds with the pinned toolchain.
Pass the capture file to tools/generate_carla_fixed_s_controls.mojo to write the road corpus.
Add --check to replay the road corpus without writes.
Both tools write formatted Mojo, so the files need no mojo format.
tests/test_carla_control_replay_tool.mojo replays both corpora.
Tutorials
How-to
Reference
- Scene graph
- Rotations
- Cameras
- Geometry
- Geometry addons
- Lofts and clipping groups
- Sculptor
- Procedural generators
- Meshes and assets
- Lines
- Points and sprites
- Helpers
- Scene objects
- Animated objects
- Raycasting
- Curves and paths
- Animation
- Skinning
- Materials
- Node materials
- TSL functions
- Lights
- Lighting addons
- Fog
- Textures
- Renderer
- Renderer hooks and material flags
- Rasterization
- GPU backend
- Render target
- Post-processing
- GPU computation
- Compute nodes
- Progressive light map
- Gaussian splats
- Voxel global illumination
- SVG renderer
- Image files
- Image decode queue
- Model files
- More model files
- Exporters
- Scene JSON
- Windowing and controls
- Math
- Norm consumers
- Math addons
- Units
- Coverage tool
- Commands
- Examples
- Benchmarks
- Extensions
- Shared physics
- Physics query snapshots
- Continuous collision
- Tick force restoration
- Water
- Animals
- Buildings
- CARLA
- Femur
- Tibia
- Fibula
- Patella
- Knee
- Muscles
- Vessels
- Lymph
- Nerves
- Integument
- Leg
- Foot
- Pelvis
- Torso
- Arm
- Hand
- Head
- Genome
- Game humanoid
- Humanoid fidelity
- Audio-aligned game faces
- Converted assets
- Mesh quality
- Segment inertia
Explanation
- Software rasterizer
- Scene graph as an array
- Linear color
- Normals are not colors
- Perspective correction
- Fixed-point coverage
- Per-fragment shading
- Mipmaps
- Sorted transparency
- Types and checks
- Render hooks as a trait
- Shared CPU and GPU code
- Bands and threads
- PNG structure
- Extensions beside the port
- CUDA teardown hang
- Mojo compiler hang