PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
particle::ParticleTransform Struct Reference

A struct that stores transformation parameters and provides method to transform the particle. Basically, given a reference particle, this provides method to translate, rotate, and scale the reference particle. More...

#include <particleTransform.h>

Collaboration diagram for particle::ParticleTransform:

Public Member Functions

 ParticleTransform ()
 Constructor.
 
 ParticleTransform (util::Point translate, util::Point axis, double theta, double scale=1.)
 Constructor.
 
 ParticleTransform (const ParticleTransform &t)
 Copy constructor.
 
util::Point apply (const util::Point &v) const
 Returns the transformed vector. We assume that the passed vector passes through origin.
 
std::string printStr (int nt=0, int lvl=0) const
 Returns the string containing printable information about the object.
 
void print (int nt=0, int lvl=0) const
 Prints the information about the object.
 

Data Fields

util::Point d_translation
 Translational vector.
 
util::Point d_axis
 Axis of rotation.
 
double d_theta
 Angle of rotation.
 
double d_scale
 Volumetric scaling factor.
 

Detailed Description

A struct that stores transformation parameters and provides method to transform the particle. Basically, given a reference particle, this provides method to translate, rotate, and scale the reference particle.

Definition at line 25 of file particleTransform.h.

Constructor & Destructor Documentation

◆ ParticleTransform() [1/3]

particle::ParticleTransform::ParticleTransform ( )
inline

Constructor.

Default constructor creates identity transformation, i.e., transform(x) = x.

Definition at line 44 of file particleTransform.h.

46 d_theta(0.), d_scale(1.){};
double d_theta
Angle of rotation.
util::Point d_translation
Translational vector.
util::Point d_axis
Axis of rotation.
double d_scale
Volumetric scaling factor.
A structure to represent 3d vectors.
Definition point.h:30

◆ ParticleTransform() [2/3]

particle::ParticleTransform::ParticleTransform ( util::Point  translate,
util::Point  axis,
double  theta,
double  scale = 1. 
)
inline

Constructor.

Parameters
translateTranslation vector
axisAxis of rotation
thetaAngle of rotation
scaleVolumetric scaling

Definition at line 56 of file particleTransform.h.

58 : d_translation(translate), d_axis(axis / axis.length()), d_theta(theta),
59 d_scale(scale){};
double length() const
Computes the Euclidean length of the vector.
Definition point.h:118

◆ ParticleTransform() [3/3]

particle::ParticleTransform::ParticleTransform ( const ParticleTransform t)
inline

Copy constructor.

Parameters
tAnother ParticleTransform object

Definition at line 65 of file particleTransform.h.

66 : d_translation(t.d_translation), d_axis(t.d_axis),
67 d_theta(t.d_theta), d_scale(t.d_scale){};

Member Function Documentation

◆ apply()

util::Point particle::ParticleTransform::apply ( const util::Point v) const
inline

Returns the transformed vector. We assume that the passed vector passes through origin.

Let B(0, R) is the ball centered at origin. Let v is a point in ball B (0,R).

Suppose we want to transform v so that it is now in ball B(x, r), where x is the point in space, r is the radius of new ball.

Further, suppose we also want to rotate the v by angle theta about axis a and scale v by amount s.

To do this, we assume that this class was constructed with x, a, theta, and s, i.e. ParticleTransform(x, a, theta, s).

Following transformation is applied on vector v

  1. Rotation by angle theta about axis a
  2. Next, scale the vector
  3. Finally, translate the vector
Parameters
vVector v in ball
Returns
vector Transformed vector

Definition at line 96 of file particleTransform.h.

96 {
97
98 return d_translation +
100
101 // return d_translation + d_scale * util::Point(v.d_x, -v.d_y, 0.);
102 // return d_translation + v;
103 };
util::Point rotate(const util::Point &p, const double &theta, const util::Point &axis)
Returns the vector after rotating by desired angle.

References d_axis, d_scale, d_theta, d_translation, and util::rotate().

Referenced by particle::BaseParticle::BaseParticle().

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

◆ print()

void particle::ParticleTransform::print ( int  nt = 0,
int  lvl = 0 
) const
inline

Prints the information about the object.

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

Definition at line 132 of file particleTransform.h.

132{ std::cout << printStr(nt, lvl); }
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string particle::ParticleTransform::printStr ( int  nt = 0,
int  lvl = 0 
) const
inline

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

Definition at line 112 of file particleTransform.h.

112 {
113
114 auto tabS = util::io::getTabS(nt);
115 std::ostringstream oss;
116 oss << tabS << "------- ParticleTransform --------" << std::endl << std::endl;
117 oss << tabS << "Scale = " << d_scale << std::endl;
118 oss << tabS << "Angle = " << d_theta << std::endl;
119 oss << tabS << "Translation = " << d_translation.printStr() << std::endl;
120 oss << tabS << "Axis = " << d_axis.printStr() << std::endl;
121 oss << tabS << std::endl;
122
123 return oss.str();
124 }
std::string getTabS(int nt)
Returns tab spaces of given size.
Definition io.h:40
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_axis, d_scale, d_theta, d_translation, 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:

Field Documentation

◆ d_axis

util::Point particle::ParticleTransform::d_axis

Axis of rotation.

Definition at line 31 of file particleTransform.h.

Referenced by apply(), and printStr().

◆ d_scale

double particle::ParticleTransform::d_scale

Volumetric scaling factor.

Definition at line 37 of file particleTransform.h.

Referenced by apply(), particle::BaseParticle::BaseParticle(), and printStr().

◆ d_theta

double particle::ParticleTransform::d_theta

Angle of rotation.

Definition at line 34 of file particleTransform.h.

Referenced by apply(), and printStr().

◆ d_translation

util::Point particle::ParticleTransform::d_translation

Translational vector.

Definition at line 28 of file particleTransform.h.

Referenced by apply(), and printStr().


The documentation for this struct was generated from the following file: