diff --git a/trajectory-kt/src/commonMain/kotlin/space/kscience/trajectory/Trajectory2D.kt b/trajectory-kt/src/commonMain/kotlin/space/kscience/trajectory/Trajectory2D.kt index ddf7a67..9cd69a3 100644 --- a/trajectory-kt/src/commonMain/kotlin/space/kscience/trajectory/Trajectory2D.kt +++ b/trajectory-kt/src/commonMain/kotlin/space/kscience/trajectory/Trajectory2D.kt @@ -179,6 +179,10 @@ public fun CircleTrajectory2D( @Serializable @SerialName("composite") public class CompositeTrajectory2D(public val segments: List) : Trajectory2D { + init { + require(segments.isNotEmpty()) { "A composite trajectory cannot consist of an empty list of trajectories" } + } + override val length: Double get() = segments.sumOf { it.length } override val beginPose: Pose2D get() = segments.first().beginPose