Add requirement on non-emptiness of composite trajectory parts list.

This commit is contained in:
Gleb Minaev 2024-07-08 18:08:54 +03:00
parent e913874ace
commit 498db37a7c

View File

@ -179,6 +179,10 @@ public fun CircleTrajectory2D(
@Serializable
@SerialName("composite")
public class CompositeTrajectory2D(public val segments: List<Trajectory2D>) : 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