farm-ng-core
point_traits.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 #pragma once
10 
11 #include "sophus/concepts/point.h"
12 
13 #include <Eigen/Core>
14 
15 #include <limits>
16 
17 namespace sophus {
18 
19 template <class TPoint>
20 struct PointTraits;
21 
22 template <concepts::ScalarType TPoint>
23 struct PointTraits<TPoint> {
24  using Scalar = TPoint;
25 
26  static bool constexpr kIsFloatingPoint = std::is_floating_point_v<Scalar>;
27  static bool constexpr kIsInteger = std::is_integral_v<Scalar>;
28 
29  static int constexpr kRows = 1;
30  static int constexpr kCols = 1;
31 
32  static bool constexpr kHasInfinity =
33  std::numeric_limits<Scalar>::has_infinity;
34  static bool constexpr kHasQuietNan =
35  std::numeric_limits<Scalar>::has_quiet_NaN;
36  static bool constexpr kHasSignalingNan =
37  std::numeric_limits<Scalar>::has_signaling_NaN;
38 
39  static TPoint lowest() { return std::numeric_limits<Scalar>::lowest(); };
40  static TPoint min() { return std::numeric_limits<Scalar>::min(); };
41  static TPoint max() { return std::numeric_limits<Scalar>::max(); };
42 };
43 
44 template <concepts::EigenDenseType TPoint>
45 struct PointTraits<TPoint> {
46  using Scalar = typename TPoint::Scalar;
47  static int constexpr kRows = TPoint::RowsAtCompileTime;
48  static int constexpr kCols = TPoint::ColsAtCompileTime;
49 
50  static bool constexpr kIsFloatingPoint = std::is_floating_point_v<Scalar>;
51  static bool constexpr kIsInteger = std::is_integral_v<Scalar>;
52 
53  static bool constexpr kHasInfinity =
54  std::numeric_limits<Scalar>::has_infinity;
55  static bool constexpr kHasQuietNan =
56  std::numeric_limits<Scalar>::has_quiet_NaN;
57  static bool constexpr kHasSignalingNan =
58  std::numeric_limits<Scalar>::has_signaling_NaN;
59 
60  static TPoint lowest() {
61  return TPoint::Constant(std::numeric_limits<Scalar>::lowest());
62  };
63  static TPoint min() {
64  return TPoint::Constant(std::numeric_limits<Scalar>::min());
65  };
66  static TPoint max() {
67  return TPoint::Constant(std::numeric_limits<Scalar>::max());
68  };
69  static TPoint epsilon() {
70  return TPoint::Constant(std::numeric_limits<Scalar>::epsilon());
71  };
72  /// ... plus a bunch more if we need them
73 };
74 
75 } // namespace sophus
sophus::PointTraits< TPoint >::Scalar
TPoint Scalar
Definition: point_traits.h:24
point.h
sophus
Image MutImage, owning images types.
Definition: num_diff.h:20
sophus::min
auto min(TPoint const &a, TPoint const &b) -> TPoint
Definition: vector_space.h:104
sophus::PointTraits< TPoint >::min
static TPoint min()
Definition: point_traits.h:40
sophus::PointTraits< TPoint >::max
static TPoint max()
Definition: point_traits.h:41
sophus::PointTraits< TPoint >::epsilon
static TPoint epsilon()
Definition: point_traits.h:69
sophus::PointTraits
Definition: point_traits.h:20
sophus::max
auto max(TPoint const &a, TPoint const &b) -> TPoint
Definition: vector_space.h:114
sophus::PointTraits< TPoint >::lowest
static TPoint lowest()
Definition: point_traits.h:39