Skip to content

Commit

Permalink
Move second map out of PoseMap
Browse files Browse the repository at this point in the history
`PoseMap` is intended to be a SAM, and the `map()` overload is only
there for convenience. Making it an extension method cleans up the
interface. If performance is an issue, it can safely be moved back
into the interface.
  • Loading branch information
rbrott committed Dec 4, 2023
1 parent a25ccb0 commit 0414fde
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/kotlin/com/acmerobotics/roadrunner/Builders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,10 @@ class PathBuilder private constructor(

fun interface PoseMap {
fun map(pose: Pose2dDual<Arclength>): Pose2dDual<Arclength>
fun map(pose: Pose2d) = map(Pose2dDual.constant(pose, 1)).value()
}

fun PoseMap.map(pose: Pose2d) = map(Pose2dDual.constant(pose, 1)).value()

class IdentityPoseMap : PoseMap {
override fun map(pose: Pose2dDual<Arclength>) = pose
}
Expand Down

0 comments on commit 0414fde

Please sign in to comment.