MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Z.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #include "Z.h"
27 #include "Particles/BaseParticle.h"
28 #include "DPMBase.h"
29 
30 using namespace CGCoordinates;
31 
32 void Z::writeNames(std::ostream& os)
33 {
34  os << "z ";
35 }
36 
37 void Z::write(std::ostream& os) const
38 {
39  os << z_ << ' ';
40 }
41 
43 
45 {
46  return (max.X - min.X) * (max.Y - min.Y);
47 }
48 
50 {
51  z_ = z;
52 }
53 
55 {
56  return mathsFunc::square(p.Z - z_);
57 }
58 
65 {
66  return fabs(p.Z);
67 }
68 
73 Mdouble Z::getINormal(const BaseInteraction& c, const Vec3D& normal) const
74 {
75  return (c.getI()->getPosition().Z - z_) * normal.Z;
76 }
77 
82 Mdouble Z::getPNormal(const BaseInteraction& c, const Vec3D& normal) const
83 {
84  return (c.getP()->getPosition().Z - z_) * normal.Z;
85 }
86 
91 Mdouble Z::getCNormal(const BaseInteraction& c, const Vec3D& normal) const
92 {
93  return (c.getContactPoint().Z - z_) * normal.Z;
94 }
95 
96 std::string Z::getName()
97 {
98  return "Z";
99 }
100 
static Mdouble getLength(const Vec3D &p)
Returns the length of the input vector in the non-averaged directions.
Definition: Z.cc:64
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble X
the vector components
Definition: Vector.h:65
double Mdouble
Definition: GeneralDefine.h:34
Mdouble z_
Definition: Z.h:120
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
BaseInteractable * getI()
Returns a pointer to the second object involved in the interaction (often a wall or a particle)...
Mdouble getCNormal(const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between th...
Definition: Z.cc:91
Mdouble getPNormal(const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between th...
Definition: Z.cc:82
Stores information about interactions between two interactable objects; often particles but could be ...
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
void setZ(Mdouble x)
Returns the position of the current CGPoint, in the non-averaged directions.
Definition: Z.cc:49
static void writeNames(std::ostream &os)
Writes the coordinate names in human-readable form to an ostream.
Definition: Z.cc:32
Mdouble Y
Definition: Vector.h:65
static std::string getName()
Definition: Z.cc:96
Mdouble getINormal(const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between th...
Definition: Z.cc:73
Definition: Vector.h:49
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
void write(std::ostream &os) const
Writes the coordinates in human-readable form to an ostream.
Definition: Z.cc:37
Mdouble getDistanceSquared(const Vec3D &p) const
Returns the square of the distance between the particle p and the current CGPoint, in the non-averaged directions.
Definition: Z.cc:54
Mdouble Z
Definition: Vector.h:65
static Mdouble getVolumeOfAveragedDimensions(const Vec3D &min, const Vec3D &max)
returns the factor the CGFunction has to be divided by, due to integrating the variables over the ave...
Definition: Z.cc:44