Point3D

data class Point3D(val x: Double, val y: Double, val z: Double)(source)

A 3D point, used by the agent layer's volumetric projections (introduced in Phase 6 for UAV / drone modeling).

Mirrors Point2D in shape — same arithmetic operators, same magnitude / normalized() / distance helpers — extended to a third axis. The third coordinate is named z and conventionally represents altitude in drone models, but the type is geometry- agnostic: any 3D Cartesian context works.

Defined as a lightweight data class independent of KSL's existing ksl.modeling.spatial.LocationIfc hierarchy, matching the design decision in Point2D. Integration with a 3D spatial-layer model is deferred (see §13.5 of the agent-based- modeling design doc — the GPS / lat-lon use case is unsupported by this phase).

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

Constructors

Link copied to clipboard
constructor(x: Double, y: Double, z: 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
Link copied to clipboard
val z: Double

Functions

Link copied to clipboard
fun cross(other: Point3D): Point3D

Cross product with other, treating both as vectors from the origin. Returns the right-hand-rule perpendicular: (this × other). Order matters — a × b = -(b × a).

Link copied to clipboard

Euclidean distance to other. Uses a numerically-stable form that avoids overflow for very large coordinates: factor out the largest absolute component, then take the root of the sum of squared ratios.

Link copied to clipboard
fun dot(other: Point3D): Double

Dot product with other, treating both as vectors from the origin.

Link copied to clipboard
operator fun minus(other: Point3D): Point3D
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: Point3D): Point3D
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): Point3D