Documentation
¶
Index ¶
- func IsNegativeDirection(dir Direction) bool
- func IsPositiveDirection(dir Direction) bool
- type Direction
- type Distance
- func (d Distance) Abs() Distance
- func (d Distance) Clamp(min, max Distance) Distance
- func (d Distance) Equal(other Distance) bool
- func (d Distance) Greater(other Distance) bool
- func (d Distance) GreaterOrEqual(other Distance) bool
- func (d Distance) Kilometers() float64
- func (d Distance) Less(other Distance) bool
- func (d Distance) LessOrEqual(other Distance) bool
- func (d Distance) Meters() float64
- func (d Distance) Millimeters() float64
- func (d Distance) String() string
- type Speed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNegativeDirection ¶
func IsPositiveDirection ¶
Types ¶
type Distance ¶
type Distance float64
Distance represents a distance in meters. This is the base unit for all spatial measurements in the simulation.
Distance unit constants for multiplication.
Usage:
d := 5 * spatial.Kilometer // 5000 m d := 1500 * spatial.Millimeter // 1.5 m d := spatial.Distance(123.456) // 123.456 m
const DistanceEpsilon Distance = 0.5
DistanceEpsilon is the tolerance for PK comparison (50cm). PK values are expected to be 1 meter precise, so 0.5m tolerance handles rounding.
func ParsePK ¶
ParsePK parses a PK (point kilométrique) string in the format "XXX+YYY" or "XXX-YYY" where XXX is kilometers and YYY is meters. - "123+456" means 123 km + 456 m = 123456 m - "123-456" means 123 km - 456 m = 122544 m
func (Distance) Equal ¶
Equal returns true if the two distances are within DistanceEpsilon of each other. Use this instead of == for PK comparisons.
func (Distance) Greater ¶
Greater returns true if d is strictly greater than other (with epsilon tolerance). Returns true if d > other + DistanceEpsilon.
func (Distance) GreaterOrEqual ¶
GreaterOrEqual returns true if d is greater than or approximately equal to other. Returns true if d > other - DistanceEpsilon.
func (Distance) Kilometers ¶
Kilometers returns the distance in kilometers.
func (Distance) Less ¶
Less returns true if d is strictly less than other (with epsilon tolerance). Returns true if d < other - DistanceEpsilon.
func (Distance) LessOrEqual ¶
LessOrEqual returns true if d is less than or approximately equal to other. Returns true if d < other + DistanceEpsilon.
func (Distance) Millimeters ¶
Millimeters returns the distance in millimeters.
type Speed ¶
type Speed float64
Speed represents a speed in meters per second. This is the base unit for all velocity measurements in the simulation.
Speed unit constants for multiplication.
Usage:
s := 120 * spatial.KilometerPerHour // 120 km/h ≈ 33.33 m/s s := 30 * spatial.MeterPerSecond // 30 m/s s := spatial.SpeedFromKmh(300) // 300 km/h
func DistancePerDuration ¶
DistancePerDuration calculates the speed from a distance and duration.
func SpeedFromKmh ¶
SpeedFromKmh creates a Speed from kilometers per hour.
func SpeedFromMps ¶
SpeedFromMps creates a Speed from meters per second. This is an identity function provided for clarity.
func (Speed) DistanceIn ¶
DistanceIn returns the distance traveled at this speed over the given duration.