PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
geom::Circle Class Reference

Defines circle. More...

#include <geomObjects.h>

Inheritance diagram for geom::Circle:
Collaboration diagram for geom::Circle:

Public Member Functions

 Circle ()
 Constructor.
 
 Circle (double r, util::Point x=util::Point(), std::string description="")
 Constructor.
 
 Circle (const Circle &other)
 Copy constructor.
 
Circleoperator= (const Circle &other)
 Assignment operator.
 
void transform (const util::Point &translation, const double &scale, const double &angle, const util::Point &axis, const util::Point *rotationPoint) override
 Similarity about pivot \(\mathbf p\) (default: old center d_x), then rigid displacement \(\mathbf t\) = translation: \(\mathbf y = \mathbf p + s\,\mathbf R(\mathbf x-\mathbf p) + \mathbf t\). When \(\theta=0\) and \(s=1\), \(\mathbf y = \mathbf x + \mathbf t\) for every point and the center.
 
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::Pointbox () const override
 Computes the bounding box of object.
 
std::pair< util::Point, util::Pointbox (const double &tol) const override
 Computes the bounding box of object.
 
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.
 
void print (int nt, int lvl) const override
 Prints the information about the object.
 
void print () const override
 Prints the information about the object.
 
Interaction with point
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.
 
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
 
bool doesIntersect (const util::Point &x) const override
 Checks if point lies exactly on the boundary.
 
Interaction with box
bool isInside (const std::pair< util::Point, util::Point > &box) const override
 Checks if box is completely inside.
 
bool isOutside (const std::pair< util::Point, util::Point > &box) const override
 Checks if box is outside of the object.
 
bool isNear (const std::pair< util::Point, util::Point > &box, const double &tol) const override
 Checks if box is within given distance of this object.
 
bool doesIntersect (const std::pair< util::Point, util::Point > &box) const override
 Checks if box intersects this object.
 
- Public Member Functions inherited from geom::GeomObject
 GeomObject (std::string name="", std::string description="")
 Constructor.
 
virtual bool wallContactQuery (const util::Point &x, WallContactHit &hit) const
 Closest-point / signed-gap query for analytical wall contact. Default: unsupported (returns false, clears hit).
 

Data Fields

util::Point d_x
 Center.
 
double d_r
 Radius.
 
- Data Fields inherited from geom::GeomObject
const std::string d_name
 name of object
 
const std::string d_description
 Further description of object.
 
std::vector< std::string > d_tags
 Tags/attributes about the object.
 

Detailed Description

Defines circle.

Definition at line 2557 of file geomObjects.h.

Constructor & Destructor Documentation

◆ Circle() [1/3]

geom::Circle::Circle ( )
inline

Constructor.

Definition at line 2569 of file geomObjects.h.

2570 : GeomObject("circle", ""),
2571 d_x(util::Point()),
2572 d_r(0.) {
2573 };
double d_r
Radius.
util::Point d_x
Center.
GeomObject(std::string name="", std::string description="")
Constructor.
A structure to represent 3d vectors.
Definition point.h:30

◆ Circle() [2/3]

geom::Circle::Circle ( double  r,
util::Point  x = util::Point(),
std::string  description = "" 
)
inline

Constructor.

Parameters
rRadius
xCenter
descriptionDescription of object (e.g., further classification or any tag)

Definition at line 2582 of file geomObjects.h.

2584 : GeomObject("circle", description),
2585 d_x(x),
2586 d_r(r) {
2587 };

◆ Circle() [3/3]

geom::Circle::Circle ( const Circle other)
inline

Copy constructor.

Parameters
otherObject to copy from

Definition at line 2593 of file geomObjects.h.

2594 : GeomObject(other.d_name, other.d_description),
2595 d_x(other.d_x),
2596 d_r(other.d_r) {
2597 d_tags = other.d_tags;
2598 }
std::vector< std::string > d_tags
Tags/attributes about the object.

References geom::GeomObject::d_tags.

Member Function Documentation

◆ boundingRadius()

double geom::Circle::boundingRadius ( ) const
overridevirtual

Computes the radius of smallest circle/sphere such that object can be fit into it.

Returns
Radius Radius of bounding circle/sphere

