PeriDEM
0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
particleTransform.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
#pragma once
12
13
#include "
util/point.h
"
// definition of Point
14
#include "
util/transformation.h
"
15
16
#include <cstring>
// string and size_t type
17
#include <vector>
18
19
namespace
particle
{
20
25
struct
ParticleTransform
{
26
28
util::Point
d_translation
;
29
31
util::Point
d_axis
;
32
34
double
d_theta
;
35
37
double
d_scale
;
38
44
ParticleTransform
()
45
:
d_translation
(
util
::Point()),
d_axis
(
util
::Point()),
46
d_theta
(0.),
d_scale
(1.){};
47
56
ParticleTransform
(
util::Point
translate,
util::Point
axis,
double
theta,
57
double
scale = 1.)
58
:
d_translation
(translate),
d_axis
(axis / axis.length()),
d_theta
(theta),
59
d_scale
(scale){};
60
65
ParticleTransform
(
const
ParticleTransform
&t)
66
:
d_translation
(t.
d_translation
),
d_axis
(t.
d_axis
),
67
d_theta
(t.
d_theta
),
d_scale
(t.
d_scale
){};
68
96
util::Point
apply
(
const
util::Point
&v)
const
{
97
98
return
d_translation
+
99
d_scale
*
util::rotate
(v,
d_theta
,
d_axis
);
100
101
// return d_translation + d_scale * util::Point(v.d_x, -v.d_y, 0.);
102
// return d_translation + v;
103
};
104
112
std::string
printStr
(
int
nt = 0,
int
lvl = 0)
const
{
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
}
125
132
void
print
(
int
nt = 0,
int
lvl = 0)
const
{ std::cout <<
printStr
(nt, lvl); }
133
};
134
135
}
// namespace particle
particle
Collection of methods and data related to particle object.
Definition
particleFLoading.h:22
util::io::getTabS
std::string getTabS(int nt)
Returns tab spaces of given size.
Definition
io.h:40
util
Collection of methods useful in simulation.
Definition
feElementDefs.h:14
util::rotate
util::Point rotate(const util::Point &p, const double &theta, const util::Point &axis)
Returns the vector after rotating by desired angle.
Definition
transformation.cpp:67
point.h
particle::ParticleTransform
A struct that stores transformation parameters and provides method to transform the particle....
Definition
particleTransform.h:25
particle::ParticleTransform::print
void print(int nt=0, int lvl=0) const
Prints the information about the object.
Definition
particleTransform.h:132
particle::ParticleTransform::d_theta
double d_theta
Angle of rotation.
Definition
particleTransform.h:34
particle::ParticleTransform::ParticleTransform
ParticleTransform()
Constructor.
Definition
particleTransform.h:44
particle::ParticleTransform::printStr
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition
particleTransform.h:112
particle::ParticleTransform::d_translation
util::Point d_translation
Translational vector.
Definition
particleTransform.h:28
particle::ParticleTransform::apply
util::Point apply(const util::Point &v) const
Returns the transformed vector. We assume that the passed vector passes through origin.
Definition
particleTransform.h:96
particle::ParticleTransform::ParticleTransform
ParticleTransform(const ParticleTransform &t)
Copy constructor.
Definition
particleTransform.h:65
particle::ParticleTransform::d_axis
util::Point d_axis
Axis of rotation.
Definition
particleTransform.h:31
particle::ParticleTransform::ParticleTransform
ParticleTransform(util::Point translate, util::Point axis, double theta, double scale=1.)
Constructor.
Definition
particleTransform.h:56
particle::ParticleTransform::d_scale
double d_scale
Volumetric scaling factor.
Definition
particleTransform.h:37
util::Point
A structure to represent 3d vectors.
Definition
point.h:30
util::Point::printStr
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition
point.h:94
transformation.h
src
particle
particleTransform.h
Generated by
1.9.8