ESyS-Particle
2.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
SimpleParticle.hpp
Go to the documentation of this file.
1
2
// //
3
// Copyright (c) 2003-2013 by The University of Queensland //
4
// Earth Systems Science Computational Centre (ESSCC) //
5
// http://www.uq.edu.au/esscc //
6
// //
7
// Primary Business: Brisbane, Queensland, Australia //
8
// Licensed under the Open Software License version 3.0 //
9
// http://www.opensource.org/licenses/osl-3.0.php //
10
// //
12
13
14
SimpleParticle::SimpleParticle
(
const
Vec3
& pos,
double
rad,
int
id
,
int
tag)
15
: SimpleParticleData(pos, rad, id, tag)
16
{
17
}
18
19
SimpleParticle::SimpleParticle
(
const
SimpleParticle
& p)
20
: SimpleParticleData(p)
21
{
22
}
23
24
SimpleParticle
&
SimpleParticle::operator=
(
const
SimpleParticle
& p)
25
{
26
SimpleParticleData::operator=(p);
27
return
*
this
;
28
}
29
30
const
Vec3
&
SimpleParticle::getPos
()
const
31
{
32
return
getPosition
();
33
}
34
35
void
SimpleParticle::setPos
(
const
Vec3
&pos)
36
{
37
setPosition
(pos);
38
}
39
40
void
SimpleParticle::moveTo
(
const
Vec3
&v)
41
{
42
setPosition
(v);
43
}
44
45
void
SimpleParticle::translateBy
(
const
Vec3
&v)
46
{
47
setPosition
(
getPosition
()+v);
48
}
49
50
void
SimpleParticle::moveBy
(
const
Vec3
&v)
51
{
52
translateBy
(v);
53
}
54
55
void
SimpleParticle::rotate
(
const
Vec3
&rotation,
const
Vec3
&posn)
56
{
57
// From http://mathworld.wolfram.com/RotationFormula.html
58
const
double
phi = rotation.
norm
();
59
if
(phi > 0.0)
60
{
61
const
Vec3
r =
getPosition
() - posn;
62
const
Vec3
n = rotation/phi;
63
const
double
cosPhi = cos(phi);
64
const
Vec3
rotatedR =
65
r*cosPhi + n*((
dot
(n, r))*(1-cosPhi)) +
cross
(r, n)*sin(phi);
66
setPosition
(rotatedR + posn);
67
}
68
}
69
70
double
SimpleParticle::getRad
()
const
71
{
72
return
getRadius
();
73
}
74
75
void
SimpleParticle::setRad
(
double
r)
76
{
77
setRadius
(r);
78
}
79
80
bool
SimpleParticle::isValid
()
const
81
{
82
return
(
getID
() >= 0);
83
}
84
85
template
<
typename
TmplVisitor>
86
void
SimpleParticle::visit
(
const
TmplVisitor &visitor)
const
87
{
88
visitor.visitSimpleParticle(*
this
);
89
}
90
91
template
<
typename
TmplVisitor>
92
void
SimpleParticle::visit
(TmplVisitor &visitor)
93
{
94
visitor.visitSimpleParticle(*
this
);
95
}
96
97
ostream&
operator<<
(ostream& ost,
const
SimpleParticle
& p)
98
{
99
ost
100
<<
"Particle- id "
<< p.
getId
()
101
<<
" pos: "
<< p.
getPosition
()
102
<<
" rad: "
<< p.
getRadius
()
103
<<
" tag : "
<< p.
getTag
() << std::endl;
104
return
ost;
105
}
106
107
ParticleComparer::ParticleComparer
(
const
SimpleParticle
&particle) : m_pParticle(&particle)
108
{
109
}
110
115
bool
ParticleComparer::operator()
(
const
SimpleParticle
&p1,
const
SimpleParticle
&p2)
const
116
{
117
return
(((p1.
getPos
() -
m_pParticle
->
getPos
()).norm() - p1.
getRad
())<
118
((p2.
getPos
() -
m_pParticle
->
getPos
()).norm() - p2.
getRad
()));
119
}
120
125
bool
ParticleComparer::operator()
(
const
SimpleParticle
*p1,
const
SimpleParticle
*p2)
const
126
{
127
return
(*
this
)(*p1, *p2);
128
}
Geometry
SimpleParticle.hpp
Generated on Mon May 6 2013 23:26:29 for ESyS-Particle by
1.8.3.1