Source code for sym.ops.unit3.group_ops

# -----------------------------------------------------------------------------
# This file was autogenerated by symforce from template:
#     ops/CLASS/group_ops.py.jinja
# Do NOT modify by hand.
# -----------------------------------------------------------------------------

import math
import typing as T

import numpy

import sym  # pylint: disable=useless-suppression,unused-import


[docs]class GroupOps(object): """ Python GroupOps implementation for :py:class:`symforce.geo.unit3.Unit3`. """
[docs] @staticmethod def identity(): # type: () -> sym.Unit3 # Total ops: 0 # Input arrays # Intermediate terms (0) # Output terms _res = [0.0] * 4 _res[0] = 0 _res[1] = 0 _res[2] = 0 _res[3] = 1 return sym.Unit3.from_storage(_res)
[docs] @staticmethod def inverse(a): # type: (sym.Unit3) -> sym.Unit3 # Total ops: 3 # Input arrays _a = a.data # Intermediate terms (0) # Output terms _res = [0.0] * 4 _res[0] = -_a[0] _res[1] = -_a[1] _res[2] = -_a[2] _res[3] = _a[3] return sym.Unit3.from_storage(_res)
[docs] @staticmethod def compose(a, b): # type: (sym.Unit3, sym.Unit3) -> sym.Unit3 # Total ops: 28 # Input arrays _a = a.data _b = b.data # Intermediate terms (0) # Output terms _res = [0.0] * 4 _res[0] = _a[0] * _b[3] + _a[1] * _b[2] - _a[2] * _b[1] + _a[3] * _b[0] _res[1] = -_a[0] * _b[2] + _a[1] * _b[3] + _a[2] * _b[0] + _a[3] * _b[1] _res[2] = _a[0] * _b[1] - _a[1] * _b[0] + _a[2] * _b[3] + _a[3] * _b[2] _res[3] = -_a[0] * _b[0] - _a[1] * _b[1] - _a[2] * _b[2] + _a[3] * _b[3] return sym.Unit3.from_storage(_res)
[docs] @staticmethod def between(a, b): # type: (sym.Unit3, sym.Unit3) -> sym.Unit3 # Total ops: 28 # Input arrays _a = a.data _b = b.data # Intermediate terms (0) # Output terms _res = [0.0] * 4 _res[0] = -_a[0] * _b[3] - _a[1] * _b[2] + _a[2] * _b[1] + _a[3] * _b[0] _res[1] = _a[0] * _b[2] - _a[1] * _b[3] - _a[2] * _b[0] + _a[3] * _b[1] _res[2] = -_a[0] * _b[1] + _a[1] * _b[0] - _a[2] * _b[3] + _a[3] * _b[2] _res[3] = _a[0] * _b[0] + _a[1] * _b[1] + _a[2] * _b[2] + _a[3] * _b[3] return sym.Unit3.from_storage(_res)
[docs] @staticmethod def inverse_with_jacobian(a): # type: (sym.Unit3) -> T.Tuple[sym.Unit3, numpy.ndarray] # Total ops: 18 # Input arrays _a = a.data # Intermediate terms (5) _tmp0 = _a[0] ** 2 _tmp1 = _a[1] ** 2 _tmp2 = _a[2] ** 2 - _a[3] ** 2 _tmp3 = 2 * _a[2] * _a[3] _tmp4 = 2 * _a[0] * _a[1] # Output terms _res = [0.0] * 4 _res[0] = -_a[0] _res[1] = -_a[1] _res[2] = -_a[2] _res[3] = _a[3] _res_D_a = numpy.zeros((2, 2)) _res_D_a[0, 0] = _tmp0 - _tmp1 + _tmp2 _res_D_a[1, 0] = -_tmp3 + _tmp4 _res_D_a[0, 1] = _tmp3 + _tmp4 _res_D_a[1, 1] = -_tmp0 + _tmp1 + _tmp2 return sym.Unit3.from_storage(_res), _res_D_a
[docs] @staticmethod def compose_with_jacobians(a, b): # type: (sym.Unit3, sym.Unit3) -> T.Tuple[sym.Unit3, numpy.ndarray, numpy.ndarray] # Total ops: 146 # Input arrays _a = a.data _b = b.data # Intermediate terms (70) _tmp0 = _a[3] * _b[0] _tmp1 = _a[2] * _b[1] _tmp2 = _a[0] * _b[3] _tmp3 = _a[1] * _b[2] _tmp4 = _tmp0 - _tmp1 + _tmp2 + _tmp3 _tmp5 = _a[3] * _b[1] _tmp6 = _a[2] * _b[0] _tmp7 = _a[0] * _b[2] _tmp8 = _a[1] * _b[3] _tmp9 = _tmp5 + _tmp6 - _tmp7 + _tmp8 _tmp10 = _a[3] * _b[2] _tmp11 = _a[2] * _b[3] _tmp12 = _a[0] * _b[1] _tmp13 = _a[1] * _b[0] _tmp14 = _tmp10 + _tmp11 + _tmp12 - _tmp13 _tmp15 = _a[3] * _b[3] _tmp16 = _a[2] * _b[2] _tmp17 = _a[0] * _b[0] _tmp18 = _a[1] * _b[1] _tmp19 = _tmp15 - _tmp16 - _tmp17 - _tmp18 _tmp20 = (1.0 / 2.0) * _tmp10 _tmp21 = -1.0 / 2.0 * _tmp11 _tmp22 = (1.0 / 2.0) * _tmp12 _tmp23 = -_tmp22 _tmp24 = (1.0 / 2.0) * _tmp13 _tmp25 = _tmp20 + _tmp21 + _tmp23 - _tmp24 _tmp26 = 2 * _tmp14 _tmp27 = (1.0 / 2.0) * _tmp0 _tmp28 = (1.0 / 2.0) * _tmp1 _tmp29 = -_tmp28 _tmp30 = (1.0 / 2.0) * _tmp2 _tmp31 = (1.0 / 2.0) * _tmp3 _tmp32 = -_tmp31 _tmp33 = -_tmp27 + _tmp29 + _tmp30 + _tmp32 _tmp34 = 2 * _tmp4 _tmp35 = (1.0 / 2.0) * _tmp6 _tmp36 = (1.0 / 2.0) * _tmp7 _tmp37 = _tmp35 - _tmp36 _tmp38 = (1.0 / 2.0) * _tmp5 _tmp39 = -_tmp38 _tmp40 = (1.0 / 2.0) * _tmp8 _tmp41 = _tmp39 - _tmp40 _tmp42 = _tmp37 + _tmp41 _tmp43 = 2 * _tmp9 _tmp44 = (1.0 / 2.0) * _tmp16 _tmp45 = (1.0 / 2.0) * _tmp17 _tmp46 = _tmp44 + _tmp45 _tmp47 = (1.0 / 2.0) * _tmp15 _tmp48 = (1.0 / 2.0) * _tmp18 _tmp49 = -_tmp48 _tmp50 = _tmp47 + _tmp49 _tmp51 = _tmp46 + _tmp50 _tmp52 = 2 * _tmp19 _tmp53 = -_tmp47 _tmp54 = -_tmp44 _tmp55 = _tmp45 + _tmp49 + _tmp53 + _tmp54 _tmp56 = _tmp35 + _tmp36 + _tmp39 + _tmp40 _tmp57 = _tmp27 + _tmp30 _tmp58 = _tmp28 + _tmp32 + _tmp57 _tmp59 = _tmp21 + _tmp24 _tmp60 = _tmp20 + _tmp22 + _tmp59 _tmp61 = -_tmp35 + _tmp36 + _tmp41 _tmp62 = -_tmp45 + _tmp50 + _tmp54 _tmp63 = -_tmp20 + _tmp23 + _tmp59 _tmp64 = _tmp29 + _tmp31 + _tmp57 _tmp65 = -_tmp26 * _tmp63 + _tmp34 * _tmp64 _tmp66 = _tmp43 * _tmp64 _tmp67 = _tmp52 * _tmp63 _tmp68 = 2 * _tmp46 + 2 * _tmp48 + 2 * _tmp53 _tmp69 = _tmp37 + _tmp38 + _tmp40 # Output terms _res = [0.0] * 4 _res[0] = _tmp4 _res[1] = _tmp9 _res[2] = _tmp14 _res[3] = _tmp19 _res_D_a = numpy.zeros((2, 2)) _res_D_a[0, 0] = -_tmp25 * _tmp26 + _tmp33 * _tmp34 - _tmp42 * _tmp43 + _tmp51 * _tmp52 _res_D_a[1, 0] = -_tmp25 * _tmp52 - _tmp26 * _tmp51 + _tmp33 * _tmp43 + _tmp34 * _tmp42 _res_D_a[0, 1] = -_tmp26 * _tmp55 + _tmp34 * _tmp56 - _tmp43 * _tmp58 + _tmp52 * _tmp60 _res_D_a[1, 1] = -_tmp26 * _tmp60 + _tmp34 * _tmp58 + _tmp43 * _tmp56 - _tmp52 * _tmp55 _res_D_b = numpy.zeros((2, 2)) _res_D_b[0, 0] = -_tmp43 * _tmp61 + _tmp52 * _tmp62 + _tmp65 _res_D_b[1, 0] = -_tmp26 * _tmp62 + _tmp34 * _tmp61 + _tmp66 - _tmp67 _res_D_b[0, 1] = -_tmp14 * _tmp68 + _tmp34 * _tmp69 - _tmp66 + _tmp67 _res_D_b[1, 1] = -_tmp19 * _tmp68 + _tmp43 * _tmp69 + _tmp65 return sym.Unit3.from_storage(_res), _res_D_a, _res_D_b
[docs] @staticmethod def between_with_jacobians(a, b): # type: (sym.Unit3, sym.Unit3) -> T.Tuple[sym.Unit3, numpy.ndarray, numpy.ndarray] # Total ops: 107 # Input arrays _a = a.data _b = b.data # Intermediate terms (55) _tmp0 = _a[3] * _b[0] _tmp1 = _a[2] * _b[1] _tmp2 = _a[0] * _b[3] _tmp3 = _a[1] * _b[2] _tmp4 = _tmp0 + _tmp1 - _tmp2 - _tmp3 _tmp5 = _a[3] * _b[1] _tmp6 = _a[2] * _b[0] _tmp7 = _a[0] * _b[2] _tmp8 = _a[1] * _b[3] _tmp9 = _tmp5 - _tmp6 + _tmp7 - _tmp8 _tmp10 = _a[3] * _b[2] _tmp11 = _a[2] * _b[3] _tmp12 = _a[0] * _b[1] _tmp13 = _a[1] * _b[0] _tmp14 = _tmp10 - _tmp11 - _tmp12 + _tmp13 _tmp15 = _a[3] * _b[3] _tmp16 = _a[2] * _b[2] _tmp17 = _a[0] * _b[0] _tmp18 = _a[1] * _b[1] _tmp19 = _tmp15 + _tmp16 + _tmp17 + _tmp18 _tmp20 = (1.0 / 2.0) * _tmp5 _tmp21 = (1.0 / 2.0) * _tmp6 _tmp22 = (1.0 / 2.0) * _tmp7 _tmp23 = (1.0 / 2.0) * _tmp8 _tmp24 = _tmp20 - _tmp21 + _tmp22 - _tmp23 _tmp25 = 2 * _tmp9 _tmp26 = _tmp24 * _tmp25 _tmp27 = (1.0 / 2.0) * _tmp15 _tmp28 = (1.0 / 2.0) * _tmp16 _tmp29 = (1.0 / 2.0) * _tmp17 _tmp30 = (1.0 / 2.0) * _tmp18 _tmp31 = -_tmp27 - _tmp28 - _tmp29 - _tmp30 _tmp32 = 2 * _tmp19 _tmp33 = _tmp31 * _tmp32 _tmp34 = ( -1.0 / 2.0 * _tmp10 + (1.0 / 2.0) * _tmp11 + (1.0 / 2.0) * _tmp12 - 1.0 / 2.0 * _tmp13 ) _tmp35 = 2 * _tmp14 _tmp36 = -_tmp34 * _tmp35 _tmp37 = (1.0 / 2.0) * _tmp0 _tmp38 = (1.0 / 2.0) * _tmp1 _tmp39 = (1.0 / 2.0) * _tmp2 _tmp40 = (1.0 / 2.0) * _tmp3 _tmp41 = _tmp37 + _tmp38 - _tmp39 - _tmp40 _tmp42 = 2 * _tmp4 _tmp43 = _tmp36 + _tmp41 * _tmp42 _tmp44 = _tmp24 * _tmp42 _tmp45 = -_tmp31 * _tmp35 _tmp46 = _tmp25 * _tmp41 _tmp47 = _tmp32 * _tmp34 _tmp48 = _tmp46 - _tmp47 _tmp49 = _tmp27 + _tmp28 + _tmp29 + _tmp30 _tmp50 = -_tmp35 * _tmp49 _tmp51 = -_tmp37 - _tmp38 + _tmp39 + _tmp40 _tmp52 = _tmp44 + _tmp47 _tmp53 = _tmp32 * _tmp49 _tmp54 = -_tmp20 + _tmp21 - _tmp22 + _tmp23 # Output terms _res = [0.0] * 4 _res[0] = _tmp4 _res[1] = _tmp9 _res[2] = _tmp14 _res[3] = _tmp19 _res_D_a = numpy.zeros((2, 2)) _res_D_a[0, 0] = -_tmp26 + _tmp33 + _tmp43 _res_D_a[1, 0] = _tmp44 + _tmp45 + _tmp48 _res_D_a[0, 1] = -_tmp25 * _tmp51 + _tmp50 + _tmp52 _res_D_a[1, 1] = _tmp26 + _tmp36 + _tmp42 * _tmp51 - _tmp53 _res_D_b = numpy.zeros((2, 2)) _res_D_b[0, 0] = -_tmp25 * _tmp54 + _tmp43 + _tmp53 _res_D_b[1, 0] = _tmp42 * _tmp54 + _tmp48 + _tmp50 _res_D_b[0, 1] = _tmp45 - _tmp46 + _tmp52 _res_D_b[1, 1] = _tmp26 - _tmp33 + _tmp43 return sym.Unit3.from_storage(_res), _res_D_a, _res_D_b