# Rotation2d

class wpimath.geometry.Rotation2d(*args, **kwargs)

Bases: `pybind11_object`

A rotation in a 2D coordinate frame represented by a point on the unit circle (cosine and sine).

The angle is continuous, that is if a Rotation2d is constructed with 361 degrees, it will return 361 degrees. This allows algorithms that wouldn’t want to see a discontinuity in the rotations as it sweeps past from 360 to 0 on the second time around.

1. __init__(self: wpimath.geometry._geometry.Rotation2d) -> None

Constructs a Rotation2d with a default angle of 0 degrees.

1. __init__(self: wpimath.geometry._geometry.Rotation2d, value: wpimath.units.radians) -> None

Constructs a Rotation2d with the given radian value. :param value: The value of the angle in radians.

1. __init__(self: wpimath.geometry._geometry.Rotation2d, x: float, y: float) -> 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.

Returns:

The degree value of the rotation. @see InputModulus to constrain the angle within (-180, 180]

static fromDegrees(value: wpimath.units.degrees)
static fromRotations(arg0: wpimath.units.turns)

Returns the radian value of the rotation.

Returns:

The radian value of the rotation. @see AngleModulus to constrain the angle within (-pi, pi]

rotateBy(other: wpimath.geometry._geometry.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.