Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/saquer916/odyssey/llms.txt

Use this file to discover all available pages before exploring further.

Vector2d is an immutable 2D vector used throughout Odyssey for positions, tangents, and accelerations. Because every field is final and every operation returns a new Vector2d, instances are safe to share freely between components without defensive copying. The class is the foundation for Pose2d geometry operations, Bézier curve point and tangent evaluation, and all HeadingInterpolator computations. Package: org.firstinspires.ftc.teamcode.odyssey.geometry

Constructor

Vector2d(double x, double y)
constructor
Creates an immutable vector from explicit x and y components.
x
double
required
X component of the vector.
y
double
required
Y component of the vector.

Methods

Accessors

getX()
double
Returns the x component of the vector.
getY()
double
Returns the y component of the vector.
getMagnitude()
double
Returns the Euclidean length of the vector, computed as Math.hypot(x, y). This is numerically stable for very large or very small components.
getAngleFromCur()
double
Returns the angle from the positive x-axis to this vector, computed as Math.atan2(y, x). The result is in radians in the range (−π, π].

Arithmetic operations

add(Vector2d other)
Vector2d
Returns a new Vector2d whose components are the element-wise sum of this vector and other.
other
Vector2d
required
Vector to add.
subtract(Vector2d other)
Vector2d
Returns a new Vector2d whose components are this vector minus other component-wise.
other
Vector2d
required
Vector to subtract.
scale(double factor)
Vector2d
Returns a new Vector2d with both components multiplied by factor. Equivalent to scalar multiplication.
factor
double
required
Scalar multiplier.
normalize()
Vector2d
Returns the unit vector in the same direction. If the magnitude is exactly 0.0, returns Vector2d(0, 0) instead of throwing a divide-by-zero error.

Geometric operations

rotateVector(double theta)
Vector2d
Returns this vector rotated by theta radians counter-clockwise, using the standard 2D rotation matrix:
double newX = x * Math.cos(theta) - y * Math.sin(theta);
double newY = x * Math.sin(theta) + y * Math.cos(theta);
Rotation preserves the vector’s magnitude. Used internally by Pose2d.toRobotFrame and Pose2d.toFieldFrame.
theta
double
required
Rotation angle in radians, counter-clockwise positive.
dotProduct(Vector2d other)
double
Returns the scalar dot product x·other.x + y·other.y. A result of 0 means the vectors are perpendicular.
other
Vector2d
required
Second vector operand.
crossProduct(Vector2d other)
double
Returns the 2D cross product as a scalar: x·other.y − y·other.x. A positive result means other is counter-clockwise from this; negative means clockwise.
other
Vector2d
required
Second vector operand.

Example

Vector2d a = new Vector2d(3, 4);
double mag = a.getMagnitude();       // 5.0
Vector2d unit = a.normalize();       // (0.6, 0.8)
Vector2d rotated = a.rotateVector(Math.PI / 2); // ≈ (-4.0, 3.0)

Vector2d b = new Vector2d(1, 0);
Vector2d c = new Vector2d(0, 1);
double dot   = b.dotProduct(c);      // 0.0  (perpendicular)
double cross = b.crossProduct(c);    // 1.0  (c is CCW from b)
All Vector2d instances are immutable. Methods like add, scale, and rotateVector always return a new Vector2d — they never modify the receiver. Hold on to the returned value; discarding it silently loses the result.

Build docs developers (and LLMs) love