farm-ng-core
interpolate.h
Go to the documentation of this file.
1
// Copyright (c) 2011, Hauke Strasdat
2
// Copyright (c) 2012, Steven Lovegrove
3
// Copyright (c) 2021, farm-ng, inc.
4
//
5
// Use of this source code is governed by an MIT-style
6
// license that can be found in the LICENSE file or at
7
// https://opensource.org/licenses/MIT.
8
9
/// @file
10
/// Interpolation for Lie groups.
11
12
#pragma once
13
14
#include "
sophus/lie/lie_group.h
"
15
16
#include <Eigen/Eigenvalues>
17
18
namespace
sophus
{
19
20
/// This function interpolates between two Lie group elements
21
/// ``foo_from_bar`` and ``foo_from_daz`` with an interpolation factor
22
/// of ``alpha`` in [0, 1].
23
///
24
/// It returns a pose ``foo_T_quiz`` with ``quiz`` being a frame between ``bar``
25
/// and ``baz``. If ``alpha=0`` it returns ``foo_from_bar``. If it is 1, it
26
/// returns ``foo_from_daz``.
27
///
28
/// (Since interpolation on Lie groups is inverse-invariant, we can equivalently
29
/// think of the input arguments as being ``bar_from_foo``,
30
/// ``baz_from_foo`` and the return value being ``quiz_T_foo``.)
31
///
32
/// Precondition: ``p`` must be in [0, 1].
33
///
34
template
<
35
concepts::LieGroup
TGroup,
36
concepts::ConvertibleTo<typename TGroup::Scalar> TScalar>
37
auto
interpolate
(
38
TGroup
const
& foo_from_bar,
39
TGroup
const
& foo_from_daz,
40
TScalar p = TScalar(0.5f)) -> TGroup {
41
TScalar inter_p(p);
42
SOPHUS_ASSERT
(
43
inter_p >= TScalar(0) && inter_p <= TScalar(1),
44
"p ({}) must in [0, 1]."
,
45
inter_p);
46
return
foo_from_bar *
47
TGroup::exp(inter_p * (foo_from_bar.inverse() * foo_from_daz).log());
48
}
49
50
}
// namespace sophus
SOPHUS_ASSERT
#define SOPHUS_ASSERT(...)
Definition:
common.h:40
sophus
Image MutImage, owning images types.
Definition:
num_diff.h:20
lie_group.h
sophus::concepts::LieGroup
concept LieGroup
Definition:
lie_group.h:170
sophus::interpolate
auto interpolate(sophus::ImageView< TT > const &image, Eigen::Vector2f uv) -> TT
Definition:
interpolation.h:21
projects
farm-ng-core
cpp
sophus
lie
interp
interpolate.h
Generated by
1.8.17