17 const std::vector<double> ¶ms,
18 const std::vector<size_t> &num_params_needed) {
20 std::ostringstream oss;
22 oss <<
"Error: Number of parameters needed to create geometry = "
23 << geom_type <<
" are "
25 <<
". But the number of parameters provided are "
27 <<
" and the parameters are "
55 return {d_vertices[0] - tol, d_vertices[1] + tol};
70 auto da = (d_vertices[1] - d_vertices[0]) / d_L;
71 auto db = x - d_vertices[0];
78 auto dx = db -
dot * da;
89 const double &tol)
const {
91 auto da = (d_vertices[1] - d_vertices[0]) / d_L;
92 auto db = x - d_vertices[0];
98 auto dx = db -
dot * da;
104 const double &tol,
const bool
108 if (!isNear(x, within ? 0. : tol))
111 auto da = (d_vertices[1] - d_vertices[0]) / d_L;
112 auto db = x - d_vertices[0];
113 double dot = db * da;
119 auto dx = db -
dot * da;
126 return isNearBoundary(x, 1.0E-8,
false);
130 const std::pair<util::Point, util::Point> &box)
const {
136 const std::pair<util::Point, util::Point> &box)
const {
142 const std::pair<util::Point, util::Point> &box,
143 const double &tol)
const {
149 const std::pair<util::Point, util::Point> &box)
const {
158 std::ostringstream oss;
160 oss << tabS <<
"------- Line --------" << std::endl << std::endl;
161 oss << tabS <<
"Name = " << d_name << std::endl;
162 oss << tabS <<
"Length = " << d_L << std::endl;
163 oss << tabS <<
"Point 1 = " << d_vertices[0].printStr(0, lvl) << std::endl;
164 oss << tabS <<
"Point 2 = " << d_vertices[1].printStr(0, lvl) << std::endl;
168 oss << tabS <<
"Bounding box: "
183 return d_r * d_r * (1. + std::sin(M_PI / 3));
199 auto p1 =
util::Point(d_x.d_x - d_r, d_x.d_y - d_r, d_x.d_z);
200 auto p2 =
util::Point(d_x.d_x + d_r, d_x.d_y + d_r, d_x.d_z);
202 return {p1 - tol, p2 + tol};
207 return d_r * std::sin(M_PI / 3);
217 if ((x - d_x).length() > d_r)
220 if ((x - d_x).length() < this->inscribedRadius())
223 double a = this->volume();
231 return (a1 + a2 + a3 < a);
239 const double &tol)
const {
242 auto bbox = box(tol);
248 const double &tol,
const bool
252 if (!isNear(x, within ? 0. : tol))
255 double a = this->volume();
256 double l = 0.5 * std::sqrt(a);
278 return isNearBoundary(x, 1.0E-8,
false);
282 const std::pair<util::Point, util::Point> &box)
const {
285 if (!this->isInside(p))
292 const std::pair<util::Point, util::Point> &box)
const {
294 bool intersect =
false;
297 intersect = this->isInside(p);
303 const std::pair<util::Point, util::Point> &box,
304 const double &tol)
const {
310 const std::pair<util::Point, util::Point> &box)
const {
314 if (this->isInside(p))
324 std::ostringstream oss;
326 oss << tabS <<
"------- Triangle --------" << std::endl << std::endl;
327 oss << tabS <<
"Name = " << d_name << std::endl;
328 oss << tabS <<
"Center = " << d_x.printStr(0, lvl) << std::endl;
329 oss << tabS <<
"Radius = " << d_r << std::endl;
346 return std::pow(d_L, 2);
360 return {
util::Point(d_vertices[0].d_x - tol, d_vertices[0].d_y - tol,
362 util::Point(d_vertices[2].d_x + tol, d_vertices[2].d_y + tol,
385 const double &tol)
const {
388 auto bbox = box(tol);
394 const double &tol,
const bool
398 if (!isNear(x, within ? 0. : tol))
401 bool near_x_edge =
util::isLess(std::abs(x.
d_x - d_vertices[0].d_x), tol) or
404 bool near_y_edge =
util::isLess(std::abs(x.
d_y - d_vertices[0].d_y), tol) or
407 return near_x_edge || near_y_edge;
412 return isNearBoundary(x, 1.0E-8,
false);
416 const std::pair<util::Point, util::Point> &box)
const {
419 if(!this->isInside(p))
426 const std::pair<util::Point, util::Point> &box)
const {
428 bool intersect =
false;
431 intersect = this->isInside(p);
437 const std::pair<util::Point, util::Point> &box,
const double &tol)
const {
443 const std::pair<util::Point, util::Point> &box)
const {
447 if (this->isInside(p))
457 std::ostringstream oss;
459 oss << tabS <<
"------- Rectangle --------" << std::endl << std::endl;
460 oss << tabS <<
"Name = " << d_name << std::endl;
461 oss << tabS <<
"Length = " << d_L << std::endl;
462 oss << tabS <<
"Bounding radius = " << d_r << std::endl;
463 oss << tabS <<
"Center = " << d_x.printStr(0, lvl) << std::endl;
497 return {
util::Point(d_vertices[0].d_x - tol, d_vertices[0].d_y - tol,
499 util::Point(d_vertices[2].d_x + tol, d_vertices[2].d_y + tol,
522 const double &tol)
const {
525 auto bbox = box(tol);
531 const double &tol,
const bool
535 if (!isNear(x, within ? 0. : tol))
538 bool near_x_edge =
util::isLess(std::abs(x.
d_x - d_vertices[0].d_x), tol) or
541 bool near_y_edge =
util::isLess(std::abs(x.
d_y - d_vertices[0].d_y), tol) or
544 return near_x_edge || near_y_edge;
549 return isNearBoundary(x, 1.0E-8,
false);
553 const std::pair<util::Point, util::Point> &box)
const {
556 if (!this->isInside(p))
563 const std::pair<util::Point, util::Point> &box)
const {
565 bool intersect =
false;
568 intersect = this->isInside(p);
574 const std::pair<util::Point, util::Point> &box,
575 const double &tol)
const {
581 const std::pair<util::Point, util::Point> &box)
const {
585 if (this->isInside(p))
595 std::ostringstream oss;
597 oss << tabS <<
"------- Rectangle --------" << std::endl << std::endl;
598 oss << tabS <<
"Name = " << d_name << std::endl;
599 oss << tabS <<
"Lengths (Lx, Ly) = (" << d_Lx <<
", " << d_Ly <<
")" << std::endl;
600 oss << tabS <<
"Bounding circle radius = " << d_r << std::endl;
605 oss << tabS <<
"Bounding box: "
621 double r_small = this->inscribedRadius();
622 return 2. * std::sqrt(3.) * r_small * r_small;
637 auto p1 = d_x -
util::Point(d_r + tol, d_r + tol, d_x[2] + tol);
638 auto p2 = d_x +
util::Point(d_r + tol, d_r + tol, d_x[2] + tol);
644 return d_r * 0.5 * std::sqrt(3.);
654 if ((x - d_x).length() > d_r)
657 if ((x - d_x).length() < inscribedRadius())
668 const double &tol)
const {
671 auto bbox = box(tol);
677 const double &tol,
const bool
680 if ((x - d_x).length() > d_r + tol)
683 if ((x - d_x).length() < inscribedRadius() - tol)
691 return isNearBoundary(x, 1.0E-8,
false);
695 const std::pair<util::Point, util::Point> &box)
const {
698 if (!this->isInside(p))
705 const std::pair<util::Point, util::Point> &box)
const {
707 bool intersect =
false;
710 intersect = this->isInside(p);
716 const std::pair<util::Point, util::Point> &box,
717 const double &tol)
const {
723 const std::pair<util::Point, util::Point> &box)
const {
727 if (this->isInside(p))
737 std::ostringstream oss;
739 oss << tabS <<
"------- Hexagon --------" << std::endl << std::endl;
740 oss << tabS <<
"Name = " << d_name << std::endl;
741 oss << tabS <<
"Radius = " << d_r << std::endl;
742 oss << tabS <<
"Center = " << d_x.printStr(0, lvl) << std::endl;
743 oss << tabS <<
"Axis = " << d_a.printStr(0, lvl) << std::endl;
761 return (2. * d_r * d_r - d_r * (d_r - 2. * d_w)) * std::sin(M_PI / 3.);
776 auto p1 = d_x -
util::Point(d_r + tol, d_r + tol, d_x[2] + tol);
777 auto p2 = d_x +
util::Point(d_r + tol, d_r + tol, d_x[2] + tol);
793 if ((x - d_x).length() > d_r)
796 if ((x - d_x).length() < inscribedRadius())
811 double angle_ox_ov1 = std::acos(std::abs(d_a.dot(ox)) / ox.length());
812 double max_length = d_w + angle_ox_ov1 * (d_r - d_w) / (M_PI / 3.);
814 return ox.length() <= max_length;
822 const double &tol)
const {
825 auto bbox = box(tol);
831 const double &tol,
const bool
834 if ((x - d_x).length() > d_r + tol)
837 if ((x - d_x).length() < this->inscribedRadius() - tol)
845 return isNearBoundary(x, 1.0E-8,
false);
849 const std::pair<util::Point, util::Point> &box)
const {
852 if (!this->isInside(p))
859 const std::pair<util::Point, util::Point> &box)
const {
861 bool intersect =
false;
864 intersect = this->isInside(p);
870 const std::pair<util::Point, util::Point> &box,
871 const double &tol)
const {
877 const std::pair<util::Point, util::Point> &box)
const {
881 if (this->isInside(p))
891 std::ostringstream oss;
893 oss << tabS <<
"------- Drum2D --------" << std::endl << std::endl;
894 oss << tabS <<
"Name = " << d_name << std::endl;
895 oss << tabS <<
"Radius = " << d_r << std::endl;
896 oss << tabS <<
"Neck half-width = " << d_w << std::endl;
897 oss << tabS <<
"Center = " << d_x.printStr(0, lvl) << std::endl;
898 oss << tabS <<
"Axis = " << d_a.printStr(0, lvl) << std::endl;
915 return std::pow(d_L, 3);
929 return {
util::Point(d_vertices[0].d_x - tol, d_vertices[0].d_y - tol,
930 d_vertices[0].d_z - tol),
931 util::Point(d_vertices[6].d_x + tol, d_vertices[6].d_y + tol,
932 d_vertices[6].d_z + tol)};
954 const double &tol)
const {
957 auto bbox = box(tol);
963 const double &tol,
const bool
967 if (!isNear(x, within ? 0. : tol))
970 bool near_x_edge =
util::isLess(std::abs(x.
d_x - d_vertices[0].d_x), tol) or
973 bool near_y_edge =
util::isLess(std::abs(x.
d_y - d_vertices[0].d_y), tol) or
976 bool near_z_edge =
util::isLess(std::abs(x.
d_z - d_vertices[0].d_z), tol) or
979 return near_x_edge || near_y_edge || near_z_edge;
984 return isNearBoundary(x, 1.0E-8,
false);
988 const std::pair<util::Point, util::Point> &box)
const {
991 if (!this->isInside(p))
998 const std::pair<util::Point, util::Point> &box)
const {
1000 bool intersect =
false;
1003 intersect = this->isInside(p);
1009 const std::pair<util::Point, util::Point> &bbox,
const double &tol)
1016 const std::pair<util::Point, util::Point> &box)
const {
1020 if (this->isInside(p))
1030 std::ostringstream oss;
1032 oss << tabS <<
"------- Cube --------" << std::endl << std::endl;
1033 oss << tabS <<
"Name = " << d_name << std::endl;
1034 oss << tabS <<
"Length = " << d_L << std::endl;
1035 oss << tabS <<
"Bounding sphere radius = " << d_r << std::endl;
1036 oss << tabS <<
"Center = " << d_x.printStr(0, 0) << std::endl;
1041 oss << tabS <<
"Bounding box: "
1056 return d_Lx * d_Ly * d_Lz;
1069 double &tol)
const {
1070 return {
util::Point(d_vertices[0].d_x - tol, d_vertices[0].d_y - tol,
1071 d_vertices[0].d_z - tol),
1072 util::Point(d_vertices[6].d_x + tol, d_vertices[6].d_y + tol,
1073 d_vertices[6].d_z + tol)};
1092 return !isInside(x);
1096 const double &tol)
const {
1099 auto bbox = box(tol);
1105 const double &tol,
const bool
1109 if (!isNear(x, within ? 0. : tol))
1112 bool near_x_edge =
util::isLess(std::abs(x.
d_x - d_vertices[0].d_x), tol) or
1115 bool near_y_edge =
util::isLess(std::abs(x.
d_y - d_vertices[0].d_y), tol) or
1118 bool near_z_edge =
util::isLess(std::abs(x.
d_z - d_vertices[0].d_z), tol) or
1121 return near_x_edge || near_y_edge || near_z_edge;
1126 return isNearBoundary(x, 1.0E-8,
false);
1130 const std::pair<util::Point, util::Point> &box)
const {
1133 if (!this->isInside(p))
1140 const std::pair<util::Point, util::Point> &box)
const {
1142 bool intersect =
false;
1145 intersect = this->isInside(p);
1151 const std::pair<util::Point, util::Point> &bbox,
const double &tol)
1158 const std::pair<util::Point, util::Point> &box)
const {
1162 if (this->isInside(p))
1172 std::ostringstream oss;
1174 oss << tabS <<
"------- Cuboid --------" << std::endl << std::endl;
1175 oss << tabS <<
"Name = " << d_name << std::endl;
1176 oss << tabS <<
"Lengths (Lx, Ly, Lz) = "
1179 oss << tabS <<
"Bounding sphere radius = " << d_r << std::endl;
1180 oss << tabS <<
"Center = " << d_x.printStr(0, 0) << std::endl;
1185 oss << tabS <<
"Bounding box: "
1200 return M_PI * d_r * d_r;
1213 double &tol)
const {
1214 double r = d_r + tol;
1237 return !isInside(x);
1241 const double &tol)
const {
1250 const double &tol,
const bool
1254 if (!isNear(x, within ? 0. : tol))
1266 return isNearBoundary(x, 1.0E-8,
false);
1270 const std::pair<util::Point, util::Point> &box)
const {
1273 if (!this->isInside(p))
1280 const std::pair<util::Point, util::Point> &box)
const {
1282 bool intersect =
false;
1285 intersect = this->isInside(p);
1291 const std::pair<util::Point, util::Point> &box,
1292 const double &tol)
const {
1294 if (this->isInside(box))
1322 const std::pair<util::Point, util::Point> &box)
const {
1326 if (this->isInside(p))
1336 std::ostringstream oss;
1338 oss << tabS <<
"------- Circle --------" << std::endl << std::endl;
1339 oss << tabS <<
"Name = " << d_name << std::endl;
1340 oss << tabS <<
"Center = " << d_x.printStr(0, lvl) << std::endl;
1341 oss << tabS <<
"Radius = " << d_r << std::endl;
1344 oss << tabS <<
"Bounding box: "
1359 return M_PI * d_r * d_r * d_l;
1371 std::pair<util::Point, util::Point>
1374 if (d_xa.length() < 1.0E-10)
1377 auto xb = d_xBegin - tol * d_xa;
1378 auto xt = d_xBegin + (d_l + tol) * d_xa;
1380 double r = d_r + tol;
1382 return {xb - r, xt + r};
1387 auto box = this->box();
1389 return 0.5 * (box.second - box.first).length();
1394 return 0.5 * std::sqrt(d_l * d_l + 4. * d_r * d_r);
1399 auto dx = x - d_xBegin;
1401 if (dx.length() < 1.0E-10)
1404 double dx_dot_xa = dx * d_xa;
1411 auto dx_project = dx - dx_dot_xa * d_xa;
1418 return !isInside(x);
1424 auto dx = x - d_xBegin;
1426 if (dx.length() < tol)
1429 double dx_dot_xa = dx * d_xa;
1436 auto dx_project = dx - dx_dot_xa * d_xa;
1443 const double &tol,
const bool
1446 auto dx = x - d_xBegin;
1448 if (dx.length() < tol)
1451 double dx_dot_xa = dx * d_xa;
1460 auto dx_project = dx - dx_dot_xa * d_xa;
1462 return !(
util::isLess(dx_project.length(), d_r - tol) or
1469 return isNearBoundary(x, 1.0E-8,
false);
1473 const std::pair<util::Point, util::Point> &box)
const {
1476 if (!this->isInside(p))
1483 const std::pair<util::Point, util::Point> &box)
const {
1485 bool intersect =
false;
1488 intersect = this->isInside(p);
1494 const std::pair<util::Point, util::Point> &box,
1495 const double &tol)
const {
1501 const std::pair<util::Point, util::Point> &box)
const {
1505 if (this->isInside(p))
1516 std::ostringstream oss;
1518 oss << tabS <<
"------- Cylinder --------" << std::endl << std::endl;
1519 oss << tabS <<
"Name = " << d_name << std::endl;
1520 oss << tabS <<
"Center = " << d_xBegin.printStr(0, lvl) << std::endl;
1521 oss << tabS <<
"Axis = " << d_xa.printStr(0, lvl) << std::endl;
1522 oss << tabS <<
"Radius = " << d_r << std::endl;
1523 oss << tabS <<
"Center = " << d_x.printStr(0, 0) << std::endl;
1526 oss << tabS <<
"Bounding box: "
1542 return 4. * M_PI * d_r * d_r * d_r / 3.;
1555 double &tol)
const {
1556 double r = d_r + tol;
1559 util::Point(d_x.d_x - r, d_x.d_y - r, d_x.d_z - r),
1560 util::Point(d_x.d_x + r, d_x.d_y + r, d_x.d_z + r)
1580 return !isInside(x);
1584 const double &tol)
const {
1593 const double &tol,
const bool
1597 if (!isNear(x, within ? 0. : tol))
1609 return isNearBoundary(x, 1.0E-8,
false);
1613 const std::pair<util::Point, util::Point> &box)
const {
1616 if (!this->isInside(p))
1623 const std::pair<util::Point, util::Point> &box)
const {
1625 bool intersect =
false;
1628 intersect = this->isInside(p);
1634 const std::pair<util::Point, util::Point> &box,
1635 const double &tol)
const {
1637 if (this->isInside(box))
1665 const std::pair<util::Point, util::Point> &box)
const {
1669 if (this->isInside(p))
1679 std::ostringstream oss;
1681 oss << tabS <<
"------- Sphere --------" << std::endl << std::endl;
1682 oss << tabS <<
"Name = " << d_name << std::endl;
1683 oss << tabS <<
"Center = " << d_x.printStr(0, lvl) << std::endl;
1684 oss << tabS <<
"Radius = " << d_r << std::endl;
1687 oss << tabS <<
"Bounding box: "
1703 return d_outObj_p->volume() - d_inObj_p->volume();
1712 auto vol = volume();
1714 return (1./vol) * (d_outObj_p->volume() * d_outObj_p->center()
1715 - d_inObj_p->volume() * d_inObj_p->center());
1717 return d_outObj_p->center();
1722 return d_outObj_p->box();
1726 (
const double &tol)
const {
1727 return d_outObj_p->box(tol);
1732 return d_outObj_p->inscribedRadius();
1737 return d_outObj_p->boundingRadius();
1744 return !d_inObj_p->isInside(x) && d_outObj_p->isInside(x);
1749 return !isInside(x);
1753 const double &tol)
const {
1755 return d_outObj_p->isNear(x, tol) || d_inObj_p->isNear(x, tol);
1763 return d_outObj_p->isNearBoundary(x, tol, within) ||
1764 d_inObj_p->isNearBoundary(x, tol, within);
1770 return isNearBoundary(x, 1.0E-8,
false);
1774 const std::pair<util::Point, util::Point> &box)
const {
1777 if (!this->isInside(p))
1784 const std::pair<util::Point, util::Point> &box)
const {
1786 bool intersect =
false;
1788 intersect = this->isInside(p);
1794 const std::pair<util::Point, util::Point> &box,
1795 const double &tol)
const {
1797 return d_outObj_p->isNear(box, tol) || d_inObj_p->isNear(box, tol);
1801 const std::pair<util::Point, util::Point> &box)
const {
1805 if (this->isInside(p))
1816 std::ostringstream oss;
1818 oss << tabS <<
"------- AnnulusGeomObject --------" << std::endl
1820 oss << tabS <<
"Name = " << d_name << std::endl;
1821 oss << tabS <<
"Center = " << center().printStr() << std::endl;
1822 oss << tabS <<
"Inner object info:" << std::endl;
1823 oss << d_inObj_p->printStr(nt + 1, lvl);
1824 oss << tabS <<
"Outer object info:" << std::endl;
1825 oss << d_outObj_p->printStr(nt + 1, lvl);
1828 oss << tabS <<
"Bounding box: "
1846 for (
size_t i = 0; i < d_objFlag.size(); i++)
1847 volume += d_obj[i]->volume() * d_objFlagInt[i];
1855 auto vol = volume();
1858 for (
size_t i = 0; i < d_objFlag.size(); i++)
1859 center += d_obj[i]->volume() * d_objFlagInt[i] * d_obj[i]->center();
1860 return (1./vol) * center;
1866 std::vector<double> vol_vec(d_obj.size());
1867 for (
size_t i = 0; i < d_obj.size(); i++)
1868 vol_vec[i] = d_obj[i]->volume() * d_objFlagInt[i];
1871 return d_obj[max_vol_obj]->center();
1882 (
const double &tol)
const {
1884 auto p1 = d_obj[0]->box(tol).first;
1885 auto p2 = d_obj[0]->box(tol).second;
1887 for (
size_t i = 1; i < d_objFlag.size(); i++) {
1889 auto q1 = d_obj[i]->box(tol).first;
1890 auto q2 = d_obj[i]->box(tol).second;
1892 for (
size_t i = 0; i < 3; i++) {
1900 return std::make_pair(p1, p2);
1905 auto box = this->box();
1906 return 0.5 * (box.first - box.second).length();
1911 auto box = this->box();
1912 return 0.5 * (box.first - box.second).length();
1920 bool point_inside = d_obj[0]->isInside(x);
1921 for (
size_t i = 1; i < d_objFlag.size(); i++) {
1923 const auto &obj_i = d_obj[i];
1924 if (d_objFlagInt[i] < 0)
1925 point_inside = point_inside and !obj_i->isInside(x);
1927 point_inside = point_inside or obj_i->isInside(x);
1930 return point_inside;
1935 return !isInside(x);
1939 const double &tol)
const {
1941 bool is_near = d_obj[0]->isNear(x, tol);
1942 for (
size_t i = 1; i < d_objFlag.size(); i++) {
1944 const auto &obj_i = d_obj[i];
1945 is_near = is_near or obj_i->isNear(x, tol);
1956 bool is_near = d_obj[0]->isNearBoundary(x, tol, within);
1957 for (
size_t i = 1; i < d_objFlag.size(); i++) {
1959 const auto &obj_i = d_obj[i];
1960 is_near = is_near or obj_i->isNearBoundary(x, tol, within);
1969 return isNearBoundary(x, 1.0E-8,
false);
1973 const std::pair<util::Point, util::Point> &box)
const {
1976 if (!this->isInside(p))
1983 const std::pair<util::Point, util::Point> &box)
const {
1985 bool intersect =
false;
1987 intersect = this->isInside(p);
1993 const std::pair<util::Point, util::Point> &box,
1994 const double &tol)
const {
1996 bool is_near = d_obj[0]->isNear(box, tol);
1997 for (
size_t i = 1; i < d_objFlag.size(); i++) {
1999 const auto &obj_i = d_obj[i];
2000 is_near = is_near or obj_i->isNear(box, tol);
2007 const std::pair<util::Point, util::Point> &box)
const {
2011 if (this->isInside(p))
2022 std::ostringstream oss;
2024 oss << tabS <<
"------- ComplexGeomObject --------" << std::endl
2026 oss << tabS <<
"Name = " << d_name << std::endl;
2027 oss << tabS <<
"Center = " << center().printStr() << std::endl;
2028 oss << tabS <<
"Object info:" << std::endl;
2030 for (
const auto &p: d_obj) {
2031 oss << tabS <<
"Object id: " << ocount << std::endl;
2032 oss << tabS <<
"Object flag: " << d_objFlag[ocount] << std::endl;
2033 oss << tabS <<
"Object int flag: " << d_objFlagInt[ocount] << std::endl;
2034 oss << p->printStr(nt + 1, lvl);
2039 oss << tabS <<
"Bounding box: "
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
util::Point center() const override
Computes the center of object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
util::Point center() const override
Computes the center of object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
util::Point center() const override
Computes the center of object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
util::Point center() const override
Computes the center of object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
util::Point center() const override
Computes the center of object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
util::Point center() const override
Computes the center of object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
util::Point center() const override
Computes the center of object.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
util::Point center() const override
Computes the center of object.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
util::Point center() const override
Computes the center of object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
util::Point center() const override
Computes the center of object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
util::Point center() const override
Computes the center of object.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
util::Point center() const override
Computes the center of object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
util::Point center() const override
Computes the center of object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
std::string printErrMsg(const std::string &geom_type, const std::vector< double > ¶ms, const std::vector< size_t > &num_params_needed)
std::string printBoxStr(const std::pair< util::Point, util::Point > &box, int nt=print_default_tab)
Returns formatted string for output.
std::string getTabS(int nt)
Returns tab spaces of given size.
std::string printStr(const T &msg, int nt=print_default_tab)
Returns formatted string for output.
size_t maxIndex(const std::vector< T > &data)
Returns the index corresponding to maximum from list of data.
Collection of methods useful in simulation.
bool isPointInsideBox(util::Point x, size_t dim, const std::pair< util::Point, util::Point > &box)
Returns true if point is inside box.
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.
bool isGreater(const double &a, const double &b)
Returns true if a > b.
bool isPointInsideCuboid(util::Point x, util::Point x_lbb, util::Point x_rtf)
Checks if point is inside a cuboid.
std::vector< util::Point > getCornerPoints(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.
bool isLess(const double &a, const double &b)
Returns true if a < b.
util::Point getCenter(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns center point.
std::vector< double > dot(const std::vector< std::vector< double > > &m, const std::vector< double > &v)
Computes the dot product between matrix and vector.
double inscribedRadiusInBox(size_t dim, const std::pair< util::Point, util::Point > &box)
Computes the radius of biggest circle/sphere completely within the object.
double triangleArea(const util::Point &x1, const util::Point &x2, const util::Point &x3)
Compute area of triangle.
bool isPointInsideRectangle(util::Point x, double x_min, double x_max, double y_min, double y_max)
Checks if point is inside a rectangle.
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.
util::Point rotate(const util::Point &p, const double &theta, const util::Point &axis)
Returns the vector after rotating by desired angle.
A structure to represent 3d vectors.
double d_y
the y coordinate
double d_z
the z coordinate
double d_x
the x coordinate