|
| 1 | +/* |
| 2 | + * Copyright (c) 2025, University Osnabrück |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions are met: |
| 7 | + * * Redistributions of source code must retain the above copyright |
| 8 | + * notice, this list of conditions and the following disclaimer. |
| 9 | + * * Redistributions in binary form must reproduce the above copyright |
| 10 | + * notice, this list of conditions and the following disclaimer in the |
| 11 | + * documentation and/or other materials provided with the distribution. |
| 12 | + * * Neither the name of the University Osnabrück nor the |
| 13 | + * names of its contributors may be used to endorse or promote products |
| 14 | + * derived from this software without specific prior written permission. |
| 15 | + * |
| 16 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | + * DISCLAIMED. IN NO EVENT SHALL University Osnabrück BE LIABLE FOR ANY |
| 20 | + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | + */ |
| 27 | + |
| 28 | +/** |
| 29 | + * @file |
| 30 | + * |
| 31 | + * @brief Linear Algebra Function |
| 32 | + * |
| 33 | + * @date 19.08.2025 |
| 34 | + * @author Alexander Mock |
| 35 | + * |
| 36 | + * @copyright Copyright (c) 2025, University Osnabrück. All rights reserved. |
| 37 | + * This project is released under the 3-Clause BSD License. |
| 38 | + * |
| 39 | + */ |
| 40 | +#ifndef RMAGINE_MATH_LIE_H |
| 41 | +#define RMAGINE_MATH_LIE_H |
| 42 | + |
| 43 | +#include "types.h" |
| 44 | +#include "math.h" |
| 45 | +#include <rmagine/types/shared_functions.h> |
| 46 | +#include <rmagine/types/PointCloud.hpp> |
| 47 | + |
| 48 | +#include <rmagine/util/prints.h> |
| 49 | + |
| 50 | +namespace rmagine |
| 51 | +{ |
| 52 | + |
| 53 | +/** |
| 54 | + * [ω]x operator: maps a 3-vector to its skew-symmetric matrix |
| 55 | + */ |
| 56 | +template<typename DataT> |
| 57 | +Matrix3x3_<DataT> omega_hat(const Vector3_<DataT>& w); |
| 58 | + |
| 59 | +/** |
| 60 | + * Rodrigues' rotation formula |
| 61 | + * @param axis rotation axis (does not need to be unit; will be normalized) |
| 62 | + * @param theta rotation angle in radians |
| 63 | + * @return 3x3 rotation matrix |
| 64 | + */ |
| 65 | +template<typename DataT> |
| 66 | +Matrix3x3_<DataT> rodrigues(const Vector3_<DataT>& axis, DataT theta); |
| 67 | + |
| 68 | +/** |
| 69 | + * Convenience overload: Rodrigues from axis–angle vector ω = θ * k. |
| 70 | + * Equivalent to so3_exp(ω). |
| 71 | + */ |
| 72 | +template<typename DataT> |
| 73 | +Matrix3x3_<DataT> rodrigues(const Vector3_<DataT>& omega); |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +/** |
| 78 | + * Log map on SO(3): R -> omega (axis-angle vector) |
| 79 | + */ |
| 80 | +template<typename DataT> |
| 81 | +Vector3_<DataT> so3_log( |
| 82 | + const Matrix3x3_<DataT>& R); |
| 83 | + |
| 84 | +template<typename DataT> |
| 85 | +Vector3_<DataT> so3_log( |
| 86 | + const Quaternion_<DataT>& q); |
| 87 | + |
| 88 | +template<typename DataT> |
| 89 | +Matrix3x3_<DataT> so3_exp( |
| 90 | + const Vector3_<DataT> omega); |
| 91 | + |
| 92 | +// --- Left Jacobian of SO(3) --- |
| 93 | +// J_l(w) = I + (1-cosθ)/θ^2 [w]x + (θ - sinθ)/θ^3 [w]x^2 |
| 94 | +// Small-angle series: I - 1/2 [w]x + 1/6 [w]x^2 |
| 95 | +template<typename DataT> |
| 96 | +Matrix3x3_<DataT> so3_left_jacobian(const Vector3_<DataT>& w); |
| 97 | + |
| 98 | +// J_l(w)^{-1} = I - 1/2 [w]x + (1 - θ cot(θ/2))/θ^2 [w]x^2 |
| 99 | +// Small-angle series: I + 1/2 [w]x + 1/12 [w]x^2 |
| 100 | +template<typename DataT> |
| 101 | +Matrix3x3_<DataT> so3_left_jacobian_inv(const Vector3_<DataT>& w); |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +// ------------------------------------------------------------------ |
| 106 | +// se3 exponential: twist (v, w) -> Transform |
| 107 | +// ------------------------------------------------------------------ |
| 108 | +template<typename DataT> |
| 109 | +Transform_<DataT> se3_exp( |
| 110 | + const Vector3_<DataT>& v, |
| 111 | + const Vector3_<DataT>& w); |
| 112 | + |
| 113 | +template<typename DataT> |
| 114 | +std::pair<Vector3_<DataT>, Vector3_<DataT> > se3_log( |
| 115 | + const Transform_<DataT>& T); |
| 116 | + |
| 117 | +} // namespace rmagine |
| 118 | + |
| 119 | +#include "lie.tcc" |
| 120 | + |
| 121 | +#endif // RMAGINE_MATH_LIE_H |
| 122 | + |
0 commit comments