Reimplemented from geom::GeomObject.

Definition at line 1375 of file geomObjects.cpp.

1375 {
1376
1377 return d_r;
1378 }

References d_r.

◆ box() [1/2]

std::pair< util::Point, util::Point > geom::Circle::box ( ) const
overridevirtual

Computes the bounding box of object.

Returns
Pair Left-bottom-back and right-top-front corner points of box

Reimplemented from geom::GeomObject.

Definition at line 1356 of file geomObjects.cpp.

1356 {
1357
1358 return box(0.);
1359 }
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.

References box().

Referenced by box(), doesIntersect(), isInside(), isNear(), isOutside(), and printStr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ box() [2/2]

std::pair< util::Point, util::Point > geom::Circle::box ( const double &  tol) const
overridevirtual

Computes the bounding box of object.

Parameters
tolTolerance/padding used in creating bounding box
Returns
Pair Left-bottom-back and right-top-front corner points of box

Reimplemented from geom::GeomObject.

Definition at line 1361 of file geomObjects.cpp.

1362 {
1363 double r = d_r + tol;
1364 return {
1365 util::Point(d_x.d_x - r, d_x.d_y - r, 0.),
1366 util::Point(d_x.d_x + r, d_x.d_y + r, 0.)
1367 };
1368 }
double d_y
the y coordinate
Definition point.h:36
double d_x
the x coordinate
Definition point.h:33

References d_r, d_x, util::Point::d_x, and util::Point::d_y.

◆ center()

util::Point geom::Circle::center ( ) const
overridevirtual

Computes the center of object.

Returns
Point Coordinates of center

Reimplemented from geom::GeomObject.

Definition at line 1352 of file geomObjects.cpp.

1352 {
1353 return d_x;
1354 }

References d_x.

◆ doesIntersect() [1/2]

bool geom::Circle::doesIntersect ( const std::pair< util::Point, util::Point > &  box) const
overridevirtual

Checks if box intersects this object.

Parameters
boxBox
Returns
True True if intersects

Reimplemented from geom::GeomObject.

Definition at line 1470 of file geomObjects.cpp.

