Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Rot2

A gtsam.Rot2 represents rotation in 2D space. It models a 2D rotation in the Special Orthogonal Group SO(2)\text{SO}(2).

Open In Colab

Initialization and properties

A Rot2 can be initialized with no arguments, which yields the identity rotation, or it can be constructed from an angle in radians, degrees, cos-sin form, or the bearing or arctangent of a 2D point. Rot2 uses radians to communicate angle by default.

Identities:
0.0
0.0
Radians:
1.5707963267948966
1.5707963267948966
Degrees:
1.5707963267948966
Cos-Sin:
0.5235987755982988
Bearing:
0.7853981633974483
0.7853981633974483

The following properties are available from the standard interface:

  • theta() (in radians)

  • degrees()

  • c() (the cosine value, precalculated)

  • s() (the sine value, precalculated)

  • matrix() (the 2x2 rotation matrix: [cos⁡θ−sin⁡θsin⁡θcos⁡θ]\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix})

theta: 2.35619

Radians: 2.356194490192345
Degrees: 135.0
Cosine: -0.7071067811865475
Sine: 0.7071067811865476
Matrix:
[[-0.70710678 -0.70710678]
 [ 0.70710678 -0.70710678]]

Basic operations

For basic use, a Rot2 can rotate and unrotate a point.

Rotated: [-2.82842712e+00  2.22044605e-16]
Unrotated: [-2.  2.]
Unrotated again: [-2.22044605e-16  2.82842712e+00]

Also, the equals() function allows for comparison of two Rot2 objects with a tolerance.

True
False

Lie group SO(2)\text{SO}(2)

Group operations

Rot2 implements the group operations inverse, compose, between and identity. For more information on groups and their use here, see GTSAM concepts.

Inverse:
theta: -0.523599

Compose:
theta: 1.5708

theta: 1.5708

Between:
theta: 0.523599

Identity:
theta: 0

Lie group operations

Rot2 implements the Lie group operations for exponential mapping and log mapping. For more information on Lie groups and their use here, see GTSAM concepts.

theta: 1.5708

theta: 3.14159

[1.57079633]
[-0.78539816]
[-0.78539816]