PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
geomObjects.h
Go to the documentation of this file.
1/*
2* -------------------------------------------
3* Copyright (c) 2021 - 2024 Prashant K. Jha
4* -------------------------------------------
5* PeriDEM https://github.com/prashjha/PeriDEM
6*
7* Distributed under the Boost Software License, Version 1.0. (See accompanying
8* file LICENSE)
9*/
10
11#ifndef UTIL_GEOMETRY_OBJECTS_H
12#define UTIL_GEOMETRY_OBJECTS_H
13
14#include <iostream>
15#include <utility>
16#include <memory>
17
18#include "function.h"
19#include "io.h"
20#include "point.h" // definition of Point
21#include "transformation.h"
22
23namespace util {
24
26 namespace geometry {
27
31 class GeomObject {
32
33 public:
39 explicit GeomObject(std::string name = "",
40 std::string description = "")
41 : d_name(name), d_description(description) {};
42
47 virtual double volume() const { return 0.; };
48
53 virtual util::Point center() const { return {}; };
54
59 virtual std::pair<util::Point, util::Point> box() const {
60 return {util::Point(), util::Point()};
61 };
62
68 virtual std::pair<util::Point, util::Point>
69 box(const double &tol) const {
70 return {util::Point(), util::Point()};
71 };
72
78 virtual double inscribedRadius() const { return 0.; };
79
85 virtual double boundingRadius() const { return 0.; };
86
96 virtual bool isInside(const util::Point &x) const { return false; };
97
103 virtual bool
104 isOutside(const util::Point &x) const { return false; };
105
112 virtual bool isNear(const util::Point &x, const double &tol) const {
113 return false;
114 };
115
123 virtual bool isNearBoundary(const util::Point &x, const double &tol,
124 const bool &within) const {
125 return false;
126 };
127
133 virtual bool
134 doesIntersect(const util::Point &x) const { return false; };
135
147 virtual bool
148 isInside(const std::pair<util::Point, util::Point> &box) const {
149 return false;
150 };
151
157 virtual bool
158 isOutside(const std::pair<util::Point, util::Point> &box) const {
159 return false;
160 };
161
168 virtual bool isNear(const std::pair<util::Point, util::Point> &box,
169 const double &tol) const {
170 return false;
171 };
172
178 virtual bool
180 const std::pair<util::Point, util::Point> &box) const {
181 return false;
182 };
183
193 virtual std::string printStr(int nt, int lvl) const {
194
195 auto tabS = util::io::getTabS(nt);
196 std::ostringstream oss;
197
198 oss << tabS << "------- GeomObject --------" << std::endl
199 << std::endl;
200 oss << tabS << "Base geometrical object" << std::endl;
201 oss << tabS << "Base implementation of GeomObject." << std::endl;
202 oss << tabS << "Name of GeomObject = " << d_name << std::endl;
203 oss << tabS << "Description of GeomObject = " << d_description
204 << std::endl;
205
206 return oss.str();
207 };
208
215 virtual void print(int nt, int lvl) const {
216 std::cout << printStr(nt, lvl);
217 };
218
220 virtual void print() const { print(0, 0); };
221
222 public:
224 const std::string d_name;
225
227 const std::string d_description;
228
230 std::vector<std::string> d_tags;
231 };
232
236 class NullGeomObject : public GeomObject {
237
238 public:
242 NullGeomObject(std::string description = "") : GeomObject("null", description) {};
243
247 virtual std::string printStr(int nt, int lvl) const override {
248
249 auto tabS = util::io::getTabS(nt);
250 std::ostringstream oss;
251
252 oss << tabS << "------- NullGeomObject --------" << std::endl
253 << std::endl;
254 oss << tabS << "Name of GeomObject = " << d_name << std::endl;
255
256 return oss.str();
257 };
258
262 void print(int nt, int lvl) const override {
263 std::cout << printStr(nt, lvl);
264 };
265
269 void print() const override { print(0, 0); };
270 };
271
275 class Line : public GeomObject {
276
277 public:
282 : GeomObject("line", ""),
283 d_r(0.),
284 d_L(0.),
285 d_x(util::Point()),
287
295 Line(util::Point x1, util::Point x2, std::string description = "")
296 : GeomObject("line", description),
297 d_L((x1 - x2).length()),
298 d_r(0.5 * (x1 - x2).length()),
299 d_x(0.5 * (x1 + x2)),
300 d_vertices({x1, x2}) {};
301
309 Line(double L, util::Point x = util::Point(),
310 std::string description = "")
311 : GeomObject("line", description),
312 d_L(L),
313 d_r(0.5 * L),
314 d_x(x),
315 d_vertices({x + util::Point(-0.5 * L, 0., 0.),
316 x + util::Point(0.5 * L, 0., 0.)}) {};
317
321 double volume() const override;
322
326 util::Point center() const override;
327
331 std::pair<util::Point, util::Point> box() const override;
332
336 std::pair<util::Point, util::Point>
337 box(const double &tol) const override;
338
342 double inscribedRadius() const override;
343
347 double boundingRadius() const override;
348
357 bool isInside(const util::Point &x) const override;
358
362 bool isOutside(const util::Point &x) const override;
363
367 bool isNear(const util::Point &x, const double &tol) const override;
368
373 bool isNearBoundary(const util::Point &x, const double &tol,
374 const bool &within) const override;
375
379 bool doesIntersect(const util::Point &x) const override;
380
393 bool
394 isInside(
395 const std::pair<util::Point, util::Point> &box) const override;
396
401 bool
402 isOutside(
403 const std::pair<util::Point, util::Point> &box) const override;
404
409 bool isNear(const std::pair<util::Point, util::Point> &box,
410 const double &tol) const override;
411
416 bool doesIntersect(
417 const std::pair<util::Point, util::Point> &box) const override;
418
424 std::string printStr(int nt, int lvl) const override;
425
429 void print(int nt, int lvl) const override {
430 std::cout << printStr(nt, lvl);
431 };
432
436 void print() const override { print(0, 0); };
437
439 std::vector<util::Point> d_vertices;
440
443
445 double d_L;
446
448 double d_r;
449 };
450
454 class Triangle : public GeomObject {
455
456 public:
461 : GeomObject("triangle", ""),
462 d_r(0.),
463 d_a(util::Point(1., 0., 0.)),
464 d_x(util::Point()),
465 d_vertices(std::vector<util::Point>(3, util::Point())) {};
466
475 Triangle(double r, util::Point x = util::Point(0., 0., 0.),
476 util::Point a = util::Point(1., 0., 0.),
477 std::string description = "uniform")
478 : GeomObject("triangle", description),
479 d_r(r),
480 d_a(a),
481 d_x(x),
482 d_vertices(std::vector<util::Point>(3, util::Point())) {
483
484 // generate vertices
485 auto rotate_axis = util::Point(0., 0., 1.); // z-axis
486 for (int i = 0; i < 3; i++) {
488 d_a, i * 2. * M_PI / 3., rotate_axis);
489 }
490 };
491
495 double volume() const override;
496
500 util::Point center() const override;
501
505 std::pair<util::Point, util::Point> box() const override;
506
510 std::pair<util::Point, util::Point>
511 box(const double &tol) const override;
512
516 double inscribedRadius() const override;
517
521 double boundingRadius() const override;
522
531 bool isInside(const util::Point &x) const override;
532
536 bool isOutside(const util::Point &x) const override;
537
541 bool isNear(const util::Point &x, const double &tol) const override;
542
547 bool isNearBoundary(const util::Point &x, const double &tol,
548 const bool &within) const override;
549
553 bool doesIntersect(const util::Point &x) const override;
554
567 bool
568 isInside(
569 const std::pair<util::Point, util::Point> &box) const override;
570
575 bool
576 isOutside(
577 const std::pair<util::Point, util::Point> &box) const override;
578
583 bool isNear(const std::pair<util::Point, util::Point> &box,
584 const double &tol) const override;
585
590 bool doesIntersect(
591 const std::pair<util::Point, util::Point> &box) const override;
592
598 std::string printStr(int nt, int lvl) const override;
599
603 void print(int nt, int lvl) const override {
604 std::cout << printStr(nt, lvl);
605 };
606
610 void print() const override { print(0, 0); };
611
613 std::vector<util::Point> d_vertices;
614
617
619 double d_r;
620
636 };
637
641 class Square : public GeomObject {
642
643 public:
648 : GeomObject("square", ""),
649 d_L(0.),
650 d_r(0.),
651 d_x(util::Point()),
653 util::Point(), util::Point()}) {};
654
663 std::string description = "")
664 : GeomObject("square", description),
665 d_L(L),
666 d_r(L / std::sqrt(2)),
667 d_x(x),
668 d_vertices({x + util::Point(-0.5 * L, -0.5 * L, 0.),
669 x + util::Point(0.5 * L, -0.5 * L, 0.),
670 x + util::Point(0.5 * L, 0.5 * L, 0.),
671 x + util::Point(-0.5 * L, 0.5 * L, 0.)}) {};
672
680 Square(util::Point x1, util::Point x2, std::string description = "")
681 : GeomObject("square", description),
682 d_L((x1 - x2).length() * (1. / std::sqrt(2))),
683 d_r((x1 - x2).length() / 2.),
684 d_x(0.5 * (x1 + x2)) {
685
686 d_vertices.push_back(x1);
687 d_vertices.push_back(util::Point(x1.d_x + d_L, x1.d_y, x1.d_z));
688 d_vertices.push_back(x2);
689 d_vertices.push_back(util::Point(x2.d_x - d_L, x2.d_y, x2.d_z));
690 };
691
695 double volume() const override;
696
700 util::Point center() const override;
701
705 std::pair<util::Point, util::Point> box() const override;
706
710 std::pair<util::Point, util::Point>
711 box(const double &tol) const override;
712
716 double inscribedRadius() const override;
717
721 double boundingRadius() const override;
722
731 bool isInside(const util::Point &x) const override;
732
736 bool isOutside(const util::Point &x) const override;
737
741 bool isNear(const util::Point &x, const double &tol) const override;
742
747 bool isNearBoundary(const util::Point &x, const double &tol,
748 const bool &within) const override;
749
753 bool doesIntersect(const util::Point &x) const override;
754
766 bool
767 isInside(
768 const std::pair<util::Point, util::Point> &box) const override;
769
774 bool
775 isOutside(
776 const std::pair<util::Point, util::Point> &box) const override;
777
782 bool isNear(const std::pair<util::Point, util::Point> &box,
783 const double &tol) const override;
784
789 bool doesIntersect(
790 const std::pair<util::Point, util::Point> &box) const override;
791
797 std::string printStr(int nt, int lvl) const override;
798
802 void print(int nt, int lvl) const override {
803 std::cout << printStr(nt, lvl);
804 };
805
809 void print() const override { print(0, 0); };
810
812 std::vector<util::Point> d_vertices;
813
816
818 double d_L;
819
821 double d_r;
822 };
823
827 class Rectangle : public GeomObject {
828
829 public:
834 : GeomObject("rectangle", ""),
835 d_Lx(0.),
836 d_Ly(0.),
837 d_r(0.),
838 d_x(util::Point()),
840 util::Point(), util::Point()}) {};
841
850 Rectangle(double Lx, double Ly, util::Point x = util::Point(),
851 std::string description = "")
852 : GeomObject("rectangle", description),
853 d_Lx(Lx),
854 d_Ly(Ly),
855 d_r(0.5 * std::sqrt(std::pow(Lx, 2) + std::pow(Ly, 2))),
856 d_x(x) {
857
858 d_vertices.push_back(
859 x + util::Point(-0.5 * d_Lx, -0.5 * d_Ly, 0.));
860 d_vertices.push_back(
861 x + util::Point(0.5 * d_Lx, -0.5 * d_Ly, 0.));
862 d_vertices.push_back(x + util::Point(0.5 * d_Lx, 0.5 * d_Ly, 0.));
863 d_vertices.push_back(
864 x + util::Point(-0.5 * d_Lx, 0.5 * d_Ly, 0.));
865 };
866
875 std::string description = "")
876 : GeomObject("rectangle", description),
877 d_Lx(x2.d_x - x1.d_x),
878 d_Ly(x2.d_y - x1.d_y),
879 d_r(0.5 *
880 std::sqrt(std::pow(d_Lx, 2) + std::pow(d_Ly, 2))),
881 d_x(0.5 * (x1 + x2)) {
882
883 d_vertices.push_back(x1);
884 d_vertices.push_back(util::Point(x1.d_x + d_Lx, x1.d_y, x1.d_z));
885 d_vertices.push_back(x2);
886 d_vertices.push_back(util::Point(x2.d_x - d_Lx, x2.d_y, x2.d_z));
887 };
888
892 double volume() const override;
893
897 util::Point center() const override;
898
902 std::pair<util::Point, util::Point> box() const override;
903
907 std::pair<util::Point, util::Point>
908 box(const double &tol) const override;
909
913 double inscribedRadius() const override;
914
918 double boundingRadius() const override;
919
928 bool isInside(const util::Point &x) const override;
929
933 bool isOutside(const util::Point &x) const override;
934
938 bool isNear(const util::Point &x, const double &tol) const override;
939
944 bool isNearBoundary(const util::Point &x, const double &tol,
945 const bool &within) const override;
946
950 bool doesIntersect(const util::Point &x) const override;
951
963 bool
964 isInside(
965 const std::pair<util::Point, util::Point> &box) const override;
966
971 bool
972 isOutside(
973 const std::pair<util::Point, util::Point> &box) const override;
974
979 bool isNear(const std::pair<util::Point, util::Point> &box,
980 const double &tol) const override;
981
986 bool doesIntersect(
987 const std::pair<util::Point, util::Point> &box) const override;
988
994 std::string printStr(int nt, int lvl) const override;
995
999 void print(int nt, int lvl) const override {
1000 std::cout << printStr(nt, lvl);
1001 };
1002
1006 void print() const override { print(0, 0); };
1007
1009 std::vector<util::Point> d_vertices;
1010
1013
1015 double d_Lx;
1016
1018 double d_Ly;
1019
1021 double d_r;
1022 };
1023
1027 class Hexagon : public GeomObject {
1028
1029 public:
1034 : GeomObject("hexagon", ""),
1035 d_r(0.),
1036 d_a(util::Point(1., 0., 0.)),
1037 d_x(util::Point()),
1038 d_vertices(std::vector<util::Point>(6, util::Point())) {};
1039
1048 Hexagon(double r, util::Point x = util::Point(0., 0., 0.),
1049 util::Point a = util::Point(1., 0., 0.),
1050 std::string description = "")
1051 : GeomObject("hexagon", ""),
1052 d_r(r),
1053 d_a(a),
1054 d_x(x),
1055 d_vertices(std::vector<util::Point>(6, util::Point())) {
1056
1057 // generate vertices
1058 auto rotate_axis = util::Point(0., 0., 1.); // z-axis
1059 for (int i = 0; i < 6; i++) {
1060 d_vertices[i] = d_x + d_r * util::rotate(
1061 d_a, i * M_PI / 3., rotate_axis);
1062 }
1063 };
1064
1068 double volume() const override;
1069
1073 util::Point center() const override;
1074
1078 std::pair<util::Point, util::Point> box() const override;
1079
1083 std::pair<util::Point, util::Point>
1084 box(const double &tol) const override;
1085
1089 double inscribedRadius() const override;
1090
1094 double boundingRadius() const override;
1095
1104 bool isInside(const util::Point &x) const override;
1105
1109 bool isOutside(const util::Point &x) const override;
1110
1114 bool isNear(const util::Point &x, const double &tol) const override;
1115
1120 bool isNearBoundary(const util::Point &x, const double &tol,
1121 const bool &within) const override;
1122
1126 bool doesIntersect(const util::Point &x) const override;
1127
1141 bool
1142 isInside(
1143 const std::pair<util::Point, util::Point> &box) const override;
1144
1149 bool
1150 isOutside(
1151 const std::pair<util::Point, util::Point> &box) const override;
1152
1157 bool isNear(const std::pair<util::Point, util::Point> &box,
1158 const double &tol) const override;
1159
1164 bool doesIntersect(
1165 const std::pair<util::Point, util::Point> &box) const override;
1166
1172 std::string printStr(int nt, int lvl) const override;
1173
1177 void print(int nt, int lvl) const override {
1178 std::cout << printStr(nt, lvl);
1179 };
1180
1184 void print() const override { print(0, 0); };
1185
1187 std::vector<util::Point> d_vertices;
1188
1191
1193 double d_r;
1194
1209 };
1210
1230 class Drum2D : public GeomObject {
1231
1232 public:
1237 : GeomObject("drum2d", ""),
1238 d_r(0.),
1239 d_w(0.),
1240 d_a(util::Point(1., 0., 0.)),
1241 d_x(util::Point()),
1242 d_vertices(std::vector<util::Point>(6, util::Point())) {};
1243
1254 Drum2D(double r, double w, util::Point x = util::Point(0., 0., 0.),
1255 util::Point a = util::Point(1., 0., 0.),
1256 std::string description = "")
1257 : GeomObject("drum2d", description),
1258 d_r(r),
1259 d_w(w),
1260 d_a(a),
1261 d_x(x),
1262 d_vertices(std::vector<util::Point>(6, util::Point())) {
1263
1264 // generate vertices
1265 auto rotate_axis = util::Point(0., 0., 1.); // z-axis
1266
1267 // half-width of big (top and bottom) edge
1268 double w_big_edge = d_r * std::cos(M_PI / 3.);
1269
1270 d_vertices[0] = d_x + d_w * d_a;
1271 d_vertices[3] = d_x - d_w * d_a;
1272
1273 d_vertices[1] =
1274 d_x + d_r * util::rotate(d_a, M_PI / 3., rotate_axis);
1275 // to get third vertex, we could either rotate axis further or use second vertex to get
1276 // to the third vertex
1277 // Option 1
1278 // d_vertices[2] = d_x + d_r * util::rotate(d_a, 2.*M_PI/3., rotate_axis);
1279 // Option 2
1280 d_vertices[2] = d_vertices[1] - 2 * w_big_edge * rotate_axis;
1281
1282 d_vertices[4] = d_x + d_r * util::rotate(-1. * d_a, M_PI / 3.,
1283 rotate_axis);
1284 // Option 2
1285 d_vertices[5] = d_vertices[4] + 2. * w_big_edge * d_a;
1286 };
1287
1291 double volume() const override;
1292
1296 util::Point center() const override;
1297
1301 std::pair<util::Point, util::Point> box() const override;
1302
1306 std::pair<util::Point, util::Point>
1307 box(const double &tol) const override;
1308
1312 double inscribedRadius() const override;
1313
1317 double boundingRadius() const override;
1318
1327 bool isInside(const util::Point &x) const override;
1328
1332 bool isOutside(const util::Point &x) const override;
1333
1337 bool isNear(const util::Point &x, const double &tol) const override;
1338
1343 bool isNearBoundary(const util::Point &x, const double &tol,
1344 const bool &within) const override;
1345
1349 bool doesIntersect(const util::Point &x) const override;
1350
1362 bool
1363 isInside(
1364 const std::pair<util::Point, util::Point> &box) const override;
1365
1370 bool
1371 isOutside(
1372 const std::pair<util::Point, util::Point> &box) const override;
1373
1378 bool isNear(const std::pair<util::Point, util::Point> &box,
1379 const double &tol) const override;
1380
1385 bool doesIntersect(
1386 const std::pair<util::Point, util::Point> &box) const override;
1387
1393 std::string printStr(int nt, int lvl) const override;
1394
1398 void print(int nt, int lvl) const override {
1399 std::cout << printStr(nt, lvl);
1400 };
1401
1405 void print() const override { print(0, 0); };
1406
1408 std::vector<util::Point> d_vertices;
1409
1412
1414 double d_w;
1415
1417 double d_r;
1418
1434 };
1435
1439 class Cube : public GeomObject {
1440
1441 public:
1446 : GeomObject("cube", ""),
1447 d_L(0.),
1448 d_r(0.),
1449 d_x(util::Point()),
1450 d_vertices(std::vector<util::Point>(8, util::Point())) {};
1451
1460 std::string description = "")
1461 : GeomObject("cube", description),
1462 d_L(L),
1463 d_r(0.5 * std::sqrt(3.) * L),
1464 d_x(x),
1465 d_vertices(std::vector<util::Point>(8, util::Point())) {
1466 // numbering assuming x - left-right, y - back-front, z - bottom-top
1467 // counterclockwise in bottom plane (i.e.,
1468 // 0 - left-back-bottom, 1 - right-back-bottom,
1469 // 2 - right-front-bottom, 3 - left-front-bottom
1470 // similarly, in top plane
1471 d_vertices[0] =
1472 d_x + util::Point(-0.5 * d_L, -0.5 * d_L, -0.5 * d_L);
1473 d_vertices[1] =
1474 d_x + util::Point(0.5 * d_L, -0.5 * d_L, -0.5 * d_L);
1475 d_vertices[2] =
1476 d_x + util::Point(0.5 * d_L, 0.5 * d_L, -0.5 * d_L);
1477 d_vertices[3] =
1478 d_x + util::Point(-0.5 * d_L, 0.5 * d_L, -0.5 * d_L);
1479
1480 d_vertices[4] =
1481 d_x + util::Point(-0.5 * d_L, -0.5 * d_L, 0.5 * d_L);
1482 d_vertices[5] =
1483 d_x + util::Point(0.5 * d_L, -0.5 * d_L, 0.5 * d_L);
1484 d_vertices[6] =
1485 d_x + util::Point(0.5 * d_L, 0.5 * d_L, 0.5 * d_L);
1486 d_vertices[7] =
1487 d_x + util::Point(-0.5 * d_L, 0.5 * d_L, 0.5 * d_L);
1488 };
1489
1497 Cube(util::Point x1, util::Point x2, std::string description = "")
1498 : GeomObject("cube", description),
1499 d_L((x2 - x1).length() / std::sqrt(3.)),
1500 d_r(0.5 * (x2 - x1).length()),
1501 d_x(0.5 * (x1 + x2)),
1502 d_vertices(std::vector<util::Point>(8, util::Point())) {
1503 // numbering assuming x - left-right, y - back-front, z - bottom-top
1504 // counterclockwise in bottom plane (i.e.,
1505 // 0 - left-back-bottom, 1 - right-back-bottom,
1506 // 2 - right-front-bottom, 3 - left-front-bottom
1507 // similarly, in top plane
1508 d_vertices[0] =
1509 d_x + util::Point(-0.5 * d_L, -0.5 * d_L, -0.5 * d_L);
1510 d_vertices[1] =
1511 d_x + util::Point(0.5 * d_L, -0.5 * d_L, -0.5 * d_L);
1512 d_vertices[2] =
1513 d_x + util::Point(0.5 * d_L, 0.5 * d_L, -0.5 * d_L);
1514 d_vertices[3] =
1515 d_x + util::Point(-0.5 * d_L, 0.5 * d_L, -0.5 * d_L);
1516
1517 d_vertices[4] =
1518 d_x + util::Point(-0.5 * d_L, -0.5 * d_L, 0.5 * d_L);
1519 d_vertices[5] =
1520 d_x + util::Point(0.5 * d_L, -0.5 * d_L, 0.5 * d_L);
1521 d_vertices[6] =
1522 d_x + util::Point(0.5 * d_L, 0.5 * d_L, 0.5 * d_L);
1523 d_vertices[7] =
1524 d_x + util::Point(-0.5 * d_L, 0.5 * d_L, 0.5 * d_L);
1525 };
1526
1530 double volume() const override;
1531
1535 util::Point center() const override;
1536
1540 std::pair<util::Point, util::Point> box() const override;
1541
1545 std::pair<util::Point, util::Point>
1546 box(const double &tol) const override;
1547
1551 double inscribedRadius() const override;
1552
1556 double boundingRadius() const override;
1557
1566 bool isInside(const util::Point &x) const override;
1567
1571 bool isOutside(const util::Point &x) const override;
1572
1576 bool isNear(const util::Point &x, const double &tol) const override;
1577
1582 bool isNearBoundary(const util::Point &x, const double &tol,
1583 const bool &within) const override;
1584
1588 bool doesIntersect(const util::Point &x) const override;
1589
1601 bool
1602 isInside(
1603 const std::pair<util::Point, util::Point> &box) const override;
1604
1609 bool
1610 isOutside(
1611 const std::pair<util::Point, util::Point> &box) const override;
1612
1617 bool isNear(const std::pair<util::Point, util::Point> &box,
1618 const double &tol) const override;
1619
1624 bool doesIntersect(
1625 const std::pair<util::Point, util::Point> &box) const override;
1626
1632 std::string printStr(int nt, int lvl) const override;
1633
1637 void print(int nt, int lvl) const override {
1638 std::cout << printStr(nt, lvl);
1639 };
1640
1644 void print() const override { print(0, 0); };
1645
1647 std::vector<util::Point> d_vertices;
1648
1651
1653 double d_L;
1654
1656 double d_r;
1657 };
1658
1662 class Cuboid : public GeomObject {
1663
1664 public:
1669 : GeomObject("cuboid", ""),
1670 d_Lx(0.),
1671 d_Ly(0.),
1672 d_Lz(0.),
1673 d_r(0.),
1674 d_x(util::Point()),
1675 d_vertices(std::vector<util::Point>(8, util::Point())) {};
1676
1686 Cuboid(double Lx, double Ly, double Lz,
1688 std::string description = "")
1689 : GeomObject("cuboid", description),
1690 d_Lx(Lx),
1691 d_Ly(Ly),
1692 d_Lz(Lz),
1693 d_r(std::sqrt(std::pow(Lx, 2) + std::pow(Ly, 2) +
1694 std::pow(Lz, 2))),
1695 d_x(x),
1696 d_vertices(std::vector<util::Point>(8, util::Point())) {
1697 // numbering assuming x - left-right, y - back-front, z - bottom-top
1698 // counterclockwise in bottom plane (i.e.,
1699 // 0 - left-back-bottom, 1 - right-back-bottom,
1700 // 2 - right-front-bottom, 3 - left-front-bottom
1701 // similarly, in top plane
1702 d_vertices[0] =
1703 d_x + util::Point(-0.5 * d_Lx, -0.5 * d_Ly, -0.5 * d_Lz);
1704 d_vertices[1] =
1705 d_x + util::Point(0.5 * d_Lx, -0.5 * d_Ly, -0.5 * d_Lz);
1706 d_vertices[2] =
1707 d_x + util::Point(0.5 * d_Lx, 0.5 * d_Ly, -0.5 * d_Lz);
1708 d_vertices[3] =
1709 d_x + util::Point(-0.5 * d_Lx, 0.5 * d_Ly, -0.5 * d_Lz);
1710
1711 d_vertices[4] =
1712 d_x + util::Point(-0.5 * d_Lx, -0.5 * d_Ly, 0.5 * d_Lz);
1713 d_vertices[5] =
1714 d_x + util::Point(0.5 * d_Lx, -0.5 * d_Ly, 0.5 * d_Lz);
1715 d_vertices[6] =
1716 d_x + util::Point(0.5 * d_Lx, 0.5 * d_Ly, 0.5 * d_Lz);
1717 d_vertices[7] =
1718 d_x + util::Point(-0.5 * d_Lx, 0.5 * d_Ly, 0.5 * d_Lz);
1719 };
1720
1728 Cuboid(util::Point x1, util::Point x2, std::string description = "")
1729 : GeomObject("cuboid", description),
1730 d_Lx(x2.d_x - x1.d_x),
1731 d_Ly(x2.d_y - x1.d_y),
1732 d_Lz(x2.d_z - x1.d_z),
1733 d_r(std::sqrt(
1734 std::pow(x2.d_x - x1.d_x, 2)
1735 + std::pow(x2.d_y - x1.d_y, 2)
1736 + std::pow(x2.d_z - x1.d_z, 2)
1737 )
1738 ),
1739 d_x(0.5 * (x1 + x2)),
1740 d_vertices(std::vector<util::Point>(8, util::Point())) {
1741 // numbering assuming x - left-right, y - back-front, z - bottom-top
1742 // counterclockwise in bottom plane (i.e.,
1743 // 0 - left-back-bottom, 1 - right-back-bottom,
1744 // 2 - right-front-bottom, 3 - left-front-bottom
1745 // similarly, in top plane
1746 d_vertices[0] =
1747 d_x + util::Point(-0.5 * d_Lx, -0.5 * d_Ly, -0.5 * d_Lz);
1748 d_vertices[1] =
1749 d_x + util::Point(0.5 * d_Lx, -0.5 * d_Ly, -0.5 * d_Lz);
1750 d_vertices[2] =
1751 d_x + util::Point(0.5 * d_Lx, 0.5 * d_Ly, -0.5 * d_Lz);
1752 d_vertices[3] =
1753 d_x + util::Point(-0.5 * d_Lx, 0.5 * d_Ly, -0.5 * d_Lz);
1754
1755 d_vertices[4] =
1756 d_x + util::Point(-0.5 * d_Lx, -0.5 * d_Ly, 0.5 * d_Lz);
1757 d_vertices[5] =
1758 d_x + util::Point(0.5 * d_Lx, -0.5 * d_Ly, 0.5 * d_Lz);
1759 d_vertices[6] =
1760 d_x + util::Point(0.5 * d_Lx, 0.5 * d_Ly, 0.5 * d_Lz);
1761 d_vertices[7] =
1762 d_x + util::Point(-0.5 * d_Lx, 0.5 * d_Ly, 0.5 * d_Lz);
1763 };
1764
1768 double volume() const override;
1769
1773 util::Point center() const override;
1774
1778 std::pair<util::Point, util::Point> box() const override;
1779
1783 std::pair<util::Point, util::Point>
1784 box(const double &tol) const override;
1785
1789 double inscribedRadius() const override;
1790
1794 double boundingRadius() const override;
1795
1804 bool isInside(const util::Point &x) const override;
1805
1809 bool isOutside(const util::Point &x) const override;
1810
1814 bool isNear(const util::Point &x, const double &tol) const override;
1815
1820 bool isNearBoundary(const util::Point &x, const double &tol,
1821 const bool &within) const override;
1822
1826 bool doesIntersect(const util::Point &x) const override;
1827
1839 bool
1840 isInside(
1841 const std::pair<util::Point, util::Point> &box) const override;
1842
1847 bool
1848 isOutside(
1849 const std::pair<util::Point, util::Point> &box) const override;
1850
1855 bool isNear(const std::pair<util::Point, util::Point> &box,
1856 const double &tol) const override;
1857
1862 bool doesIntersect(
1863 const std::pair<util::Point, util::Point> &box) const override;
1864
1870 std::string printStr(int nt, int lvl) const override;
1871
1875 void print(int nt, int lvl) const override {
1876 std::cout << printStr(nt, lvl);
1877 };
1878
1882 void print() const override { print(0, 0); };
1883
1885 std::vector<util::Point> d_vertices;
1886
1889
1891 double d_Lx;
1892
1894 double d_Ly;
1895
1897 double d_Lz;
1898
1900 double d_r;
1901 };
1902
1906 class Circle : public GeomObject {
1907
1908 public:
1913 : GeomObject("circle", ""),
1914 d_x(util::Point()),
1915 d_r(0.) {};
1916
1925 std::string description = "")
1926 : GeomObject("circle", description),
1927 d_x(x),
1928 d_r(r) {};
1929
1933 double volume() const override;
1934
1938 util::Point center() const override;
1939
1943 std::pair<util::Point, util::Point> box() const override;
1944
1948 std::pair<util::Point, util::Point>
1949 box(const double &tol) const override;
1950
1954 double inscribedRadius() const override;
1955
1959 double boundingRadius() const override;
1960
1969 bool isInside(const util::Point &x) const override;
1970
1974 bool isOutside(const util::Point &x) const override;
1975
1979 bool isNear(const util::Point &x, const double &tol) const override;
1980
1985 bool isNearBoundary(const util::Point &x, const double &tol,
1986 const bool &within) const override;
1987
1991 bool doesIntersect(const util::Point &x) const override;
1992
2004 bool
2005 isInside(
2006 const std::pair<util::Point, util::Point> &box) const override;
2007
2012 bool
2013 isOutside(
2014 const std::pair<util::Point, util::Point> &box) const override;
2015
2020 bool isNear(const std::pair<util::Point, util::Point> &box,
2021 const double &tol) const override;
2022
2027 bool doesIntersect(
2028 const std::pair<util::Point, util::Point> &box) const override;
2029
2035 std::string printStr(int nt, int lvl) const override;
2036
2040 void print(int nt, int lvl) const override {
2041 std::cout << printStr(nt, lvl);
2042 };
2043
2047 void print() const override { print(0, 0); };
2048
2051
2053 double d_r;
2054 };
2055
2059 class Ellipse : public GeomObject {
2060
2061 public:
2066 : GeomObject("ellipse", ""),
2067 d_x(util::Point()),
2068 d_a(0.),
2069 d_b(0.),
2070 d_theta(0.),
2071 d_r(0.) {};
2072
2082 Ellipse(double a, double b, util::Point x = util::Point(),
2083 double theta = 0., std::string description = "")
2084 : GeomObject("ellipse", description),
2085 d_x(x),
2086 d_a(a),
2087 d_b(b),
2088 d_theta(theta),
2089 d_r(std::max(a, b)) {};
2090
2094 double volume() const override;
2095
2099 util::Point center() const override;
2100
2104 std::pair<util::Point, util::Point> box() const override;
2105
2109 std::pair<util::Point, util::Point>
2110 box(const double &tol) const override;
2111
2115 double inscribedRadius() const override;
2116
2120 double boundingRadius() const override;
2121
2130 bool isInside(const util::Point &x) const override;
2131
2135 bool isOutside(const util::Point &x) const override;
2136
2140 bool isNear(const util::Point &x, const double &tol) const override;
2141
2146 bool isNearBoundary(const util::Point &x, const double &tol,
2147 const bool &within) const override;
2148
2152 bool doesIntersect(const util::Point &x) const override;
2153
2165 bool
2166 isInside(
2167 const std::pair<util::Point, util::Point> &box) const override;
2168
2173 bool
2174 isOutside(
2175 const std::pair<util::Point, util::Point> &box) const override;
2176
2181 bool isNear(const std::pair<util::Point, util::Point> &box,
2182 const double &tol) const override;
2183
2188 bool doesIntersect(
2189 const std::pair<util::Point, util::Point> &box) const override;
2190
2196 std::string printStr(int nt, int lvl) const override;
2197
2201 void print(int nt, int lvl) const override {
2202 std::cout << printStr(nt, lvl);
2203 };
2204
2208 void print() const override { print(0, 0); };
2209
2212
2214 double d_a;
2215
2217 double d_b;
2218
2220 double d_theta;
2221
2223 double d_r;
2224 };
2225
2229 class Sphere : public GeomObject {
2230
2231 public:
2236 : GeomObject("sphere", ""),
2237 d_x(util::Point()),
2238 d_r(0.) {};
2239
2248 std::string description = "")
2249 : GeomObject("sphere", description),
2250 d_x(x),
2251 d_r(r) {};
2252
2256 double volume() const override;
2257
2261 util::Point center() const override;
2262
2266 std::pair<util::Point, util::Point> box() const override;
2267
2271 std::pair<util::Point, util::Point>
2272 box(const double &tol) const override;
2273
2277 double inscribedRadius() const override;
2278
2282 double boundingRadius() const override;
2283
2292 bool isInside(const util::Point &x) const override;
2293
2297 bool isOutside(const util::Point &x) const override;
2298
2302 bool isNear(const util::Point &x, const double &tol) const override;
2303
2308 bool isNearBoundary(const util::Point &x, const double &tol,
2309 const bool &within) const override;
2310
2314 bool doesIntersect(const util::Point &x) const override;
2315
2327 bool
2328 isInside(
2329 const std::pair<util::Point, util::Point> &box) const override;
2330
2335 bool
2336 isOutside(
2337 const std::pair<util::Point, util::Point> &box) const override;
2338
2343 bool isNear(const std::pair<util::Point, util::Point> &box,
2344 const double &tol) const override;
2345
2350 bool doesIntersect(
2351 const std::pair<util::Point, util::Point> &box) const override;
2352
2358 std::string printStr(int nt, int lvl) const override;
2359
2363 void print(int nt, int lvl) const override {
2364 std::cout << printStr(nt, lvl);
2365 };
2366
2370 void print() const override { print(0, 0); };
2371
2374
2376 double d_r;
2377 };
2378
2382 class Cylinder : public GeomObject {
2383
2384 public:
2389 : GeomObject("cylinder", ""),
2390 d_xBegin(util::Point()),
2391 d_xa(util::Point(1., 1., 1.)),
2392 d_r(0.),
2393 d_l(0.),
2394 d_x(util::Point()) {};
2395
2405 Cylinder(double r, double l, util::Point x_begin, util::Point xa,
2406 std::string description = "")
2407 : GeomObject("cylinder", description),
2408 d_xBegin(x_begin),
2409 d_xa(xa / xa.length()),
2410 d_r(r),
2411 d_l(l),
2412 d_x(x_begin + 0.5 * l * xa) {};
2413
2423 Cylinder(double r, util::Point x_begin, util::Point xa,
2424 std::string description = "")
2425 : GeomObject("cylinder", description),
2426 d_xBegin(x_begin),
2427 d_xa(xa / xa.length()),
2428 d_r(r),
2429 d_l(xa.length()),
2430 d_x(x_begin + 0.5 * xa.length() * xa) {};
2431
2435 double volume() const override;
2436
2440 util::Point center() const override;
2441
2445 std::pair<util::Point, util::Point> box() const override;
2446
2450 std::pair<util::Point, util::Point>
2451 box(const double &tol) const override;
2452
2456 double inscribedRadius() const override;
2457
2461 double boundingRadius() const override;
2462
2471 bool isInside(const util::Point &x) const override;
2472
2476 bool isOutside(const util::Point &x) const override;
2477
2481 bool isNear(const util::Point &x, const double &tol) const override;
2482
2487 bool isNearBoundary(const util::Point &x, const double &tol,
2488 const bool &within) const override;
2489
2493 bool doesIntersect(const util::Point &x) const override;
2494
2506 bool
2507 isInside(
2508 const std::pair<util::Point, util::Point> &box) const override;
2509
2514 bool
2515 isOutside(
2516 const std::pair<util::Point, util::Point> &box) const override;
2517
2522 bool isNear(const std::pair<util::Point, util::Point> &box,
2523 const double &tol) const override;
2524
2529 bool doesIntersect(
2530 const std::pair<util::Point, util::Point> &box) const override;
2531
2537 std::string printStr(int nt, int lvl) const override;
2538
2542 void print(int nt, int lvl) const override {
2543 std::cout << printStr(nt, lvl);
2544 };
2545
2549 void print() const override { print(0, 0); };
2550
2553
2556
2559
2561 double d_r;
2562
2564 double d_l;
2565 };
2566
2571
2572 public:
2577 : GeomObject("annulus_object", ""),
2580 d_dim(0) {};
2581
2591 std::string description = "")
2592 : GeomObject("annulus_object", description),
2593 d_outObj_p(out),
2594 d_inObj_p(in),
2595 d_dim(dim) {};
2596
2600 double volume() const override;
2601
2605 util::Point center() const override;
2606
2610 std::pair<util::Point, util::Point> box() const override;
2611
2615 std::pair<util::Point, util::Point>
2616 box(const double &tol) const override;
2617
2621 double inscribedRadius() const override;
2622
2626 double boundingRadius() const override;
2627
2636 bool isInside(const util::Point &x) const override;
2637
2641 bool isOutside(const util::Point &x) const override;
2642
2646 bool isNear(const util::Point &x, const double &tol) const override;
2647
2652 bool isNearBoundary(const util::Point &x, const double &tol,
2653 const bool &within) const override;
2654
2658 bool doesIntersect(const util::Point &x) const override;
2659
2671 bool
2672 isInside(
2673 const std::pair<util::Point, util::Point> &box) const override;
2674
2679 bool
2680 isOutside(
2681 const std::pair<util::Point, util::Point> &box) const override;
2682
2687 bool isNear(const std::pair<util::Point, util::Point> &box,
2688 const double &tol) const override;
2689
2694 bool doesIntersect(
2695 const std::pair<util::Point, util::Point> &box) const override;
2696
2702 std::string printStr(int nt, int lvl) const override;
2703
2707 void print(int nt, int lvl) const override {
2708 std::cout << printStr(nt, lvl);
2709 };
2710
2714 void print() const override { print(0, 0); };
2715
2718
2721
2723 size_t d_dim;
2724 };
2725
2730
2731 public:
2735 ComplexGeomObject() : GeomObject("complex", ""), d_dim(0) {};
2736
2746 std::vector<std::shared_ptr<util::geometry::GeomObject>> &obj,
2747 std::vector<std::string> obj_flag, size_t dim,
2748 std::string description = "")
2749 : GeomObject("complex", description),
2750 d_obj(obj),
2752 d_dim(dim) {
2753
2754 for (const auto &s: d_objFlag)
2755 if (s == "plus")
2756 d_objFlagInt.push_back(1);
2757 else if (s == "minus")
2758 d_objFlagInt.push_back(-1);
2759 else {
2760 std::cerr
2761 << "Error: Check object flag " + s +
2762 " passed to create ComplexGeomObject\n";
2763 exit(1);
2764 }
2765 };
2766
2770 double volume() const override;
2771
2775 util::Point center() const override;
2776
2780 std::pair<util::Point, util::Point> box() const override;
2781
2785 std::pair<util::Point, util::Point>
2786 box(const double &tol) const override;
2787
2791 double inscribedRadius() const override;
2792
2796 double boundingRadius() const override;
2797
2806 bool isInside(const util::Point &x) const override;
2807
2811 bool isOutside(const util::Point &x) const override;
2812
2816 bool isNear(const util::Point &x, const double &tol) const override;
2817
2822 bool isNearBoundary(const util::Point &x, const double &tol,
2823 const bool &within) const override;
2824
2828 bool doesIntersect(const util::Point &x) const override;
2829
2841 bool
2842 isInside(
2843 const std::pair<util::Point, util::Point> &box) const override;
2844
2849 bool
2850 isOutside(
2851 const std::pair<util::Point, util::Point> &box) const override;
2852
2857 bool isNear(const std::pair<util::Point, util::Point> &box,
2858 const double &tol) const override;
2859
2864 bool doesIntersect(
2865 const std::pair<util::Point, util::Point> &box) const override;
2866
2872 std::string printStr(int nt, int lvl) const override;
2873
2877 void print(int nt, int lvl) const override {
2878 std::cout << printStr(nt, lvl);
2879 };
2880
2884 void print() const override { print(0, 0); };
2885
2887 std::vector<std::shared_ptr<util::geometry::GeomObject>> d_obj;
2888
2897 std::vector<std::string> d_objFlag;
2898
2902 std::vector<int> d_objFlagInt;
2903
2905 size_t d_dim;
2906 };
2907
2908 } // namespace geometry
2909
2910} // namespace util
2911
2912#endif // UTIL_GEOMETRY_OBJECTS_H
Defines annulus rectangle.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
size_t d_dim
Dimension objects live in.
util::geometry::GeomObject * d_inObj_p
Inner 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.
util::geometry::GeomObject * d_outObj_p
Outer 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.
void print() const override
Prints the information about the object.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
void print(int nt, int lvl) const override
Prints the information about the object.
AnnulusGeomObject(GeomObject *in, GeomObject *out, size_t dim, std::string description="")
Constructor.
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
void print(int nt, int lvl) const override
Prints the information about the object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
void print() const override
Prints the 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.
Circle(double r, util::Point x=util::Point(), std::string description="")
Constructor.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
util::Point d_x
Center.
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.
Defines complex geometrical object.
util::Point center() const override
Computes the center of object.
void print() const override
Prints the information about the 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.
ComplexGeomObject(std::vector< std::shared_ptr< util::geometry::GeomObject > > &obj, std::vector< std::string > obj_flag, size_t dim, std::string description="")
Constructor.
void print(int nt, int lvl) const override
Prints the information about the object.
std::vector< std::shared_ptr< util::geometry::GeomObject > > d_obj
Object.
std::vector< int > d_objFlagInt
Object integer flags. Here, +1 means object is filling and -1 means object is void.
std::vector< std::string > d_objFlag
Object flag.
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.
size_t d_dim
Dimension objects live in.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
void print() const override
Prints the information about the 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.
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.
Cube(util::Point x1, util::Point x2, std::string description="")
Constructor.
double d_L
Edge length of cube.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
void print(int nt, int lvl) const override
Prints the information about the object.
util::Point d_x
Center.
std::vector< util::Point > d_vertices
Vertices.
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.
Cube(double L, util::Point x=util::Point(), std::string description="")
Constructor.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
double d_r
Radius of bounding circle.
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.
std::vector< util::Point > d_vertices
Vertices.
util::Point d_x
Center.
void print(int nt, int lvl) const override
Prints the information about the object.
double d_Ly
Edge length of cuboid in y-direction.
double d_Lz
Edge length of cuboid in z-direction.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
Cuboid(double Lx, double Ly, double Lz, util::Point x=util::Point(), std::string description="")
Constructor.
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.
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.
void print() const override
Prints the information about the object.
Cuboid(util::Point x1, util::Point x2, std::string description="")
Constructor.
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 d_Lx
Edge length of cuboid in x-direction.
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.
Defines cylinder.
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.
util::Point d_xBegin
Center point of cross-section at the beginning.
void print() const override
Prints the information about the object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
util::Point d_xa
Axis of cylinder (unit vector)
void print(int nt, int lvl) const override
Prints the information about the 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
Cylinder(double r, double l, util::Point x_begin, util::Point xa, std::string description="")
Constructor.
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.
util::Point d_x
Center.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
Cylinder(double r, util::Point x_begin, util::Point xa, std::string description="")
Constructor.
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.
util::Point d_a
Axis: defined as the vector pointing from center to the first vertex v3 v2.
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.
double d_w
Half width of neck.
void print() const override
Prints the information about the object.
double d_r
Distance between center and the farthest vertex.
util::Point d_x
Center.
std::vector< util::Point > d_vertices
Vertices.
util::Point center() const override
Computes the center of object.
void print(int nt, int lvl) const override
Prints the information about the object.
Drum2D(double r, double w, util::Point x=util::Point(0., 0., 0.), util::Point a=util::Point(1., 0., 0.), std::string description="")
Constructor.
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.
util::Point d_x
Center.
double d_b
Semi-minor axis length.
void print() const override
Prints the 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.
void print(int nt, int lvl) const override
Prints the information about the 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 d_a
Semi-major axis length.
double d_r
Bounding radius (max of semi-major and semi-minor axis)
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
double d_theta
Rotation angle in radians (counterclockwise from x-axis)
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 volume() const override
Computes the volume (area in 2d, length in 1d) of object.
Ellipse(double a, double b, util::Point x=util::Point(), double theta=0., std::string description="")
Constructor.
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.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
Defines abstract geometrical domain.
Definition geomObjects.h:31
virtual void print() const
Prints the information about the object.
virtual bool isInside(const std::pair< util::Point, util::Point > &box) const
Checks if box is completely inside.
virtual double boundingRadius() const
Computes the radius of smallest circle/sphere such that object can be fit into it.
Definition geomObjects.h:85
std::vector< std::string > d_tags
Tags/attributes about the object.
const std::string d_description
Further description of object.
virtual void print(int nt, int lvl) const
Prints the information about the object.
virtual bool isOutside(const util::Point &x) const
Checks if point is outside of this object.
virtual bool doesIntersect(const std::pair< util::Point, util::Point > &box) const
Checks if box intersects this object.
virtual util::Point center() const
Computes the center of object.
Definition geomObjects.h:53
virtual std::string printStr(int nt, int lvl) const
Returns the string containing printable information about the object.
virtual bool isNear(const util::Point &x, const double &tol) const
Checks if point is within given distance of this object.
virtual bool doesIntersect(const util::Point &x) const
Checks if point lies exactly on the boundary.
virtual bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const
Checks if point is within given distance of this object.
virtual std::pair< util::Point, util::Point > box() const
Computes the bounding box of object.
Definition geomObjects.h:59
GeomObject(std::string name="", std::string description="")
Constructor.
Definition geomObjects.h:39
virtual bool isInside(const util::Point &x) const
Checks if point is inside this object.
Definition geomObjects.h:96
virtual bool isOutside(const std::pair< util::Point, util::Point > &box) const
Checks if box is outside of the object.
virtual std::pair< util::Point, util::Point > box(const double &tol) const
Computes the bounding box of object.
Definition geomObjects.h:69
virtual double volume() const
Computes the volume (area in 2d, length in 1d) of object.
Definition geomObjects.h:47
virtual double inscribedRadius() const
Computes the radius of biggest circle/sphere completely within the object.
Definition geomObjects.h:78
const std::string d_name
name of object
virtual bool isNear(const std::pair< util::Point, util::Point > &box, const double &tol) const
Checks if box is within given distance of this object.
double inscribedRadius() const override
Computes the radius of biggest circle/sphere completely within the object.
void print() const override
Prints the information about the object.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
std::vector< util::Point > d_vertices
Vertices.
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.
double d_r
Distance between center and the farthest vertex of hexagon.
bool doesIntersect(const util::Point &x) const override
Checks if point lies exactly on the boundary.
void print(int nt, int lvl) const override
Prints the information about the object.
util::Point d_x
Center.
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
Hexagon(double r, util::Point x=util::Point(0., 0., 0.), util::Point a=util::Point(1., 0., 0.), std::string description="")
Constructor.
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.
util::Point d_a
Axis: defined as the vector pointing from center to the first vertex.
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.
std::vector< util::Point > d_vertices
Vertices.
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
void print() const override
Prints the information about the object.
Line(double L, util::Point x=util::Point(), std::string description="")
Constructor.
util::Point d_x
Center.
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 isOutside(const util::Point &x) const override
Checks if point is outside of this object.
double d_r
Radius of bounding circle.
Line()
Constructor.
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.
void print(int nt, int lvl) const override
Prints the information about the object.
Line(util::Point x1, util::Point x2, std::string description="")
Constructor.
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.
Defines null (empty) geom object.
void print() const override
Prints the information about the object.
void print(int nt, int lvl) const override
Prints the information about the object.
NullGeomObject(std::string description="")
Constructor.
virtual std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
Defines Rectangle.
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.
util::Point d_x
Center.
double d_r
Radius of bounding circle.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
double d_Ly
Edge length of a rectangle in y-direction.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
void print(int nt, int lvl) const override
Prints the information about the object.
double d_Lx
Edge length of a rectangle in x-direction.
void print() const override
Prints the 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.
Rectangle(double Lx, double Ly, util::Point x=util::Point(), std::string description="")
Constructor.
std::vector< util::Point > d_vertices
Vertices.
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.
Rectangle(util::Point x1, util::Point x2, std::string description="")
Constructor.
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.
void print(int nt, int lvl) const override
Prints the information about the 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.
void print() const override
Prints the information about the object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
Sphere(double r, util::Point x=util::Point(), std::string description="")
Constructor.
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
util::Point d_x
Center.
Defines Square.
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
Square(util::Point x1, util::Point x2, std::string description="")
Constructor.
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.
std::vector< util::Point > d_vertices
Vertices.
util::Point d_x
Center.
void print() const override
Prints the 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.
void print(int nt, int lvl) const override
Prints the information about the object.
double d_L
Edge length of a square.
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
Square(double L, util::Point x=util::Point(), std::string description="")
Constructor.
bool isOutside(const util::Point &x) const override
Checks if point is outside of this object.
double d_r
Radius of bounding circle.
Defines Triangle.
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.
void print() const override
Prints the information about the object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
util::Point d_x
Center.
double boundingRadius() const override
Computes the radius of smallest circle/sphere such that object can be fit into it.
util::Point d_a
Axis: defined as the vector pointing from center to the first vertex v2 +.
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.
std::vector< util::Point > d_vertices
Vertices.
double d_r
Distance between center and the farthest vertex of triangle.
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons
void print(int nt, int lvl) const override
Prints the information about the object.
Triangle(double r, util::Point x=util::Point(0., 0., 0.), util::Point a=util::Point(1., 0., 0.), std::string description="uniform")
Constructor.
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.
Collection of methods and data related to geometry.
Definition fracture.h:20
std::string getTabS(int nt)
Returns tab spaces of given size.
Definition io.h:40
Collection of methods useful in simulation.
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.
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 d_x
the x coordinate
Definition point.h:33