Source code for sym.ops.rot2.group_ops
# -----------------------------------------------------------------------------
# This file was autogenerated by symforce from template:
# ops/CLASS/group_ops.py.jinja
# Do NOT modify by hand.
# -----------------------------------------------------------------------------
# ruff: noqa: PLR0915, F401, PLW0211, PLR0914
from __future__ import annotations
import math
import typing as T
import numpy
import sym
[docs]
class GroupOps(object):
"""
Python GroupOps implementation for :py:class:`symforce.geo.rot2.Rot2`.
"""
[docs]
@staticmethod
def identity() -> sym.Rot2:
# Total ops: 0
# Input arrays
# Intermediate terms (0)
# Output terms
_res = sym.Rot2.from_storage([1, 0])
return _res
[docs]
@staticmethod
def inverse(a: sym.Rot2) -> sym.Rot2:
# Total ops: 1
# Input arrays
_a = a.data
# Intermediate terms (0)
# Output terms
_res = sym.Rot2.from_storage([_a[0], -_a[1]])
return _res
[docs]
@staticmethod
def compose(a: sym.Rot2, b: sym.Rot2) -> sym.Rot2:
# Total ops: 6
# Input arrays
_a = a.data
_b = b.data
# Intermediate terms (0)
# Output terms
_res = sym.Rot2.from_storage([_a[0] * _b[0] - _a[1] * _b[1], _a[0] * _b[1] + _a[1] * _b[0]])
return _res
[docs]
@staticmethod
def between(a: sym.Rot2, b: sym.Rot2) -> sym.Rot2:
# Total ops: 6
# Input arrays
_a = a.data
_b = b.data
# Intermediate terms (0)
# Output terms
_res = sym.Rot2.from_storage([_a[0] * _b[0] + _a[1] * _b[1], _a[0] * _b[1] - _a[1] * _b[0]])
return _res
[docs]
@staticmethod
def inverse_with_jacobian(a: sym.Rot2) -> tuple[sym.Rot2, numpy.ndarray]:
# Total ops: 5
# Input arrays
_a = a.data
# Intermediate terms (0)
# Output terms
_res = sym.Rot2.from_storage([_a[0], -_a[1]])
_res_D_a = numpy.zeros(1)
_res_D_a[0] = -(_a[0] ** 2) - _a[1] ** 2
return _res, _res_D_a
[docs]
@staticmethod
def compose_with_jacobians(
a: sym.Rot2, b: sym.Rot2
) -> tuple[sym.Rot2, numpy.ndarray, numpy.ndarray]:
# Total ops: 11
# Input arrays
_a = a.data
_b = b.data
# Intermediate terms (5)
_tmp0 = _a[0] * _b[0] - _a[1] * _b[1]
_tmp1 = _a[0] * _b[1]
_tmp2 = _a[1] * _b[0]
_tmp3 = _tmp1 + _tmp2
_tmp4 = _tmp0**2 - _tmp3 * (-_tmp1 - _tmp2)
# Output terms
_res = sym.Rot2.from_storage([_tmp0, _tmp3])
_res_D_a = numpy.zeros(1)
_res_D_a[0] = _tmp4
_res_D_b = numpy.zeros(1)
_res_D_b[0] = _tmp4
return _res, _res_D_a, _res_D_b
[docs]
@staticmethod
def between_with_jacobians(
a: sym.Rot2, b: sym.Rot2
) -> tuple[sym.Rot2, numpy.ndarray, numpy.ndarray]:
# Total ops: 15
# Input arrays
_a = a.data
_b = b.data
# Intermediate terms (6)
_tmp0 = _a[0] * _b[0]
_tmp1 = _a[1] * _b[1]
_tmp2 = _tmp0 + _tmp1
_tmp3 = _a[0] * _b[1]
_tmp4 = _a[1] * _b[0]
_tmp5 = _tmp3 - _tmp4
# Output terms
_res = sym.Rot2.from_storage([_tmp2, _tmp5])
_res_D_a = numpy.zeros(1)
_res_D_a[0] = _tmp2 * (-_tmp0 - _tmp1) - _tmp5**2
_res_D_b = numpy.zeros(1)
_res_D_b[0] = _tmp2**2 - _tmp5 * (-_tmp3 + _tmp4)
return _res, _res_D_a, _res_D_b