33 this->find_polyhedron();
53 dir_h(0) = dir(1), dir_h(1) = -dir(0);
54 if (dir_h.norm() == 0) {
60 dir_h = dir_h.normalized();
77 dir_v(0) = dir(1) * dir_h(2) - dir(2) * dir_h(1);
78 dir_v(1) = dir(2) * dir_h(0) - dir(0) * dir_h(2);
79 dir_v(2) = dir(0) * dir_h(1) - dir(1) * dir_h(0);
89 typename std::enable_if<U == 2>::type
98 double ratio = axes(1) / axes(0);
104 C = Ri * C * Ri.transpose();
110 auto obs_inside = obs;
112 while (!obs_inside.empty()) {
116 axes(1) = std::abs(p(1)) / std::sqrt(1 - std::pow(p(0) / axes(0), 2));
118 new_C(0, 0) = axes(0);
119 new_C(1, 1) = axes(1);
120 E.C_ = Ri * new_C * Ri.transpose();
123 for(
const auto &it: obs_inside) {
125 obs_new.push_back(it);
127 obs_inside = obs_new;
134 template<
int U = Dim>
135 typename std::enable_if<U == 3>::type
144 double ratio = axes(1) / axes(0);
149 const auto Ri = vec3_to_rotation(
p2_ -
p1_);
150 C = Ri * C * Ri.transpose();
156 auto obs_inside = obs;
158 while (!obs_inside.empty()) {
161 const decimal_t roll = atan2(p(2), p(1));
162 Rf = Ri *
Quatf(cos(roll / 2), sin(roll / 2), 0, 0);
163 p = Rf.transpose() * (pw - E.
d());
166 axes(1) = std::abs(p(1)) / std::sqrt(1 - std::pow(p(0) / axes(0), 2));
168 new_C(0, 0) = axes(0);
169 new_C(1, 1) = axes(1);
170 new_C(2, 2) = axes(1);
171 E.C_ = Rf * new_C * Rf.transpose();
174 for(
const auto &it: obs_inside) {
176 obs_new.push_back(it);
178 obs_inside = obs_new;
182 C = f * Matf<Dim, Dim>::Identity();
186 E.C_ = Rf * C * Rf.transpose();
190 while (!obs_inside.empty()) {
192 Vec3f p = Rf.transpose() * (pw - E.
d());
193 decimal_t dd = 1 - std::pow(p(0) / axes(0), 2) -
194 std::pow(p(1) / axes(1), 2);
196 axes(2) = std::abs(p(2)) / std::sqrt(dd);
198 new_C(0, 0) = axes(0);
199 new_C(1, 1) = axes(1);
200 new_C(2, 2) = axes(2);
201 E.C_ = Rf * new_C * Rf.transpose();
204 for(
const auto &it: obs_inside) {
206 obs_new.push_back(it);
208 obs_inside = obs_new;
vec_E< Vecf< N >> vec_Vecf
Vector of Eigen 1D float vector.
Definition: data_type.h:69
Line Segment Class.
Definition: decomp_base.h:18
Vecf< Dim > local_bbox_
Local bounding box along the line segment.
Definition: decomp_base.h:94
Vecf< Dim > p2_
The other end of line segment, input.
Definition: line_segment.h:217
Line Segment Class.
Definition: line_segment.h:17
Polyhedron< Dim > polyhedron_
Output polyhedron.
Definition: decomp_base.h:91
Polyhedron class.
Definition: polyhedron.h:41
Mat2f vec2_to_rotation(const Vec2f &v)
Calculate rotation matrix from a vector (aligned with x-axis)
Definition: geometric_utils.h:20
constexpr decimal_t epsilon_
Compensate for numerical error.
Definition: data_type.h:126
decimal_t dist(const Vecf< Dim > &pt) const
Calculate distance to the center.
Definition: ellipsoid.h:19
Definition: ellipsoid.h:14
void add(const Hyperplane< Dim > &v)
Append Hyperplane.
Definition: polyhedron.h:49
std::enable_if< U==3 >::type find_ellipsoid(double offset_x)
Find ellipsoid in 3D.
Definition: line_segment.h:136
vec_Vecf< Dim > obs_
Obstacles, input.
Definition: decomp_base.h:86
vec_Vecf< Dim > points_inside(const vec_Vecf< Dim > &O) const
Calculate points inside ellipsoid, non-exclusive.
Definition: ellipsoid.h:29
LineSegment()
Simple constructor.
Definition: line_segment.h:20
Vecf< 3 > Vec3f
Eigen 1D float vector of size 3.
Definition: data_type.h:79
Vecf< Dim > closest_point(const vec_Vecf< Dim > &O) const
Find the closest point.
Definition: ellipsoid.h:39
Eigen::Matrix< decimal_t, M, N > Matf
MxN Eigen matrix.
Definition: data_type.h:63
void dilate(decimal_t radius)
Infalte the line segment.
Definition: line_segment.h:31
std::enable_if< U==2 >::type find_ellipsoid(double offset_x)
Find ellipsoid in 2D.
Definition: line_segment.h:90
double decimal_t
Rename the float type used in lib.
Definition: data_type.h:50
Eigen::Quaternion< decimal_t > Quatf
Allias of Eigen::Quaterniond.
Definition: data_type.h:120
Eigen::Matrix< decimal_t, N, 1 > Vecf
Eigen 1D float vector.
Definition: data_type.h:57
Hyperplane class.
Definition: polyhedron.h:13
Ellipsoid< Dim > ellipsoid_
Output ellipsoid.
Definition: decomp_base.h:89
Vecf< Dim > p1_
One end of line segment, input.
Definition: line_segment.h:215
Vecf< Dim > d() const
Get center.
Definition: ellipsoid.h:90
vec_Vecf< Dim > get_line_segment() const
Get the line.
Definition: line_segment.h:38
void add_local_bbox(Polyhedron< Dim > &Vs)
Add the bounding box.
Definition: line_segment.h:47
LineSegment(const Vecf< Dim > &p1, const Vecf< Dim > &p2)
Basic constructor.
Definition: line_segment.h:26