Geometry

object Geometry

Defines useful conversion methods for RoadRunner geometry types, restoring some removed methods from RoadRunner v0.5.

This class was created for migration purposes between RoadRunner v0.5 and v1.0, where new types were introduced and some methods removed, but these methods are still useful within BunyipsLib.

Author

Lucas Bubner, 2024

Since

6.0.0

Functions

Link copied to clipboard
infix fun Pose2d.approx(other: Pose2d): Boolean

Compare two poses with an epsilon value.

infix fun Vector2d.approx(other: Vector2d): Boolean

Compare two vectors with an epsilon value.

Link copied to clipboard
infix fun Pose2d.approxNormHeading(other: Pose2d): Boolean

Compare two poses with an epsilon value plus a renormalisation of heading.

Link copied to clipboard
infix fun Vector2d.distTo(other: Vector2d): Double

Calculate the distance between two vectors.

Link copied to clipboard
infix fun Vector2d.inchesFrom(unit: Distance): Vector2d

Create a vector in the desired units to be converted to a conventional Inches unit.

Link copied to clipboard
fun Pose2d.lerp(other: Pose2d, t: Double): Pose2d

Linearly interpolate between two poses. The t parameter is not clamped between 0-1.

fun Rotation2d.lerp(other: Rotation2d, t: Double): Rotation2d

Linearly interpolate between two rotations. The t parameter is not clamped between 0-1. Rotation value will take the shortest path.

fun Vector2d.lerp(other: Vector2d, t: Double): Vector2d

Linearly interpolate between two vectors. The t parameter is not clamped between 0-1.

Link copied to clipboard
fun Rotation2d.moveTowards(other: Rotation2d, stepSize: Measure<Angle>): Rotation2d

Move a rotation towards another rotation by a step size.

fun Vector2d.moveTowards(other: Vector2d, stepSizeInches: Double): Vector2d

Move a vector towards another vector by a step size.

fun Pose2d.moveTowards(other: Pose2d, stepSizeInches: Double, stepSizeRad: Double): Pose2d

Move a pose towards another pose by a step size.

Link copied to clipboard
fun Vector2d.poseFrom(tUnit: Distance = Inches, r: Double, rUnit: Angle): Pose2d

Create a pose in the desired units to be converted to conventional Inches and Radians units.

Link copied to clipboard
fun Pose2d.smoothDamp(target: Pose2d, currentVelocity: Reference<Double>, smoothTime: Measure<Time>, maxVelocity: Number, deltaTime: Measure<Time>): Pose2d

Smoothly damp a pose towards another pose. Velocity will be in degrees per second.

fun Rotation2d.smoothDamp(target: Rotation2d, currentVelocity: Reference<Double>, smoothTime: Measure<Time>, maxVelocity: Number, deltaTime: Measure<Time>): Rotation2d

Smoothly damp a rotation towards another rotation. Velocity will be in degrees per second.

fun Vector2d.smoothDamp(target: Vector2d, currentVelocity: Reference<Double>, smoothTime: Measure<Time>, maxVelocity: Number, deltaTime: Measure<Time>): Vector2d

Smoothly damp a vector towards another vector.

Link copied to clipboard

Returns a user-friendly representation of a Pose2d.

Link copied to clipboard
fun vel(xVel: Double, yVel: Double, angVel: Double): PoseVelocity2d

Create a new PoseVelocity2d with x, y, and heading values.

Link copied to clipboard
fun zeroPose(): Pose2d

Create a new Pose2d with zero values.

Link copied to clipboard
fun zeroTwist(): Twist2d

Create a new Twist2d with zero values.

Link copied to clipboard
fun zeroVec(): Vector2d

Create a new Vector2d with zero values.

Link copied to clipboard
fun zeroVel(): PoseVelocity2d

Create a new PoseVelocity2d with zero values.