1471 {
1472
1473 // need to check all four corner points
1474 for (auto p: geom::getCornerPoints(2, box))
1475 if (this->isInside(p))
1476 return true;
1477
1478 return false;
1479 }
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
std::vector< util::Point > getCornerPoints(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.

References box(), geom::getCornerPoints(), and isInside().

Here is the call graph for this function:

◆ doesIntersect() [2/2]

bool geom::Circle::doesIntersect ( const util::Point x) const
overridevirtual

Checks if point lies exactly on the boundary.

Parameters
xPoint
Returns
True True if it lies on the boundary

Reimplemented from geom::GeomObject.

Definition at line 1413 of file geomObjects.cpp.

1413 {
1414
1415 return isNearBoundary(x, 1.0E-8, false);
1416 }
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons

References isNearBoundary().

Here is the call graph for this function:

◆ inscribedRadius()

double geom::Circle::inscribedRadius ( ) const
overridevirtual

Computes the radius of biggest circle/sphere completely within the object.

Returns
Radius Radius of inscribed circle/sphere

Reimplemented from geom::GeomObject.

Definition at line 1370 of file geomObjects.cpp.

1370 {
1371
1372 return d_r;
1373 }

References d_r.

◆ isInside() [1/2]

bool geom::Circle::isInside ( const std::pair< util::Point, util::Point > &  box) const
overridevirtual

Checks if box is completely inside.

Parameters
boxBox
Returns
True True if box lies inside

Reimplemented from geom::GeomObject.

Definition at line 1418 of file geomObjects.cpp.

1419 {
1420
1421 for (auto p: geom::getCornerPoints(2, box))
1422 if (!this->isInside(p))
1423 return false;
1424
1425 return true;
1426 }

References box(), geom::getCornerPoints(), and isInside().

Here is the call graph for this function:

◆ isInside() [2/2]

bool geom::Circle::isInside ( const util::Point x) const
overridevirtual

Checks if point is inside this object.

Parameters
xPoint
Returns
True If point lies inside

Reimplemented from geom::GeomObject.

Definition at line 1380 of file geomObjects.cpp.

1380 {
1381
1382 return util::isLess(d_x.dist(x), d_r + 1.0E-12);
1383 }
bool isLess(const double &a, const double &b)
Returns true if a < b.
Definition function.cpp:20
double dist(const Point &b) const
Computes the distance between a given point from this point.
Definition point.h:146

References d_r, d_x, util::Point::dist(), and util::isLess().

Referenced by doesIntersect(), isInside(), isNear(), isOutside(), and isOutside().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNear() [1/2]

bool geom::Circle::isNear ( const std::pair< util::Point, util::Point > &  box,
const double &  tol 
) const
overridevirtual

Checks if box is within given distance of this object.

Parameters
boxBox
tolTolerance used in checking the nearness
Returns
True True if box is inside within the tol distance

Reimplemented from geom::GeomObject.

Definition at line 1439 of file geomObjects.cpp.

1441 {
1442
1443 if (this->isInside(box))
1444 return true;
1445
1446 // get corner points of box
1447 auto cp = geom::getCornerPoints(2, box);
1448
1449 for (auto p: cp) {
1450
1451 // check the distance of corner point with the center
1452 auto dx = p - d_x;
1453 if (util::isLess(dx.length(), d_r + tol))
1454 return true;
1455 }
1456
1457 // check center to center distance
1458 auto dxc = geom::getCenter(2, box) - d_x;
1459
1460 // check wrt inscribed circle
1461 auto r = geom::inscribedRadiusInBox(2, box);
1462 if (util::isLess(dxc.length(), d_r + r + tol))
1463 return true;
1464
1465 // check wrt circumscribed circle
1467 return util::isLess(dxc.length(), d_r + r + tol);
1468 }
util::Point getCenter(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns center point.
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.
double inscribedRadiusInBox(size_t dim, const std::pair< util::Point, util::Point > &box)
Computes the radius of biggest circle/sphere completely within the object.

References box(), geom::circumscribedRadiusInBox(), d_r, d_x, geom::getCenter(), geom::getCornerPoints(), geom::inscribedRadiusInBox(), isInside(), and util::isLess().

Here is the call graph for this function:

◆ isNear() [2/2]

bool geom::Circle::isNear ( const util::Point x,
const double &  tol 
) const
overridevirtual

Checks if point is within given distance of this object.

Parameters
xPoint
tolTolerance used in checking the nearness
Returns
True True if within the tol distance

Reimplemented from geom::GeomObject.

Definition at line 1389 of file geomObjects.cpp.

1390 {
1391
1392 // translate to origin
1393 auto x0 = x - d_x;
1394
1395 return util::isLess(x0.length(), d_r + tol);
1396 }

References d_r, d_x, and util::isLess().

Referenced by isNearBoundary().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNearBoundary()

bool geom::Circle::isNearBoundary ( const util::Point x,
const double &  tol,
const bool &  within 
) const
overridevirtual

cons

cons

Reimplemented from geom::GeomObject.

Definition at line 1398 of file geomObjects.cpp.

1400 {
1401
1402 // check if particle is within the tolerance distance
1403 if (!isNear(x, within ? 0. : tol))
1404 return false;
1405
1406 // check if it is close enough to circumference
1407 auto x0 = x - d_x;
1408
1409 return util::isLess(x0.length(), d_r + tol) ||
1410 util::isLess(x0.length(), d_r - tol);
1411 }
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.

References d_r, d_x, util::isLess(), and isNear().

Referenced by doesIntersect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isOutside() [1/2]

bool geom::Circle::isOutside ( const std::pair< util::Point, util::Point > &  box) const
overridevirtual

Checks if box is outside of the object.

Parameters
boxBox
Returns
True True if box lies outside

Reimplemented from geom::GeomObject.

Definition at line 1428 of file geomObjects.cpp.

1429 {
1430
1431 bool intersect = false;
1432 for (auto p: geom::getCornerPoints(2, box))
1433 if (!intersect)
1434 intersect = this->isInside(p);
1435
1436 return !intersect;
1437 }

References box(), geom::getCornerPoints(), and isInside().

Here is the call graph for this function:

◆ isOutside() [2/2]

bool geom::Circle::isOutside ( const util::Point x) const
overridevirtual

Checks if point is outside of this object.

Parameters
xPoint
Returns
True If point lies outside

Reimplemented from geom::GeomObject.

Definition at line 1385 of file geomObjects.cpp.

1385 {
1386 return !isInside(x);
1387 }

References isInside().

Here is the call graph for this function:

◆ operator=()

Circle & geom::Circle::operator= ( const Circle other)
inline

Assignment operator.

Parameters
otherObject to copy from
Returns
Reference to this object

Definition at line 2605 of file geomObjects.h.

2605 {
2606 if (this != &other) {
2607 // Copy base class members
2608 d_tags = other.d_tags;
2609
2610 // Copy member variables
2611 d_x = other.d_x;
2612 d_r = other.d_r;
2613 }
2614 return *this;
2615 }

References d_r, geom::GeomObject::d_tags, and d_x.

◆ print() [1/2]

void geom::Circle::print ( ) const
inlineoverridevirtual

Prints the information about the object.

Reimplemented from geom::GeomObject.

Definition at line 2741 of file geomObjects.h.

2741{ print(0, 0); };
void print() const override
Prints the information about the object.

References print().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print() [2/2]

void geom::Circle::print ( int  nt,
int  lvl 
) const
inlineoverridevirtual

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Reimplemented from geom::GeomObject.

Definition at line 2734 of file geomObjects.h.

2734 {
2735 std::cout << printStr(nt, lvl);
2736 };
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string geom::Circle::printStr ( int  nt,
int  lvl 
) const
overridevirtual

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Reimplemented from geom::GeomObject.

Definition at line 1481 of file geomObjects.cpp.

1481 {
1482
1483 auto tabS = util::io::getTabS(nt);
1484
1485 std::ostringstream oss;
1486
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;
1491
1492 if (lvl > 0)
1493 oss << tabS << "Bounding box: "
1494 << util::io::printBoxStr(box(0.), nt + 1);
1495
1496 if (lvl == 0)
1497 oss << std::endl;
1498
1499 return oss.str();
1500 }
const std::string d_name
name of object
std::string printBoxStr(const std::pair< util::Point, util::Point > &box, int nt=print_default_tab)
Returns formatted string for output.
Definition io.h:188
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:39
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition point.h:94

References box(), geom::GeomObject::d_name, d_r, d_x, util::io::getTabS(), util::io::printBoxStr(), and util::Point::printStr().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transform()

void geom::Circle::transform ( const util::Point translation,
const double &  scale,
const double &  angle,
const util::Point axis,
const util::Point rotationPoint 
)
inlineoverridevirtual

Similarity about pivot \(\mathbf p\) (default: old center d_x), then rigid displacement \(\mathbf t\) = translation: \(\mathbf y = \mathbf p + s\,\mathbf R(\mathbf x-\mathbf p) + \mathbf t\). When \(\theta=0\) and \(s=1\), \(\mathbf y = \mathbf x + \mathbf t\) for every point and the center.

Parameters
translationRigid translation vector \(\mathbf t\) (added after rotate+scale about \(\mathbf p\))
scaleUniform scale factor
angleRotation angle (radians)
axisAxis of rotation
rotationPointIf non-null, use as \(\mathbf p\); if null, use old d_x as pivot.

Reimplemented from geom::GeomObject.

Definition at line 2617 of file geomObjects.h.

2618 {
2619 const util::Point c0 = d_x;
2620 d_r *= scale;
2621 d_x = mapSimilarity(c0, c0, translation, scale, angle, axis, rotationPoint);
2622 }
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)
Definition geomObjects.h:55

References d_r, d_x, and geom::mapSimilarity().

Here is the call graph for this function:

◆ volume()

double geom::Circle::volume ( ) const
overridevirtual

Computes the volume (area in 2d, length in 1d) of object.

Returns
Volume Volume of object

Reimplemented from geom::GeomObject.

Definition at line 1348 of file geomObjects.cpp.

1348 {
1349 return M_PI * d_r * d_r;
1350 }

References d_r.

Field Documentation

◆ d_r

◆ d_x


The documentation for this class was generated from the following files: