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

Infinite plane: free space is the half-space in the normal direction. More...

#include <geomObjects.h>

Inheritance diagram for geom::Plane:
Collaboration diagram for geom::Plane:

Public Member Functions

 Plane ()
 
 Plane (util::Point n, util::Point p, std::string description="")
 
 Plane (const Plane &other)
 
Planeoperator= (const Plane &other)
 
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.
 
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 &) 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 wallContactQuery (const util::Point &x, WallContactHit &hit) const override
 Closest-point / signed-gap query for analytical wall contact. Default: unsupported (returns false, clears hit).
 
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.
 
- Public Member Functions inherited from geom::GeomObject
 GeomObject (std::string name="", std::string description="")
 Constructor.
 
virtual bool isInside (const std::pair< util::Point, util::Point > &box) const
 Checks if box is completely inside.
 
virtual bool isOutside (const std::pair< util::Point, util::Point > &box) const
 Checks if box is outside of the 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.
 
virtual bool doesIntersect (const std::pair< util::Point, util::Point > &box) const
 Checks if box intersects this object.
 

Data Fields

util::Point d_n
 outward (free-space) normal, stored unit-length when possible
 
util::Point d_p
 a point on the plane
 
- 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

Infinite plane: free space is the half-space in the normal direction.

Factory params: nx,ny,nz, px,py,pz (unit/non-unit normal + point on plane).

Definition at line 428 of file geomObjects.h.

Constructor & Destructor Documentation

◆ Plane() [1/3]

geom::Plane::Plane ( )
inline

Definition at line 433 of file geomObjects.h.

434 : GeomObject("plane", ""),
435 d_n(util::Point(0., 1., 0.)),
436 d_p(util::Point()) {}
GeomObject(std::string name="", std::string description="")
Constructor.
util::Point d_p
a point on the plane
util::Point d_n
outward (free-space) normal, stored unit-length when possible
A structure to represent 3d vectors.
Definition point.h:30

◆ Plane() [2/3]

geom::Plane::Plane ( util::Point  n,
util::Point  p,
std::string  description = "" 
)
inline

Definition at line 438 of file geomObjects.h.

439 : GeomObject("plane", std::move(description)), d_n(n), d_p(p) {
440 const double ln = d_n.length();
441 if (ln > 1.e-16)
442 d_n = d_n / ln;
443 }
double length() const
Computes the Euclidean length of the vector.
Definition point.h:124

References d_n, and util::Point::length().

Here is the call graph for this function:

◆ Plane() [3/3]

geom::Plane::Plane ( const Plane other)
inline

Definition at line 445 of file geomObjects.h.

446 : GeomObject(other.d_name, other.d_description),
447 d_n(other.d_n),
448 d_p(other.d_p) {
449 d_tags = other.d_tags;
450 }
std::vector< std::string > d_tags
Tags/attributes about the object.

References geom::GeomObject::d_tags.

Member Function Documentation

◆ boundingRadius()

double geom::Plane::boundingRadius ( ) const
inlineoverridevirtual

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 483 of file geomObjects.h.

483{ return 0.; }

◆ box() [1/2]

std::pair< util::Point, util::Point > geom::Plane::box ( ) const
inlineoverridevirtual

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 476 of file geomObjects.h.

476 {
477 return {d_p, d_p};
478 }

References d_p.

◆ box() [2/2]

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

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 479 of file geomObjects.h.

479 {
480 return {d_p - util::Point(tol, tol, tol), d_p + util::Point(tol, tol, tol)};
481 }

References d_p.

◆ center()

util::Point geom::Plane::center ( ) const
inlineoverridevirtual

Computes the center of object.

Returns
Point Coordinates of center

Reimplemented from geom::GeomObject.

Definition at line 475 of file geomObjects.h.

475{ return d_p; }

References d_p.

◆ doesIntersect()

bool geom::Plane::doesIntersect ( const util::Point x) const
inlineoverridevirtual

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 498 of file geomObjects.h.

498 {
499 return isNear(x, 1.e-12);
500 }
bool isNear(const util::Point &x, const double &tol) const override
Checks if point is within given distance of this object.

References isNear().

Here is the call graph for this function:

◆ inscribedRadius()

double geom::Plane::inscribedRadius ( ) const
inlineoverridevirtual

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 482 of file geomObjects.h.

482{ return 0.; }

◆ isInside()

bool geom::Plane::isInside ( const util::Point x) const
inlineoverridevirtual

Checks if point is inside this object.

Parameters
xPoint
Returns
True If point lies inside

Reimplemented from geom::GeomObject.

Definition at line 485 of file geomObjects.h.

485 {
486 return (x - d_p) * d_n < 0.;
487 }

References d_n, and d_p.

Referenced by isOutside().

Here is the caller graph for this function:

◆ isNear()

bool geom::Plane::isNear ( const util::Point x,
const double &  tol 
) const
inlineoverridevirtual

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 491 of file geomObjects.h.

491 {
492 return std::abs((x - d_p) * d_n) <= tol;
493 }

References d_n, and d_p.

Referenced by doesIntersect(), and isNearBoundary().

Here is the caller graph for this function:

◆ isNearBoundary()

bool geom::Plane::isNearBoundary ( const util::Point x,
const double &  tol,
const bool &  within 
) const
inlineoverridevirtual

Checks if point is within given distance of this object.

Parameters
xPoint
tolTolerance used in checking the nearness
withinCheck if the point is within (inside) the object
Returns
True True if it is near within tol distance

Reimplemented from geom::GeomObject.

Definition at line 494 of file geomObjects.h.

495 {
496 return isNear(x, tol);
497 }

References isNear().

Here is the call graph for this function:

◆ isOutside()

bool geom::Plane::isOutside ( const util::Point x) const
inlineoverridevirtual

Checks if point is outside of this object.

Parameters
xPoint
Returns
True If point lies outside

Reimplemented from geom::GeomObject.

Definition at line 488 of file geomObjects.h.

488 {
489 return !isInside(x);
490 }
bool isInside(const util::Point &x) const override
Checks if point is inside this object.

References isInside().

Here is the call graph for this function:

◆ operator=()

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

Definition at line 452 of file geomObjects.h.

452 {
453 if (this != &other) {
454 d_tags = other.d_tags;
455 d_n = other.d_n;
456 d_p = other.d_p;
457 }
458 return *this;
459 }

References d_n, d_p, and geom::GeomObject::d_tags.

◆ print() [1/2]

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

Prints the information about the object.

Reimplemented from geom::GeomObject.

Definition at line 516 of file geomObjects.h.

516{ 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::Plane::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 513 of file geomObjects.h.

513 {
514 std::cout << printStr(nt, lvl);
515 }
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::Plane::printStr ( int  nt,
int  lvl 
) const
inlineoverridevirtual

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 505 of file geomObjects.h.

505 {
506 auto tabS = util::io::getTabS(nt);
507 std::ostringstream oss;
508 oss << tabS << "------- Plane --------\n\n";
509 oss << tabS << "Normal = " << d_n.printStr(0, lvl) << "\n";
510 oss << tabS << "Point = " << d_p.printStr(0, lvl) << "\n";
511 return oss.str();
512 }
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 d_n, d_p, util::io::getTabS(), 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::Plane::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 461 of file geomObjects.h.

463 {
464 (void)scale;
465 const util::Point pivot =
466 (rotationPoint != nullptr) ? *rotationPoint : d_p;
467 d_p = mapSimilarity(d_p, pivot, translation, 1., angle, axis, rotationPoint);
468 d_n = util::rotate(d_n, angle, axis);
469 const double ln = d_n.length();
470 if (ln > 1.e-16)
471 d_n = d_n / ln;
472 }
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
util::Point rotate(const util::Point &p, const double &theta, const util::Point &axis)
Returns the vector after rotating by desired angle.

References d_n, d_p, util::Point::length(), geom::mapSimilarity(), and util::rotate().

Here is the call graph for this function:

◆ volume()

double geom::Plane::volume ( ) const
inlineoverridevirtual

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

Returns
Volume Volume of object

Reimplemented from geom::GeomObject.

Definition at line 474 of file geomObjects.h.

474{ return 0.; }

◆ wallContactQuery()

bool geom::Plane::wallContactQuery ( const util::Point x,
WallContactHit hit 
) const
overridevirtual

Closest-point / signed-gap query for analytical wall contact. Default: unsupported (returns false, clears hit).

Reimplemented from geom::GeomObject.

Definition at line 46 of file geomObjects.cpp.

47 {
48 hit = WallContactHit();
49 const double ln = d_n.length();
50 if (!(ln > 1.e-16))
51 return false;
52 const util::Point n = d_n / ln;
53 const double gap = (x - d_p) * n;
54 hit.active = true;
55 hit.signed_gap = gap;
56 hit.outward_n = n;
57 hit.closest = x - gap * n;
58 return true;
59 }

References geom::WallContactHit::active, geom::WallContactHit::closest, d_n, d_p, util::Point::length(), geom::WallContactHit::outward_n, and geom::WallContactHit::signed_gap.

Referenced by main().

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

Field Documentation

◆ d_n

util::Point geom::Plane::d_n

outward (free-space) normal, stored unit-length when possible

Definition at line 430 of file geomObjects.h.

Referenced by isInside(), isNear(), operator=(), Plane(), printStr(), transform(), and wallContactQuery().

◆ d_p

util::Point geom::Plane::d_p

a point on the plane

Definition at line 431 of file geomObjects.h.

Referenced by box(), box(), center(), isInside(), isNear(), operator=(), printStr(), transform(), and wallContactQuery().


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