23 #if !defined(__FLECSI_PRIVATE__) 24 #error Do not include this file directly! 44 template<
typename T,
size_t D>
56 static constexpr element_t tol =
57 std::numeric_limits<element_t>::epsilon() * 10.;
62 within(
const point_t & origin,
const point_t & center, element_t r1) {
63 return util::distance(origin, center) - r1 <= tol;
68 const point_t & center,
71 return util::distance(origin, center) <= std::max(r1, r2);
77 within_box(
const point_t & min,
const point_t & max,
const point_t & origin) {
78 return origin[0] <= max[0] && origin[0] >= min[0];
83 const point_t & max_b1,
84 const point_t & min_b2,
85 const point_t & max_b2) {
86 return !((max_b1[0] < min_b2[0]) || (max_b2[0] < min_b1[0]));
94 return util::distance(c1, c2) - (r1 + r2) <= tol;
103 point_t x = point_t(std::max(min[0], std::min(c[0], max[0])));
104 element_t dist = util::distance(x, c);
105 return dist - r <= tol;
114 const point_t & position_sink,
115 const point_t & box_source_min,
116 const point_t & box_source_max,
118 double dmax = util::distance(box_source_min, box_source_max);
119 double disttoc = util::distance(position_sink, position_source);
120 return dmax / disttoc - macangle <= tol;
133 static constexpr element_t tol =
134 std::numeric_limits<element_t>::epsilon() * 10.;
139 within(
const point_t & origin,
const point_t & center, element_t r1) {
140 return util::distance(origin, center) - r1 <= tol;
145 const point_t & center,
148 return util::distance(origin, center) <= std::max(r1, r2);
154 within_box(
const point_t & min,
const point_t & max,
const point_t & origin) {
155 return origin[0] <= max[0] && origin[0] > min[0] && origin[1] <= max[1] &&
161 const point_t & max_b1,
162 const point_t & min_b2,
163 const point_t & max_b2) {
164 return !((max_b1[0] < min_b2[0] || max_b1[1] < min_b2[1]) ||
165 (max_b2[0] < min_b1[0] || max_b2[1] < min_b1[1]));
172 const element_t r2) {
173 return util::distance(c1, c2) - (r1 + r2) <= tol;
182 point_t x = point_t(std::max(min[0], std::min(c[0], max[0])),
183 std::max(min[1], std::min(c[1], max[1])));
184 element_t dist = util::distance(x, c);
185 return dist - r <= tol;
193 static bool box_MAC(
const point_t & position_source,
194 const point_t & position_sink,
195 const point_t & box_source_min,
196 const point_t & box_source_max,
198 double dmax = util::distance(box_source_min, box_source_max);
199 double disttoc = util::distance(position_sink, position_source);
200 return dmax / disttoc < macangle;
212 static constexpr element_t tol =
213 std::numeric_limits<element_t>::epsilon() * 10.;
218 within(
const point_t & origin,
const point_t & center, element_t r1) {
219 return util::distance(origin, center) - r1 <= tol;
224 const point_t & center,
225 const element_t & r1,
226 const element_t & r2) {
227 return util::distance(origin, center) <= std::max(r1, r2);
233 within_box(
const point_t & min,
const point_t & max,
const point_t & origin) {
234 return origin[0] <= max[0] && origin[0] > min[0] && origin[1] <= max[1] &&
235 origin[1] > min[1] && origin[2] <= max[2] && origin[2] > min[2];
240 const point_t & max_b1,
241 const point_t & min_b2,
242 const point_t & max_b2) {
243 return !((max_b1[0] < min_b2[0] || max_b1[1] < min_b2[1] ||
244 max_b1[2] < min_b2[2]) ||
245 (max_b2[0] < min_b1[0] || max_b2[1] < min_b1[1] ||
246 max_b2[2] < min_b1[2]));
253 const element_t r2) {
254 return (c2[0] - c1[0]) * (c2[0] - c1[0]) +
255 (c2[1] - c1[1]) * (c2[1] - c1[1]) +
256 (c2[2] - c1[2]) * (c2[2] - c1[2]) <=
257 (r1 + r2) * (r1 + r2);
265 const element_t & r) {
266 point_t x = point_t(c[0] < max[0] ? c[0] : max[0],
267 c[1] < max[1] ? c[1] : max[1],
268 c[2] < max[2] ? c[2] : max[2]);
269 x = {x[0] < min[0] ? min[0] : x[0],
270 x[1] < min[1] ? min[1] : x[1],
271 x[2] < min[2] ? min[2] : x[2]};
272 element_t dist = (x[0] - c[0]) * (x[0] - c[0]) +
273 (x[1] - c[1]) * (x[1] - c[1]) +
274 (x[2] - c[2]) * (x[2] - c[2]);
275 return dist <= r * r;
283 static bool box_MAC(
const point_t & position_source,
284 const point_t & position_sink,
285 const point_t & box_source_min,
286 const point_t & box_source_max,
288 double dmax = util::distance(box_source_min, box_source_max);
289 double disttoc = util::distance(position_sink, position_source);
290 return dmax / disttoc < macangle;
static bool within(const point_t &origin, const point_t ¢er, element_t r1)
Definition: geometry.hh:62
static bool intersects_sphere_sphere(const point_t &c1, const element_t r1, const point_t &c2, const element_t r2)
Intersection of two spheres based on center and radius.
Definition: geometry.hh:169
static bool within_square(const point_t &origin, const point_t ¢er, element_t r1, element_t r2)
Return true if dist^2 < radius^2.
Definition: geometry.hh:67
static bool within_square(const point_t &origin, const point_t ¢er, const element_t &r1, const element_t &r2)
Return true if dist^2 < radius^2.
Definition: geometry.hh:223
static bool within(const point_t &origin, const point_t ¢er, element_t r1)
Definition: geometry.hh:218
static bool intersects_sphere_box(const point_t &min, const point_t &max, const point_t &c, const element_t &r)
Definition: geometry.hh:262
static bool intersects_sphere_box(const point_t &min, const point_t &max, const point_t &c, const element_t r)
Definition: geometry.hh:178
static bool box_MAC(const point_t &position_source, const point_t &position_sink, const point_t &box_source_min, const point_t &box_source_max, double macangle)
Definition: geometry.hh:283
static bool box_MAC(const point_t &position_source, const point_t &position_sink, const point_t &box_source_min, const point_t &box_source_max, double macangle)
Definition: geometry.hh:193
static bool intersects_sphere_box(const point_t &min, const point_t &max, const point_t &c, const element_t r)
Definition: geometry.hh:99
static bool within(const point_t &origin, const point_t ¢er, element_t r1)
Definition: geometry.hh:139
static bool within_box(const point_t &min, const point_t &max, const point_t &origin)
Definition: geometry.hh:154
Definition: dimensioned_array.hh:58
static bool intersects_sphere_sphere(const point_t &c1, const element_t r1, const point_t &c2, const element_t r2)
Intersection of two spheres based on center and radius.
Definition: geometry.hh:90
static bool intersects_box_box(const point_t &min_b1, const point_t &max_b1, const point_t &min_b2, const point_t &max_b2)
Intersection between two boxes defined by there min and max bound.
Definition: geometry.hh:82
static bool intersects_box_box(const point_t &min_b1, const point_t &max_b1, const point_t &min_b2, const point_t &max_b2)
Intersection between two boxes defined by there min and max bound.
Definition: geometry.hh:160
static bool intersects_sphere_sphere(const point_t &c1, const element_t r1, const point_t &c2, const element_t r2)
Intersection of two spheres based on center and radius.
Definition: geometry.hh:250
static bool within_box(const point_t &min, const point_t &max, const point_t &origin)
Definition: geometry.hh:77
static bool intersects_box_box(const point_t &min_b1, const point_t &max_b1, const point_t &min_b2, const point_t &max_b2)
Intersection between two boxes defined by there min and max bound.
Definition: geometry.hh:239
Definition: geometry.hh:45
bool box_MAC(const point_t &position_source, const point_t &position_sink, const point_t &box_source_min, const point_t &box_source_max, double macangle)
Definition: geometry.hh:113
static bool within_box(const point_t &min, const point_t &max, const point_t &origin)
Definition: geometry.hh:233
static bool within_square(const point_t &origin, const point_t ¢er, element_t r1, element_t r2)
Return true if dist^2 < radius^2.
Definition: geometry.hh:144
Definition: control.hh:31