PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
geom.cpp
Go to the documentation of this file.
1
2// Copyright (c) 2021 Prashant K. Jha
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6// ////////////////////////////////////////////////////////////////////////////////
7
8#include "geom.h"
9#include "function.h"
10#include "io.h"
11#include "transformation.h"
12#include <iostream>
13
14std::vector<util::Point> util::getCornerPoints(
15 size_t dim, const std::pair<util::Point, util::Point> &box) {
16
17 if (dim == 1)
18 return {box.first, box.second};
19 else if (dim == 2)
20 return {box.first,
21 util::Point(box.second.d_x, box.first.d_y, 0.),
22 box.second,
23 util::Point(box.first.d_x, box.second.d_y, 0.)};
24 else if (dim == 3) {
25 double a = box.second.d_x - box.first.d_x;
26 double b = box.second.d_y - box.first.d_y;
27 double c = box.second.d_z - box.first.d_z;
28 return {box.first,
29 box.first + util::Point(a, 0., 0.),
30 box.first + util::Point(a, b, 0.),
31 box.first + util::Point(0., b, 0.),
32 box.first + util::Point(0., 0., c),
33 box.first + util::Point(a, 0., c),
34 box.first + util::Point(a, b, c),
35 box.first + util::Point(0., b, c)};
36 }
37 else {
38 std::cerr << "Error: Check dimension = " << dim << ".\n";
39 exit(1);
40 }
41}
42
43std::vector<std::pair<util::Point, util::Point>> util::getEdges(size_t dim, const
44std::pair<util::Point, util::Point> &box) {
45
46 std::vector<std::pair<util::Point, util::Point>> data;
47 if (dim == 1) {
48 data.emplace_back(box);
49 return data;
50 } else if (dim == 2) {
51
52 // points returned by below function is in anti-clockwise order
53 auto corner_pts = util::getCornerPoints(dim, box);
54
55 data.emplace_back(corner_pts[0], corner_pts[1]);
56 data.emplace_back(corner_pts[1], corner_pts[2]);
57 data.emplace_back(corner_pts[2], corner_pts[3]);
58 data.emplace_back(corner_pts[3], corner_pts[0]);
59 return data;
60 } else if (dim == 3) {
61
62 // points returned by below function is in anti-clockwise order
63 // first 4 points are on lower z-plane, and remaining are in upper z-plane
64 auto corner_pts = util::getCornerPoints(dim, box);
65
66 // edges in lower plane
67 data.emplace_back(corner_pts[0], corner_pts[1]);
68 data.emplace_back(corner_pts[1], corner_pts[2]);
69 data.emplace_back(corner_pts[2], corner_pts[3]);
70 data.emplace_back(corner_pts[3], corner_pts[0]);
71
72 // edges in upper plane
73 data.emplace_back(corner_pts[4], corner_pts[5]);
74 data.emplace_back(corner_pts[5], corner_pts[6]);
75 data.emplace_back(corner_pts[6], corner_pts[7]);
76 data.emplace_back(corner_pts[7], corner_pts[4]);
77
78 // edges parrallel to z-axis
79 data.emplace_back(corner_pts[0], corner_pts[4]);
80 data.emplace_back(corner_pts[1], corner_pts[5]);
81 data.emplace_back(corner_pts[2], corner_pts[6]);
82 data.emplace_back(corner_pts[3], corner_pts[7]);
83
84 return data;
85 } else {
86 std::cerr << "getEdges(): Function implemented for dim = 1,2,3 only.\n";
87 exit(EXIT_FAILURE);
88 }
89}
90
92 const std::pair<util::Point, util::Point> &box) {
93
94 if (dim == 1)
95 return {0.5 * box.second.d_x + 0.5 * box.first.d_x, 0., 0.};
96 else if (dim == 2)
97 return {0.5 * box.second.d_x + 0.5 * box.first.d_x,
98 0.5 * box.second.d_y + 0.5 * box.first.d_y, 0.};
99 else if (dim == 3)
100 return {0.5 * box.second.d_x + 0.5 * box.first.d_x,
101 0.5 * box.second.d_y + 0.5 * box.first.d_y,
102 0.5 * box.second.d_z + 0.5 * box.first.d_z};
103 else {
104 std::cerr << "Error: Check dimension = " << dim << ".\n";
105 exit(1);
106 }
107}
108
109bool util::areBoxesNear(const std::pair<util::Point, util::Point>
110 &b1,
111 const std::pair<util::Point, util::Point> &b2,
112 const double &tol,
113 size_t dim) {
114
115 auto cp1 = getCornerPoints(dim, b1);
116 auto cp2 = getCornerPoints(dim, b2);
117
118 for (auto p : cp1) {
119
120 // check 1: If any of the corner points of box 1 are inside box 2
121 if (isPointInsideBox(p, dim, b2))
122 return true;
123
124 // check 2: If any pair of corner points of box 1 and box 2 are at
125 // distance smaller than the tolerance
126 for (auto pp : cp2) {
127 auto dx = pp - p;
128 if (util::isLess(dx.length(), tol))
129 return true;
130 }
131 }
132
133 // check 3: Check if distance between centers of box 1 and box 2 are below
134 // sum of tolerance, radius of circle inscribed in box 1, and radius of
135 // circle inscribed in box 2
136 auto dxc = getCenter(dim, b2) - getCenter(dim, b1);
137 auto dist = tol + inscribedRadiusInBox(dim, b1) + inscribedRadiusInBox(dim,
138 b2);
139
140 if (util::isLess(dxc.length(), dist))
141 return true;
142
143 // check 4: Check if distance between centers of box 1 and box 2 are below
144 // sum of tolerance, radius of circle inscribed in box 1, and radius of
145 // circle circumscribed in box 2
146 dist = tol + inscribedRadiusInBox(dim, b1) + circumscribedRadiusInBox(dim,
147 b2);
148 if (util::isLess(dxc.length(), dist))
149 return true;
150
151 dist = tol + circumscribedRadiusInBox(dim, b1) + inscribedRadiusInBox(dim,
152 b2);
153 if (util::isLess(dxc.length(), dist))
154 return true;
155
156 return false;
157}
158
160 const std::pair<util::Point, util::Point> &box) {
161
162 if (dim == 1)
163 return !(util::isLess(x.d_x, box.first.d_x - 1.0E-12) or
164 util::isGreater(x.d_x, box.second.d_x + 1.0E-12));
165 else if (dim == 2)
166 return !(util::isLess(x.d_x, box.first.d_x - 1.0E-12) or
167 util::isLess(x.d_y, box.first.d_y - 1.0E-12) or
168 util::isGreater(x.d_x, box.second.d_x + 1.0E-12) or
169 util::isGreater(x.d_y, box.second.d_y + 1.0E-12));
170 else if (dim == 3)
171 return !(util::isLess(x.d_x, box.first.d_x - 1.0E-12) or
172 util::isLess(x.d_y, box.first.d_y - 1.0E-12) or
173 util::isLess(x.d_z, box.first.d_z - 1.0E-12) or
174 util::isGreater(x.d_x, box.second.d_x + 1.0E-12) or
175 util::isGreater(x.d_y, box.second.d_y + 1.0E-12) or
176 util::isGreater(x.d_z, box.second.d_z + 1.0E-12));
177 else {
178 std::cerr << "isPointInsideBox(): Function implemented for dim = 1,2,3 only.\n";
179 exit(EXIT_FAILURE);
180 }
181}
182
184 const std::pair<util::Point, util::Point> &box) {
185
186 double r = 0.5 * std::abs(box.second.d_x - box.first.d_x);
187 if (dim == 1)
188 return r;
189 else if (dim == 2) {
190 if (util::isGreater(r, 0.5 * std::abs(box.second.d_y - box.first.d_y)))
191 return 0.5 * std::abs(box.second.d_y - box.first.d_y);
192 else
193 return r;
194 } else if (dim == 3) {
195 if (util::isGreater(r, 0.5 * std::abs(box.second.d_y - box.first.d_y)))
196 r = 0.5 * std::abs(box.second.d_y - box.first.d_y);
197
198 if (util::isGreater(r, 0.5 * std::abs(box.second.d_z - box.first.d_z)))
199 return 0.5 * std::abs(box.second.d_z - box.first.d_z);
200 else
201 return r;
202 } else {
203 std::cerr << "inscribedRadiusInBox(): Function implemented for dim = 1,2,3 only.\n";
204 exit(EXIT_FAILURE);
205 }
206}
207
209 const std::pair<util::Point, util::Point> &box) {
210
211 auto xc = getCenter(dim, box);
212 auto cp = getCornerPoints(dim, box);
213
214 auto dx = cp[0] - xc;
215 auto r = dx.length();
216
217 if (dim == 1)
218 return r;
219 else {
220 for (auto p : cp) {
221 dx = p - xc;
222 if (util::isGreater(dx.length(), r))
223 r = dx.length();
224 }
225
226 return r;
227 }
228}
229
230
232 double x_max, double y_min,
233 double y_max) {
234
235 return !(util::isLess(x.d_x, x_min - 1.0E-12) or
236 util::isLess(x.d_y, y_min - 1.0E-12) or
237 util::isGreater(x.d_x, x_max + 1.0E-12) or
238 util::isGreater(x.d_y, y_max + 1.0E-12));
239}
240
242 util::Point x_rt) {
243 return !(util::isLess(x.d_x, x_lb.d_x - 1.0E-12) or
244 util::isLess(x.d_y, x_lb.d_y - 1.0E-12) or
245 util::isGreater(x.d_x, x_rt.d_x + 1.0E-12) or
246 util::isGreater(x.d_y, x_rt.d_y + 1.0E-12));
247}
248
250 double x2, double y1,
251 double y2, double theta) {
252 // we assume that the rectangle has passed the test
253
254 //
255 // (x2,y2)
256 // o
257 //
258 //
259 //
260 //
261 //
262 // o
263 // (x1,y1)
264
265 // get divisors
267 util::Point(x2 - x1, y2 - y1, 0.0), theta);
268
269 // double lam1 = (x2-x1) * std::cos(theta) + (y2-y1) * std::sin(theta);
270 // double lam2 = -(x2-x1) * std::sin(theta) + (y2-y1) * std::cos(theta);
271
272 // get mapped coordinate of x
274 util::Point(x[0] - x1, x[1] - y1, 0.0), theta);
275
276 // double xmap = (x[0]-x1) * std::cos(theta) + (x[1]-y1) * std::sin(theta);
277 // double ymap = -(x[0]-x1) * std::sin(theta) + (x[1]-y1) * std::cos(theta);
278
279 // check if mapped coordinate are out of range [0, lam1] and [0, lam2]
280 return !(util::isLess(xmap[0], -1.0E-12) or
281 util::isLess(xmap[1], -1.0E-12) or
282 util::isGreater(xmap[0], lam[0] + 1.0E-12) or
283 util::isGreater(xmap[1], lam[1] + 1.0E-12));
284}
285
287 util::Point x_rtf) {
288 return !(util::isLess(x.d_x, x_lbb.d_x - 1.0E-12) or
289 util::isLess(x.d_y, x_lbb.d_y - 1.0E-12) or
290 util::isLess(x.d_z, x_lbb.d_z - 1.0E-12) or
291 util::isGreater(x.d_x, x_rtf.d_x + 1.0E-12) or
292 util::isGreater(x.d_y, x_rtf.d_y + 1.0E-12) or
293 util::isGreater(x.d_z, x_rtf.d_z + 1.0E-12));
294}
295
296bool util::isPointInsideCylinder(const util::Point &p, const double &length, const double
297&radius, const util::Point &axis) {
298
299 double p_dot_a = p * axis;
300 if (p_dot_a > length or p_dot_a < 0.)
301 return false;
302 else {
303
304 auto p_parallel = p - p_dot_a * axis;
305
306 return p_parallel.lengthSq() < radius * radius;
307 }
308}
309
310bool util::isPointInsideCylinder(const util::Point &p, const double &radius,
311 const util::Point &x1, const util::Point &x2) {
312
313 auto p_new = p - x1;
314 auto a = x2 - x1;
315 double p_dot_a = p_new * a;
316
317 // note here we should 1 if a is not normalized
318 if (p_dot_a > 1. or p_dot_a < 0.)
319 return false;
320 else {
321
322 auto p_parallel = p_new - p_dot_a * a;
323
324 return p_parallel.lengthSq() < radius * radius;
325 }
326}
327
328bool util::isPointInsideEllipse(const util::Point &p, const util::Point &center, const
329std::vector<double> &radius_vec, unsigned int dim) {
330
331 double d = 0.;
332 auto x = p - center;
333 for (unsigned int i=0; i<dim; i++)
334 d += x[i] * x[i] / (radius_vec[i] * radius_vec[i]);
335
336 return d < 1.;
337}
338
339bool util::isPointInsideEllipse(const util::Point &p, const util::Point &center, const
340std::vector<double> &radius_vec, unsigned int dim, double &d) {
341
342 d = 0.;
343 auto x = p - center;
344 for (unsigned int i=0; i<dim; i++)
345 d += x[i] * x[i] / (radius_vec[i] * radius_vec[i]);
346
347 return d < 1.;
348}
349
351util::Point &p2,
352 const double &s) {
353 return (1. - s) * p1 + s * p2;
354}
355
356bool util::doLinesIntersect(const std::pair<util::Point, util::Point> &line_1,
357 const std::pair<util::Point, util::Point> &line_2) {
358
359 // change of variable so that first point of line_1 is at origin
360 // After change of variables:
361 // a is the second point of line_1
362 // b is the first point of line_2
363 // c is the difference of second and first point of line_2
364 auto a = line_1.second - line_1.first;
365 auto b = line_2.first - line_1.first;
366 auto c = line_2.second - line_2.first;
367
368 // check if the two lines are parallel
369 if (util::angle(a / a.length(), c / c.length()) < 1.0E-8)
370 return false;
371
372 double a_dot_a = a.lengthSq();
373 double a_dot_b = a * b;
374 double a_dot_c = a * c;
375 double b_dot_c = b * c;
376 double c_dot_c = c.lengthSq();
377
378 double r = (a_dot_a * b_dot_c - a_dot_b * a_dot_c) /
379 (a_dot_c * a_dot_c - c_dot_c * a_dot_a);
380
381 // if r is in (0,1) then this gives the intersection point
382 // otherwise b + r c gives the point where two vectors originating from
383 // a and originating from b would intersect
384 return r > 0. and r < 1.;
385}
386
387double util::distanceBetweenLines(const std::pair<util::Point, util::Point> &line_1,
388 const std::pair<util::Point, util::Point>
389 &line_2) {
390
391 // let line 1 is l1(s) = p + s u
392 // and line 2 is l2(r) = q + r v
393 // and let normal to the plane containing line 1 and 2 is
394 // n = u x v / |u x v|
395
396 auto u = line_1.second - line_1.first;
397 auto v = line_2.second - line_2.first;
398 auto w0 = line_1.first - line_2.first;
399
400 double a = u * u;
401 double b = u * v;
402 double c = v * v;
403 double d = u * w0;
404 double e = v * w0;
405
406 auto dp = w0 + ((b * e - c * d) * u + (a * e - b * d) * v) / (a * c - b * b);
407
408 return dp.length();
409}
410
411double
412util::distanceBetweenSegments(const std::pair<util::Point, util::Point> &line_1,
413 const std::pair<util::Point, util::Point> &line_2) {
414
415 // let line 1 is l1(s) = p + s u
416 // and line 2 is l2(r) = q + r v
417 // and let normal to the plane containing line 1 and 2 is
418 // n = u x v / |u x v|
419
420 auto u = line_1.second - line_1.first;
421 auto v = line_2.second - line_2.first;
422 auto w0 = line_1.first - line_2.first;
423
424 double a = u * u;
425 double b = u * v;
426 double c = v * v;
427 double d = u * w0;
428 double e = v * w0;
429 double D = a * c - b * b;
430 double sc, sN, sD = D;
431 double tc, tN, tD = D;
432
433 // compute line parameters of two closest points
434 if (D < 1.0E-12) {
435
436 sN = 0.;
437 sD = 1.;
438 tN = e;
439 tD = c;
440 } else {
441
442 sN = b * e - c * d;
443 tN = a * e - b * d;
444
445 if (sN < 0.) {
446 sN = 0.;
447 tN = e;
448 tD = c;
449 } else if (sN > sD) {
450 sN = sD;
451 tN = e + b;
452 tD = c;
453 }
454 }
455
456 if (tN < 0.) {
457
458 tN = 0.;
459
460 if (-d < 0.)
461 sN = 0.;
462 else if (-d > a)
463 sN = sD;
464 else {
465 sN = -d;
466 sD = a;
467 }
468 } else if (tN > tD) {
469
470 tN = tD;
471
472 if (-d + b < 0.)
473 sN = 0.;
474 else if (-d + b > a)
475 sN = sD;
476 else {
477 sN = -d + b;
478 sD = a;
479 }
480 }
481
482 sc = std::abs(sN) < 1.0E-12 ? 0. : sN / sD;
483 tc = std::abs(tN) < 1.0E-12 ? 0. : tN / tD;
484
485 auto dp = w0 + sc * u - tc * v;
486
487 return dp.length();
488}
489
490double util::distanceBetweenPlanes(const std::pair<util::Point, util::Point> &plane_1,
491 const std::pair<util::Point, util::Point>
492 &plane_2) {
493
494 // check if planes are parallel
495 if (util::angle(plane_1.first, plane_2.first) < 1.0E-8)
496 return 0.;
497
498 return std::abs(plane_1.first * (plane_1.second - plane_2.second)) /
499 plane_1.first.length();
500}
501
503 const std::pair<util::Point, util::Point> &line) {
504
505 // line vector
506 auto v = line.second - line.first;
507
508 // vector from 1st point of line to p
509 auto w = p - line.first;
510
511 // project w onto v and add 1st point to get projected point's location
512 auto w_on_line = line.first + (w * v) * v / v.lengthSq();
513
514 return (p - w_on_line).length();
515}
516
518 const std::pair<util::Point, util::Point> &line) {
519
520 // line vector
521 auto v = line.second - line.first;
522
523 // vector from 1st point of line to p
524 auto w = p - line.first;
525
526 // determine if w is on left side or right side of line
527 double w_dot_v = w * v;
528 if (w_dot_v < 1.0E-12)
529 return (p - line.first).length();
530
531 if (w_dot_v > v.lengthSq() - 1.0E-12)
532 return (p - line.second).length();
533
534 // project w onto v and add 1st point to get projected point's location
535 auto w_on_line = line.first + w_dot_v * v / v.lengthSq();
536
537 return (p - w_on_line).length();
538}
539
541 const std::pair<util::Point, util::Point> &plane) {
542
543 // if plane is given by unit normal n and a point a which is contained in it
544 // then the distance of point p from plane is
545 // |(p - a) dot n| / |n|
546
547 auto pa = p - plane.second;
548 return std::abs(pa * plane.first) / plane.first.length();
549}
550
551double util::computeMeshSize(const std::vector<util::Point> &nodes) {
552
553 double guess = 0.;
554 if (nodes.size() < 2)
555 return guess;
556
557 guess = (nodes[0] - nodes[1]).length();
558 for (size_t i = 0; i < nodes.size(); i++)
559 for (size_t j = 0; j < nodes.size(); j++)
560 if (i != j) {
561 double val = nodes[i].dist(nodes[j]);
562
563 if (util::isLess(val, 1.0E-12)) {
564
565 std::cout << "Check nodes are too close = "
566 << util::io::printStr<util::Point>({nodes[i],
567 nodes[j]})
568 << "\n";
569 std::cout << "Distance = " << val << ", guess = " << guess << "\n";
570 }
571 if (util::isLess(val, guess))
572 guess = val;
573 }
574
575 return guess;
576}
577
578double util::computeMeshSize(const std::vector<util::Point> &nodes, size_t start,
579 size_t end) {
580
581 double guess = 0.;
582 if (nodes.size() < 2 or (end - start) < 2)
583 return guess;
584
585 guess = (nodes[start] - nodes[start + 1]).length();
586 for (size_t i = start; i < end; i++)
587 for (size_t j = start; j < end; j++)
588 if (i != j) {
589 double val = nodes[i].dist(nodes[j]);
590
591 if (util::isLess(val, 1.0E-12)) {
592
593 std::cout << "Check nodes are too close = "
594 << util::io::printStr<util::Point>({nodes[i],
595 nodes[j]})
596 << "\n";
597 std::cout << "Distance = " << val << ", guess = " << guess << "\n";
598 }
599 if (util::isLess(val, guess))
600 guess = val;
601 }
602
603 return guess;
604}
605
606std::pair<util::Point, util::Point> util::computeBBox(const std::vector<util::Point> &nodes) {
607
608 auto p1 = util::Point();
609 auto p2 = util::Point();
610 for (const auto& x : nodes) {
611 if (util::isLess(x.d_x, p1.d_x))
612 p1.d_x = x.d_x;
613 if (util::isLess(x.d_y, p1.d_y))
614 p1.d_y = x.d_y;
615 if (util::isLess(x.d_z, p1.d_z))
616 p1.d_z = x.d_z;
617 if (util::isLess(p2.d_x, x.d_x))
618 p2.d_x = x.d_x;
619 if (util::isLess(p2.d_y, x.d_y))
620 p2.d_y = x.d_y;
621 if (util::isLess(p2.d_z, x.d_z))
622 p2.d_z = x.d_z;
623 }
624
625 return {p1, p2};
626}
627
628double util::computeInscribedRadius(const std::pair<util::Point, util::Point>
629 &box) {
630
631 return 0.5 * (box.first - box.second).length();
632}
633
634std::pair<util::Point, util::Point> util::toPointBox(const std::vector<double>
635 &p1, const std::vector<double>
636 &p2) {
637 auto q1 = util::Point(p1[0], p1[1], p1[2]);
638 auto q2 = util::Point(p2[0], p2[1], p2[2]);
639 return {q1, q2};
640}
641
642double util::triangleArea(const util::Point &x1, const util::Point &x2,
643 const util::Point &x3) {
644 return 0.5 * ((x2.d_x - x1.d_x) * (x3.d_y - x1.d_y) -
645 (x3.d_x - x1.d_x) * (x2.d_y - x1.d_y));
646}
bool isPointInsideBox(util::Point x, size_t dim, const std::pair< util::Point, util::Point > &box)
Returns true if point is inside box.
Definition geom.cpp:159
double pointDistanceLine(const util::Point &p, const std::pair< util::Point, util::Point > &line)
Compute distance between point and line.
Definition geom.cpp:502
double computeMeshSize(const std::vector< util::Point > &nodes)
Computes minimum distance between any two nodes.
Definition geom.cpp:551
bool isPointInsideEllipse(const util::Point &p, const util::Point &center, const std::vector< double > &radius_vec, unsigned int dim)
Returns true if point is inside the ellipsoid.
Definition geom.cpp:328
double pointDistancePlane(const util::Point &p, const std::pair< util::Point, util::Point > &plane)
Compute distance between point and plane.
Definition geom.cpp:540
bool areBoxesNear(const std::pair< util::Point, util::Point > &b1, const std::pair< util::Point, util::Point > &b2, const double &tol, size_t dim)
Checks if given two boxes are within given distance from each other.
Definition geom.cpp:109
bool isGreater(const double &a, const double &b)
Returns true if a > b.
Definition function.cpp:15
bool doLinesIntersect(const std::pair< util::Point, util::Point > &line_1, const std::pair< util::Point, util::Point > &line_2)
Do lines intersect.
Definition geom.cpp:356
double distanceBetweenPlanes(const std::pair< util::Point, util::Point > &plane_1, const std::pair< util::Point, util::Point > &plane_2)
Compute distance between planes.
Definition geom.cpp:490
bool isPointInsideCuboid(util::Point x, util::Point x_lbb, util::Point x_rtf)
Checks if point is inside a cuboid.
Definition geom.cpp:286
std::vector< std::pair< util::Point, util::Point > > getEdges(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.
Definition geom.cpp:43
double angle(util::Point a, util::Point b)
Computes angle between two vectors.
std::vector< util::Point > getCornerPoints(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.
Definition geom.cpp:14
util::Point getPointOnLine(const util::Point &p1, const util::Point &p2, const double &s)
Returns point in line formed by points p1 and p2.
Definition geom.cpp:350
double distanceBetweenLines(const std::pair< util::Point, util::Point > &line_1, const std::pair< util::Point, util::Point > &line_2)
Compute distance between lines.
Definition geom.cpp:387
bool isLess(const double &a, const double &b)
Returns true if a < b.
Definition function.cpp:20
std::pair< util::Point, util::Point > computeBBox(const std::vector< util::Point > &nodes)
Computes bounding box for vector nodes.
Definition geom.cpp:606
util::Point getCenter(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns center point.
Definition geom.cpp:91
double distanceBetweenSegments(const std::pair< util::Point, util::Point > &line_1, const std::pair< util::Point, util::Point > &line_2)
Compute distance between lines.
Definition geom.cpp:412
double inscribedRadiusInBox(size_t dim, const std::pair< util::Point, util::Point > &box)
Computes the radius of biggest circle/sphere completely within the object.
Definition geom.cpp:183
bool isPointInsideAngledRectangle(util::Point x, double x_min, double x_max, double y_min, double y_max, double theta)
Checks if point is inside an angled rectangle.
Definition geom.cpp:249
bool isPointInsideCylinder(const util::Point &p, const double &length, const double &radius, const util::Point &axis)
Returns true if point is inside the cylinder.
Definition geom.cpp:296
double pointDistanceSegment(const util::Point &p, const std::pair< util::Point, util::Point > &line)
Compute distance between point and line.
Definition geom.cpp:517
std::pair< util::Point, util::Point > toPointBox(const std::vector< double > &p1, const std::vector< double > &p2)
Create box from two coordinate data.
Definition geom.cpp:634
std::vector< double > rotateCW2D(const std::vector< double > &x, const double &theta)
Rotates a vector in xy-plane in clockwise direction.
double triangleArea(const util::Point &x1, const util::Point &x2, const util::Point &x3)
Compute area of triangle.
Definition geom.cpp:642
double computeInscribedRadius(const std::pair< util::Point, util::Point > &box)
Computes maximum radius of circle/sphere within a given box.
Definition geom.cpp:628
bool isPointInsideRectangle(util::Point x, double x_min, double x_max, double y_min, double y_max)
Checks if point is inside a rectangle.
Definition geom.cpp:231
double circumscribedRadiusInBox(size_t dim, const std::pair< util::Point, util::Point > &box)
Computes the radius of smallest circle/sphere which can have the box inside.
Definition geom.cpp:208
A structure to represent 3d vectors.
Definition point.h:30
double d_y
the y coordinate
Definition point.h:36
double d_z
the z coordinate
Definition point.h:39
double length() const
Computes the Euclidean length of the vector.
Definition point.h:118
double lengthSq() const
Computes the Euclidean length of the vector.
Definition point.h:124
double d_x
the x coordinate
Definition point.h:33