Rotation2d
- class wpimath.Rotation2d(*args, **kwargs)
Bases:
pybind11_objectA rotation in a 2D coordinate frame represented by a point on the unit circle (cosine and sine).
Overloaded function.
__init__(self: wpimath._wpimath.Rotation2d) -> None
Constructs a Rotation2d with a default angle of 0 degrees.
__init__(self: wpimath._wpimath.Rotation2d, value: wpimath.units.radians) -> None
Constructs a Rotation2d with the given radian value. :param value: The value of the angle in radians.
__init__(self: wpimath._wpimath.Rotation2d, x: typing.SupportsFloat | typing.SupportsIndex, y: typing.SupportsFloat | typing.SupportsIndex) -> None
Constructs a Rotation2d with the given x and y (cosine and sine) components. The x and y don’t have to be normalized.
- Parameters:
x – The x component or cosine of the rotation.
y – The y component or sine of the rotation.
- WPIStruct = <capsule object "WPyStruct">
- cos() float
Returns the cosine of the rotation.
- Returns:
The cosine of the rotation.
- degrees() wpimath.units.degrees
Returns the degree value of the rotation constrained within [-180, 180].
- Returns:
The degree value of the rotation constrained within [-180, 180].
- static fromDegrees(value: wpimath.units.degrees) wpimath._wpimath.Rotation2d
- static fromMatrix(rotationMatrix: Annotated[numpy.typing.ArrayLike, numpy.float64, '[2, 2]']) wpimath._wpimath.Rotation2d
Constructs a Rotation2d from a rotation matrix.
- Parameters:
rotationMatrix – The rotation matrix. @throws std::domain_error if the rotation matrix isn’t special orthogonal.
- static fromRotations(arg0: wpimath.units.turns) wpimath._wpimath.Rotation2d
- radians() wpimath.units.radians
Returns the radian value of the rotation constrained within [-π, π].
- Returns:
The radian value of the rotation constrained within [-π, π].
- relativeTo(other: wpimath._wpimath.Rotation2d) wpimath._wpimath.Rotation2d
Returns the current rotation relative to the given rotation.
- Parameters:
other – The rotation describing the orientation of the new coordinate frame that the current rotation will be converted into.
- Returns:
The current rotation relative to the new orientation of the coordinate frame.
- rotateBy(other: wpimath._wpimath.Rotation2d) wpimath._wpimath.Rotation2d
Adds the new rotation to the current rotation using a rotation matrix.
[cos_new] [other.cos, -other.sin][cos] [sin_new] = [other.sin, other.cos][sin] value_new = std::atan2(sin_new, cos_new)
- Parameters:
other – The rotation to rotate by.
- Returns:
The new rotated Rotation2d.
- sin() float
Returns the sine of the rotation.
- Returns:
The sine of the rotation.
- tan() float
Returns the tangent of the rotation.
- Returns:
The tangent of the rotation.
- toMatrix() Annotated[numpy.typing.NDArray[numpy.float64], '[2, 2]']
Returns matrix representation of this rotation.