-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusegment.h
More file actions
122 lines (93 loc) · 4.01 KB
/
usegment.h
File metadata and controls
122 lines (93 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* This file is part of the GreasePad distribution (https://github.com/FraunhoferIOSB/GreasePad).
* Copyright (c) 2022-2026 Jochen Meidow, Fraunhofer IOSB
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef USEGMENT_H
#define USEGMENT_H
#include "geometry/aabb.h"
#include <Eigen/Core>
#include <cmath>
#include <memory> // C++
namespace Uncertain {
class uPoint;
class uStraightLine;
using Eigen::Matrix;
using Eigen::VectorXd;
using Eigen::MatrixXd;
using Eigen::Matrix3d;
using Eigen::Vector2d;
using Eigen::Vector3d;
using Geometry::Aabb;
//! Uncertain straight line segment
class uStraightLineSegment
{
private:
using Vector9d = Matrix<double,9,1>; // type alias (typedef)
using Matrix9d = Matrix<double,9,9>; // type alias (typedef)
uStraightLineSegment() = default;
public:
uStraightLineSegment( const uPoint & ux, const uPoint & uy);
uStraightLineSegment( Vector9d t, Matrix9d Sigma_tt);
uStraightLineSegment & operator= ( const uStraightLineSegment &) = default; //!< Copy assignment
// deserialization with protected constructor
static std::shared_ptr<uStraightLineSegment> create();
// relations ....................................................
[[nodiscard]] bool intersects( const uStraightLineSegment & ut_) const;
[[nodiscard]] bool touches( const uStraightLineSegment & other,
double T_dist,
double T_in) const;
[[nodiscard]] bool touchedBy( const uPoint &,
double T_dist,
double T_in) const;
[[nodiscard]] uPoint ux() const;
[[nodiscard]] uPoint uy() const;
[[nodiscard]] uStraightLine ul() const;
[[nodiscard]] uStraightLine um() const;
[[nodiscard]] uStraightLine un() const;
[[nodiscard]] Vector3d hx() const;
[[nodiscard]] Vector3d hy() const;
//! Get the endpoints connecting straight line l = S(x)*y
[[nodiscard]] Vector3d hl() const { return m_t.head(3); }
//! Get delimiting straight line m in homogeneous coordinates
[[nodiscard]] Vector3d hm() const { return m_t.segment(3,3); }
//! Get delimiting straight line n in homogeneous coordinates
[[nodiscard]] Vector3d hn() const { return m_t.tail(3); }
//! Get the 9-vector t = [l',m',n']'
[[nodiscard]] VectorXd t() const { return m_t;}
//! Get 9x9 covariance matrix of vector t
[[nodiscard]] MatrixXd Cov_tt() const { return m_Cov_tt; }
//! Get endpoint x in Euclidean coordinates
[[nodiscard]] Vector2d x() const { return hx().head(2)/hx()(2); }
//! Get endpoint y in Euclidean coordinates
[[nodiscard]] Vector2d y() const { return hy().head(2)/hy()(2); }
//! Get angle between straight line l and x-axis in degree
[[nodiscard]] double phi_deg() const {
constexpr double pi = 3.14159265358979323846;
constexpr double rho = 180./pi;
return rho*atan2( m_t(1),m_t(0) );
}
//! Get axis-aligned bounding box
[[nodiscard]] Aabb<double,2> bounding_box() const { return m_bounding_box; }
[[nodiscard]] bool move_x_to( const Vector3d & m );
[[nodiscard]] bool move_y_to( const Vector3d & n );
void transform( const Matrix9d & TT );
private:
Vector9d m_t; // 9-vector t=[l',m',n']'
Matrix9d m_Cov_tt;
Aabb<double,2> m_bounding_box; // not constant, due to merge operation, .united(...)
};
} // namespace Uncertain
#endif // USEGMENT_H