24 const std::vector<double> ¶ms,
25 const std::vector<size_t> &num_params_needed) {
27 std::ostringstream oss;
29 oss <<
"Error: Number of parameters needed to create geometry = "
30 << geom_type <<
" are "
32 <<
". But the number of parameters provided are "
34 <<
" and the parameters are "
53 const double gap = (x -
d_p) * n;
81 const double nl = n.
length();
86 double s = ((x - a) * t) / t2;
93 if (s > 1.e-12 && s < 1. - 1.e-12) {
97 const double dist = dx.
length();
98 if (!(dist > 1.e-16)) {
145 double dot = db * da;
151 auto dx = db - dot * da;
162 const double &tol)
const {
166 double dot = db * da;
171 auto dx = db - dot * da;
177 const double &tol,
const bool
181 if (!
isNear(x, within ? 0. : tol))
186 double dot = db * da;
192 auto dx = db - dot * da;
203 const std::pair<util::Point, util::Point> &box)
const {
209 const std::pair<util::Point, util::Point> &box)
const {
215 const std::pair<util::Point, util::Point> &box,
216 const double &tol)
const {
222 const std::pair<util::Point, util::Point> &box)
const {
231 std::ostringstream oss;
233 oss << tabS <<
"------- Line --------" << std::endl << std::endl;
234 oss << tabS <<
"Name = " <<
d_name << std::endl;
235 oss << tabS <<
"Length = " <<
d_L << std::endl;
236 oss << tabS <<
"Point 1 = " <<
d_vertices[0].printStr(0, lvl) << std::endl;
237 oss << tabS <<
"Point 2 = " <<
d_vertices[1].printStr(0, lvl) << std::endl;
241 oss << tabS <<
"Bounding box: "
274 p1.
d_x = std::min(p1.
d_x, v.d_x);
275 p1.
d_y = std::min(p1.
d_y, v.d_y);
276 p1.
d_z = std::min(p1.
d_z, v.d_z);
277 p2.d_x = std::max(p2.d_x, v.d_x);
278 p2.d_y = std::max(p2.d_y, v.d_y);
279 p2.d_z = std::max(p2.d_z, v.d_z);
281 return {p1 - tol, p2 + tol};
286 return d_r * std::sin(M_PI / 3);
296 if ((x -
d_x).length() >
d_r)
302 double a = this->
volume();
310 return (a1 + a2 + a3 <= a * (1.0 + 1.0e-10));
318 const double &tol)
const {
321 auto bbox =
box(tol);
327 const double &tol,
const bool
331 if (!
isNear(x, within ? 0. : tol))
334 double a = this->
volume();
335 double l = 0.5 * std::sqrt(a);
361 const std::pair<util::Point, util::Point> &box)
const {
371 const std::pair<util::Point, util::Point> &box)
const {
373 bool intersect =
false;
382 const std::pair<util::Point, util::Point> &box,
383 const double &tol)
const {
389 const std::pair<util::Point, util::Point> &box)
const {
403 std::ostringstream oss;
405 oss << tabS <<
"------- Triangle --------" << std::endl << std::endl;
406 oss << tabS <<
"Name = " <<
d_name << std::endl;
407 oss << tabS <<
"Center = " <<
d_x.
printStr(0, lvl) << std::endl;
408 oss << tabS <<
"Radius = " <<
d_r << std::endl;
425 return std::pow(
d_L, 2);
464 const double &tol)
const {
467 auto bbox =
box(tol);
473 const double &tol,
const bool
477 if (!
isNear(x, within ? 0. : tol))
486 return near_x_edge || near_y_edge;
495 const std::pair<util::Point, util::Point> &box)
const {
505 const std::pair<util::Point, util::Point> &box)
const {
507 bool intersect =
false;
516 const std::pair<util::Point, util::Point> &box,
const double &tol)
const {
522 const std::pair<util::Point, util::Point> &box)
const {
536 std::ostringstream oss;
538 oss << tabS <<
"------- Rectangle --------" << std::endl << std::endl;
539 oss << tabS <<
"Name = " <<
d_name << std::endl;
540 oss << tabS <<
"Length = " <<
d_L << std::endl;
541 oss << tabS <<
"Bounding radius = " <<
d_r << std::endl;
542 oss << tabS <<
"Center = " <<
d_x.
printStr(0, lvl) << std::endl;
564 const auto bb =
box();
565 const double x0 = bb.first.d_x;
566 const double y0 = bb.first.d_y;
567 const double x1 = bb.second.d_x;
568 const double y1 = bb.second.d_y;
569 if (!(x1 > x0) || !(y1 > y0))
572 const double dx = std::max(x0 - x.
d_x, x.
d_x - x1);
573 const double dy = std::max(y0 - x.
d_y, x.
d_y - y1);
574 const bool outside = dx > 0. || dy > 0.;
589 const double dist = d.
length();
590 if (!(dist > 1.e-16)) {
606 const double dl = x.
d_x - x0;
607 const double dr = x1 - x.
d_x;
608 const double db = x.
d_y - y0;
609 const double dt = y1 - x.
d_y;
610 const double m = std::min(std::min(dl, dr), std::min(db, dt));
615 }
else if (m == dr) {
618 }
else if (m == db) {
671 const double &tol)
const {
674 auto bbox =
box(tol);
680 const double &tol,
const bool
684 if (!
isNear(x, within ? 0. : tol))
693 return near_x_edge || near_y_edge;
702 const std::pair<util::Point, util::Point> &box)
const {
712 const std::pair<util::Point, util::Point> &box)
const {
714 bool intersect =
false;
723 const std::pair<util::Point, util::Point> &box,
724 const double &tol)
const {
730 const std::pair<util::Point, util::Point> &box)
const {
744 std::ostringstream oss;
746 oss << tabS <<
"------- Rectangle --------" << std::endl << std::endl;
747 oss << tabS <<
"Name = " <<
d_name << std::endl;
748 oss << tabS <<
"Lengths (Lx, Ly) = (" <<
d_Lx <<
", " <<
d_Ly <<
")" << std::endl;
749 oss << tabS <<
"Bounding circle radius = " <<
d_r << std::endl;
754 oss << tabS <<
"Bounding box: "
771 return 2. * std::sqrt(3.) * r_small * r_small;
793 return d_r * 0.5 * std::sqrt(3.);
803 if ((x -
d_x).length() >
d_r)
817 const double &tol)
const {
820 auto bbox =
box(tol);
826 const double &tol,
const bool
829 if ((x -
d_x).length() >
d_r + tol)
844 const std::pair<util::Point, util::Point> &box)
const {
854 const std::pair<util::Point, util::Point> &box)
const {
856 bool intersect =
false;
865 const std::pair<util::Point, util::Point> &box,
866 const double &tol)
const {
872 const std::pair<util::Point, util::Point> &box)
const {
886 std::ostringstream oss;
888 oss << tabS <<
"------- Hexagon --------" << std::endl << std::endl;
889 oss << tabS <<
"Name = " <<
d_name << std::endl;
890 oss << tabS <<
"Radius = " <<
d_r << std::endl;
891 oss << tabS <<
"Center = " <<
d_x.
printStr(0, lvl) << std::endl;
892 oss << tabS <<
"Axis = " <<
d_a.
printStr(0, lvl) << std::endl;
910 return (2. *
d_r *
d_r -
d_r * (
d_r - 2. *
d_w)) * std::sin(M_PI / 3.);
942 if ((x -
d_x).length() >
d_r)
960 double angle_ox_ov1 = std::acos(std::abs(
d_a.
dot(ox)) / ox.length());
961 double max_length =
d_w + angle_ox_ov1 * (
d_r -
d_w) / (M_PI / 3.);
963 return ox.length() <= max_length;
971 const double &tol)
const {
974 auto bbox =
box(tol);
980 const double &tol,
const bool
983 if ((x -
d_x).length() >
d_r + tol)
998 const std::pair<util::Point, util::Point> &box)
const {
1008 const std::pair<util::Point, util::Point> &box)
const {
1010 bool intersect =
false;
1019 const std::pair<util::Point, util::Point> &box,
1020 const double &tol)
const {
1026 const std::pair<util::Point, util::Point> &box)
const {
1040 std::ostringstream oss;
1042 oss << tabS <<
"------- Drum2D --------" << std::endl << std::endl;
1043 oss << tabS <<
"Name = " <<
d_name << std::endl;
1044 oss << tabS <<
"Radius = " <<
d_r << std::endl;
1045 oss << tabS <<
"Neck half-width = " <<
d_w << std::endl;
1046 oss << tabS <<
"Center = " <<
d_x.
printStr(0, lvl) << std::endl;
1047 oss << tabS <<
"Axis = " <<
d_a.
printStr(0, lvl) << std::endl;
1064 return std::pow(
d_L, 3);
1077 double &tol)
const {
1103 const double &tol)
const {
1106 auto bbox =
box(tol);
1112 const double &tol,
const bool
1116 if (!
isNear(x, within ? 0. : tol))
1128 return near_x_edge || near_y_edge || near_z_edge;
1137 const std::pair<util::Point, util::Point> &box)
const {
1147 const std::pair<util::Point, util::Point> &box)
const {
1149 bool intersect =
false;
1158 const std::pair<util::Point, util::Point> &bbox,
const double &tol)
1165 const std::pair<util::Point, util::Point> &box)
const {
1179 std::ostringstream oss;
1181 oss << tabS <<
"------- Cube --------" << std::endl << std::endl;
1182 oss << tabS <<
"Name = " <<
d_name << std::endl;
1183 oss << tabS <<
"Length = " <<
d_L << std::endl;
1184 oss << tabS <<
"Bounding sphere radius = " <<
d_r << std::endl;
1185 oss << tabS <<
"Center = " <<
d_x.
printStr(0, 0) << std::endl;
1190 oss << tabS <<
"Bounding box: "
1218 double &tol)
const {
1245 const double &tol)
const {
1248 auto bbox =
box(tol);
1254 const double &tol,
const bool
1258 if (!
isNear(x, within ? 0. : tol))
1270 return near_x_edge || near_y_edge || near_z_edge;
1279 const std::pair<util::Point, util::Point> &box)
const {
1289 const std::pair<util::Point, util::Point> &box)
const {
1291 bool intersect =
false;
1300 const std::pair<util::Point, util::Point> &bbox,
const double &tol)
1307 const std::pair<util::Point, util::Point> &box)
const {
1321 std::ostringstream oss;
1323 oss << tabS <<
"------- Cuboid --------" << std::endl << std::endl;
1324 oss << tabS <<
"Name = " <<
d_name << std::endl;
1325 oss << tabS <<
"Lengths (Lx, Ly, Lz) = "
1328 oss << tabS <<
"Bounding sphere radius = " <<
d_r << std::endl;
1329 oss << tabS <<
"Center = " <<
d_x.
printStr(0, 0) << std::endl;
1334 oss << tabS <<
"Bounding box: "
1362 double &tol)
const {
1363 double r =
d_r + tol;
1390 const double &tol)
const {
1399 const double &tol,
const bool
1403 if (!
isNear(x, within ? 0. : tol))
1419 const std::pair<util::Point, util::Point> &box)
const {
1429 const std::pair<util::Point, util::Point> &box)
const {
1431 bool intersect =
false;
1440 const std::pair<util::Point, util::Point> &box,
1441 const double &tol)
const {
1471 const std::pair<util::Point, util::Point> &box)
const {
1485 std::ostringstream oss;
1487 oss << tabS <<
"------- Circle --------" << std::endl << std::endl;
1488 oss << tabS <<
"Name = " <<
d_name << std::endl;
1489 oss << tabS <<
"Center = " <<
d_x.
printStr(0, lvl) << std::endl;
1490 oss << tabS <<
"Radius = " <<
d_r << std::endl;
1493 oss << tabS <<
"Bounding box: "
1510 if (a <= 0. || b <= 0.)
1512 return util::isLess(u * u / (a * a) + v * v / (b * b), 1. + 1.0E-12);
1518 const double c = std::cos(e.
d_theta);
1519 const double s = std::sin(e.
d_theta);
1520 u = c * dx + s * dy;
1521 v = -s * dx + c * dy;
1537 std::pair<util::Point, util::Point>
Ellipse::box(
const double &tol)
const {
1539 const double at =
d_a + tol;
1540 const double bt =
d_b + tol;
1541 const double ex = std::hypot(at * std::cos(
d_theta), bt * std::sin(
d_theta));
1542 const double ey = std::hypot(at * std::sin(
d_theta), bt * std::cos(
d_theta));
1557 double u = 0., v = 0.;
1558 ellipseLocal(*
this, x, u, v);
1559 return ellipseMetricInside(u, v,
d_a,
d_b);
1567 double u = 0., v = 0.;
1568 ellipseLocal(*
this, x, u, v);
1569 return ellipseMetricInside(u, v,
d_a + tol,
d_b + tol);
1574 double u = 0., v = 0.;
1575 ellipseLocal(*
this, x, u, v);
1576 const bool inOuter = ellipseMetricInside(u, v,
d_a + tol,
d_b + tol);
1577 const bool inInner = ellipseMetricInside(u, v,
d_a - tol,
d_b - tol);
1579 return inOuter && !inInner;
1598 bool intersect =
false;
1606 bool Ellipse::isNear(
const std::pair<util::Point, util::Point> &box,
const double &tol)
const {
1638 std::ostringstream oss;
1640 oss << tabS <<
"------- Ellipse --------" << std::endl << std::endl;
1641 oss << tabS <<
"Name = " <<
d_name << std::endl;
1642 oss << tabS <<
"Center = " <<
d_x.
printStr(0, lvl) << std::endl;
1643 oss << tabS <<
"Semi-axes a, b = " <<
d_a <<
", " <<
d_b << std::endl;
1644 oss << tabS <<
"Theta (rad) = " <<
d_theta << std::endl;
1647 oss << tabS <<
"Bounding box: "
1675 std::pair<util::Point, util::Point>
1684 double r =
d_r + tol;
1686 return {xb - r, xt + r};
1693 return 0.5 * (
box.second -
box.first).length();
1705 if (dx.length() < 1.0E-10)
1708 double dx_dot_xa = dx *
d_xa;
1715 auto dx_project = dx - dx_dot_xa *
d_xa;
1730 if (dx.length() < tol)
1733 double dx_dot_xa = dx *
d_xa;
1740 auto dx_project = dx - dx_dot_xa *
d_xa;
1747 const double &tol,
const bool
1752 if (dx.length() < tol)
1755 double dx_dot_xa = dx *
d_xa;
1764 auto dx_project = dx - dx_dot_xa *
d_xa;
1777 const std::pair<util::Point, util::Point> &box)
const {
1787 const std::pair<util::Point, util::Point> &box)
const {
1789 bool intersect =
false;
1798 const std::pair<util::Point, util::Point> &box,
1799 const double &tol)
const {
1805 const std::pair<util::Point, util::Point> &box)
const {
1820 std::ostringstream oss;
1822 oss << tabS <<
"------- Cylinder --------" << std::endl << std::endl;
1823 oss << tabS <<
"Name = " <<
d_name << std::endl;
1825 oss << tabS <<
"Axis = " <<
d_xa.
printStr(0, lvl) << std::endl;
1826 oss << tabS <<
"Radius = " <<
d_r << std::endl;
1827 oss << tabS <<
"Center = " <<
d_x.
printStr(0, 0) << std::endl;
1830 oss << tabS <<
"Bounding box: "
1846 return 4. * M_PI *
d_r *
d_r *
d_r / 3.;
1859 double &tol)
const {
1860 double r =
d_r + tol;
1888 const double &tol)
const {
1897 const double &tol,
const bool
1901 if (!
isNear(x, within ? 0. : tol))
1917 const std::pair<util::Point, util::Point> &box)
const {
1927 const std::pair<util::Point, util::Point> &box)
const {
1929 bool intersect =
false;
1938 const std::pair<util::Point, util::Point> &box,
1939 const double &tol)
const {
1969 const std::pair<util::Point, util::Point> &box)
const {
1983 std::ostringstream oss;
1985 oss << tabS <<
"------- Sphere --------" << std::endl << std::endl;
1986 oss << tabS <<
"Name = " <<
d_name << std::endl;
1987 oss << tabS <<
"Center = " <<
d_x.
printStr(0, lvl) << std::endl;
1988 oss << tabS <<
"Radius = " <<
d_r << std::endl;
1991 oss << tabS <<
"Bounding box: "
2009 static void quatMul(
double aw,
double ax,
double ay,
double az,
2010 double bw,
double bx,
double by,
double bz,
2011 double &cw,
double &cx,
double &cy,
double &cz) {
2012 cw = aw * bw - ax * bx - ay * by - az * bz;
2013 cx = aw * bx + ax * bw + ay * bz - az * by;
2014 cy = aw * by - ax * bz + ay * bw + az * bx;
2015 cz = aw * bz + ax * by - ay * bx + az * bw;
2019 double &w,
double &x,
double &y,
double &z) {
2020 if (std::abs(theta) < 1.0e-30) {
2025 const double L = axisIn.
length();
2032 const double half = 0.5 * theta;
2034 const double s = std::sin(half);
2042 double n = std::sqrt(qw * qw + qx * qx + qy * qy + qz * qz);
2058 qw = std::max(-1., std::min(1., qw));
2059 theta = 2. * std::acos(qw);
2060 const double sv = std::sqrt(qx * qx + qy * qy + qz * qz);
2070 double &v1,
double &v2) {
2072 v0 = R[0] * p.
d_x + R[3] * p.
d_y + R[6] * p.
d_z;
2073 v1 = R[1] * p.
d_x + R[4] * p.
d_y + R[7] * p.
d_z;
2074 v2 = R[2] * p.
d_x + R[5] * p.
d_y + R[8] * p.
d_z;
2078 const double &rb,
const double &rc) {
2082 const double dx = v0 / ra;
2083 const double dy = v1 / rb;
2084 const double dz = v2 / rc;
2085 return dx * dx + dy * dy + dz * dz;
2097 double ow, ox, oy, oz;
2100 double rw, rx, ry, rz;
2101 axisAngleToQuatSafe(axis, angle,
rw, rx, ry, rz);
2103 double nw, nx, ny, nz;
2104 quatMul(
rw, rx, ry, rz, ow, ox, oy, oz, nw, nx, ny, nz);
2107 d_x =
mapSimilarity(c0, c0, translation, scale, angle, axis, rotationPoint);
2111 return (4. / 3.) * M_PI *
d_a *
d_b *
d_c;
2124 const double ra =
d_a + tol;
2125 const double rb =
d_b + tol;
2126 const double rc =
d_c + tol;
2132 std::sqrt((ra * R[0]) * (ra * R[0]) + (rb * R[3]) * (rb * R[3]) + (rc * R[6]) * (rc * R[6]));
2134 std::sqrt((ra * R[1]) * (ra * R[1]) + (rb * R[4]) * (rb * R[4]) + (rc * R[7]) * (rc * R[7]));
2136 std::sqrt((ra * R[2]) * (ra * R[2]) + (rb * R[5]) * (rb * R[5]) + (rc * R[8]) * (rc * R[8]));
2161 if (
d_a <= 0. ||
d_b <= 0. ||
d_c <= 0.)
2172 if (
d_a + tol <= 0. ||
d_b + tol <= 0. ||
d_c + tol <= 0.)
2181 const bool inOuter =
isNear(x, tol);
2186 if (shrunk.
d_a <= 0. || shrunk.
d_b <= 0. || shrunk.
d_c <= 0.)
2188 const bool inInner = shrunk.
isInside(x);
2190 return inOuter && !inInner;
2209 bool intersect =
false;
2235 std::ostringstream oss;
2237 oss << tabS <<
"------- Ellipsoid --------" << std::endl << std::endl;
2238 oss << tabS <<
"Name = " <<
d_name << std::endl;
2239 oss << tabS <<
"Center = " <<
d_x.
printStr(0, lvl) << std::endl;
2240 oss << tabS <<
"Semi-axes a, b, c = " <<
d_a <<
", " <<
d_b <<
", " <<
d_c << std::endl;
2241 if (std::abs(
d_theta) > 1.0e-14)
2246 oss << tabS <<
"Bounding box: "
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
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 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 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 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.
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.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double d_r
Radius of bounding circle.
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::vector< util::Point > d_vertices
Vertices.
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.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
double d_L
Edge length of cube.
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.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
double d_Ly
Edge length of cuboid in y-direction.
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::vector< util::Point > d_vertices
Vertices.
util::Point center() const override
Computes the center of object.
double d_Lx
Edge length of cuboid in x-direction.
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.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
double d_r
Radius of bounding circle.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double d_Lz
Edge length of cuboid in z-direction.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
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.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
util::Point d_xBegin
Center point of cross-section at the beginning.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
util::Point d_xa
Axis of cylinder (unit vector)
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.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this 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.
util::Point center() const override
Computes the center of object.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
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.
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.
util::Point d_a
Axis: defined as the vector pointing from center to the first vertex v3 v2.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
std::vector< util::Point > d_vertices
Vertices.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
double d_r
Distance between center and the farthest vertex.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
double d_w
Half width of neck.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
Filled ellipse in the plane z = center.d_z, semi-axes in the xy plane.
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.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
double d_a
Semi-axis along local x before rotation (in-plane)
util::Point center() const override
Computes the center of object.
double d_b
Semi-axis along local y before rotation (in-plane)
double d_theta
Counter-clockwise rotation about +z through the center (radians)
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 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.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) 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.
Ellipsoid: center , semi-axes in a body frame rotated from world by axis–angle (Rodrigues)....
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
double d_theta
Rotation angle (radians) about d_axis.
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.
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.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
util::Point d_axis
Unit rotation axis (axis–angle); default (0,0,1) when .
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) 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.
void transform(const util::Point &translation, const double &scale, const double &angle, const util::Point &axis, const util::Point *rotationPoint) override
Similarity about pivot (default: old center d_x), then rigid displacement = translation: ....
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
const std::string d_name
name of object
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
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of 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 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.
util::Point d_a
Axis: defined as the vector pointing from center to the first vertex.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double d_r
Distance between center and the farthest vertex of hexagon.
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.
std::vector< util::Point > d_vertices
Vertices.
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.
std::vector< util::Point > d_vertices
Vertices.
double d_r
Radius of bounding circle.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
bool wallContactQuery(const util::Point &x, WallContactHit &hit) const override
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.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
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.
double d_L
Length of line.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this 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.
util::Point d_p
a point on the plane
util::Point d_n
outward (free-space) normal, stored unit-length when possible
bool wallContactQuery(const util::Point &x, WallContactHit &hit) const override
Closest-point / signed-gap query for analytical wall contact. Default: unsupported (returns false,...
std::vector< util::Point > d_vertices
Vertices.
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 doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
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.
double d_r
Radius of bounding circle.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
bool wallContactQuery(const util::Point &x, WallContactHit &hit) const override
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 d_Lx
Edge length of a rectangle in x-direction.
double d_Ly
Edge length of a rectangle in y-direction.
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.
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.
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.
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.
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
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.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the 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 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.
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::vector< util::Point > d_vertices
Vertices.
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 volume() const override
Computes the volume (area in 2d, length in 1d) of object.
double d_L
Edge length of a square.
double d_r
Radius of bounding circle.
std::vector< util::Point > d_vertices
Vertices.
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::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.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the 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.
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.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double d_r
Distance between center and the farthest vertex of triangle.
std::string printErrMsg(const std::string &geom_type, const std::vector< double > ¶ms, const std::vector< size_t > &num_params_needed)
static void quatToAxisAngle(double qw, double qx, double qy, double qz, util::Point &axis, double &theta)
static void axisAngleToQuatSafe(const util::Point &axisIn, double theta, double &w, double &x, double &y, double &z)
void ellipseLocal(const Ellipse &e, const util::Point &x, double &u, double &v)
static void quatMul(double aw, double ax, double ay, double az, double bw, double bx, double by, double bz, double &cw, double &cx, double &cy, double &cz)
void ellipsoidBodyCoords(const Ellipsoid &e, const util::Point &p, double R[9], double &v0, double &v1, double &v2)
bool ellipseMetricInside(double u, double v, double a, double b)
double ellipsoidMetric(const Ellipsoid &e, const util::Point &x, double R[9], const double &ra, const double &rb, const double &rc)
util::Point getCenter(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns center point.
bool isPointInsideRectangle(util::Point x, double x_min, double x_max, double y_min, double y_max)
Checks if point is inside a rectangle.
util::Point mapSimilarity(const util::Point &x, const util::Point &pivotDefault, const util::Point &t, double scale, double angle, const util::Point &axis, const util::Point *rotationPoint)
bool isPointInsideBox(util::Point x, size_t dim, const std::pair< util::Point, util::Point > &box)
Returns true if point is inside box.
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.
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.
std::vector< util::Point > getCornerPoints(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.
double triangleArea(const util::Point &x1, const util::Point &x2, const util::Point &x3)
Compute area of triangle.
void ellipsoidRotationMatrix(const Ellipsoid &e, double R[9])
Row-major 3×3 rotation from ellipsoid axis–angle (identity if ).
double inscribedRadiusInBox(size_t dim, const std::pair< util::Point, util::Point > &box)
Computes the radius of biggest circle/sphere completely within the object.
bool isPointInsideCuboid(util::Point x, util::Point x_lbb, util::Point x_rtf)
Checks if point is inside a cuboid.
Collection of methods and database related to reading and writing.
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 a given size.
std::string printStr(const T &msg, int nt=print_default_tab)
Returns formatted string for output.
bool isGreater(const double &a, const double &b)
Returns true if a > b.
bool isLess(const double &a, const double &b)
Returns true if a < b.
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
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
double dist(const Point &b) const
Computes the distance between a given point from this point.
double d_z
the z coordinate
double dot(const Point &b) const
Computes the dot product of this vector with another point.
double length() const
Computes the Euclidean length of the vector.
double lengthSq() const
Computes the Euclidean length of the vector.
double d_x
the x coordinate