From ada1141738328101da29f48af4ba71bc8fca2d30 Mon Sep 17 00:00:00 2001 From: Erik Schouten Date: Fri, 15 Jul 2022 18:57:10 +0200 Subject: [PATCH] Use Line distancTo function --- .../kotlin/space/kscience/kmath/trajectory/segments/Line.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kmath-trajectory/src/commonMain/kotlin/space/kscience/kmath/trajectory/segments/Line.kt b/kmath-trajectory/src/commonMain/kotlin/space/kscience/kmath/trajectory/segments/Line.kt index f63372016..b3e93b5ed 100644 --- a/kmath-trajectory/src/commonMain/kotlin/space/kscience/kmath/trajectory/segments/Line.kt +++ b/kmath-trajectory/src/commonMain/kotlin/space/kscience/kmath/trajectory/segments/Line.kt @@ -1,5 +1,6 @@ package space.kscience.kmath.trajectory.segments +import space.kscience.kmath.geometry.Euclidean2DSpace.distanceTo import space.kscience.kmath.geometry.Line2D import space.kscience.kmath.operations.DoubleField.pow import kotlin.math.PI @@ -17,7 +18,7 @@ internal val Line2D.theta: Double get() = atan2(direction.x - base.x, direction.y - base.y).theta internal val Line2D.length: Double - get() = sqrt((direction.x - base.x).pow(2) + (direction.y - base.y).pow(2)) + get() = base.distanceTo(direction) internal val Double.theta: Double get() = (this + (2 * PI)) % (2 * PI)