Point2D
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 ==.
Properties
Functions
Euclidean distance to other. Uses Math.hypot for numerical stability when one coordinate is much larger than the other.
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).
Squared Euclidean distance to other. Faster than distanceTo when only comparison is needed (no square root).