Point2D

data class Point2D(val x: Double, val y: Double)(source)

A 2D point, used by the agent layer's spatial projections.

Defined here as a lightweight data class independent of KSL's existing ksl.modeling.spatial.LocationIfc hierarchy, which couples locations to a SpatialModel. Phase 3 of the agent layer introduces its own Context/Projection model that doesn't depend on SpatialModel; integration between the two systems is deferred to a future phase.

Equality note: as a data class, == uses Double.equals per component, which follows IEEE-754 corner cases — Point2D(-0.0, 0.0) != Point2D(0.0, 0.0), and any point containing NaN is not equal to itself. For position comparisons prefer distanceTo with a tolerance rather than ==.

Constructors

Link copied to clipboard
constructor(x: Double, y: Double)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Magnitude of this point treated as a vector from the origin.

Link copied to clipboard
val x: Double
Link copied to clipboard
val y: Double

Functions

Link copied to clipboard

Euclidean distance to other. Uses Math.hypot for numerical stability when one coordinate is much larger than the other.

Link copied to clipboard
operator fun minus(other: Point2D): Point2D
Link copied to clipboard

Unit vector in the same direction as this point (treated as a vector from the origin). Returns the origin if this point is the origin (no canonical direction).

Link copied to clipboard
operator fun plus(other: Point2D): Point2D
Link copied to clipboard

Squared Euclidean distance to other. Faster than distanceTo when only comparison is needed (no square root).

Link copied to clipboard
operator fun times(scalar: Double): Point2D