Twist2d

data class Twist2d(val line: Vector2d<DistanceUnit>, val angle: Double)(source)

Represents a differential twist in 2D: a combination of linear and angular displacement.

A twist is an element of the Lie algebra \(\mathfrak{se}(2)\), the tangent space of SE(2). It represents an infinitesimal transformation consisting of:

  • Linear displacement: \(\mathbf{v}\) - translation component

  • Angular displacement: \(\theta\) - rotation component (as a Rotation2d)

Relationship to Velocity

A twist can be thought of as a "velocity × time" - it represents the displacement that would result from moving with a constant velocity for a unit time.

Exponential Map

The exponential map converts a twist to a pose: \(\exp: \mathfrak{se}(2) \to SE(2)\)

This allows us to compute the pose resulting from a given displacement.

Example Usage

// Create a twist: move forward 1 inch and rotate 45 degrees
val twist = Twist2d(
Vector2d(1.0.inches, 0.0.inches),
Math.PI / 4
)

// Convert twist to pose
val pose = Pose2d.exp(twist)

// Add twist to existing pose
val newPose = currentPose + twist

Constructors

Link copied to clipboard
constructor(line: Vector2d<DistanceUnit>, angle: Double)
constructor(x: Distance, y: Distance, angle: Rotation2d)

Constructs a Twist2d from x and y distance measurements and a rotation.

constructor(x: Distance, y: Distance, angle: Angle)

Constructs a Twist2d from x and y distance measurements and an angle measurement.

constructor(x: Double, y: Double, angle: Rotation2d)

Constructs a Twist2d from x and y coordinates (in inches) and a rotation.

constructor(x: Double, y: Double, angle: Double)

Constructs a Twist2d from x and y coordinates (in inches) and an angle (in radians).

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

angular displacement as a rotation

Link copied to clipboard

linear displacement vector

Functions

Link copied to clipboard
operator fun div(scalar: Double): Twist2d

Divides the twist by a scalar.

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

Linear interpolation (lerp) toward another twist.

Link copied to clipboard
operator fun minus(other: Twist2d): Twist2d

Subtracts two twists component-wise (Lie algebra subtraction).

Link copied to clipboard
operator fun plus(other: Twist2d): Twist2d

Adds two twists component-wise (Lie algebra addition).

Link copied to clipboard
operator fun times(scalar: Double): Twist2d

Multiplies the twist by a scalar (useful for scaling displacements).

Link copied to clipboard
operator fun unaryMinus(): Twist2d

Negates the twist.