MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XZ.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 "XZ.h"
27 #include "Particles/BaseParticle.h"
28 #include "DPMBase.h"
29 
30 using namespace CGCoordinates;
31 
32 void XZ::writeNames(std::ostream& os)
33 {
34  os << "x z ";
35 }
36 
37 void XZ::write(std::ostream& os) const
38 {
39  os << x_ << ' ' << z_ << ' ';
40 }
41 
44 {
45  return max.Y - min.Y;
46 }
47 
49 {
50  x_ = x;
51  z_ = z;
52 }
53 
55 {
56  return mathsFunc::square(p.X - x_) + mathsFunc::square(p.Z - z_);
57 }
58 
65 {
66  return sqrt(p.X * p.X + p.Z * p.Z);
67 }
68 
69 Mdouble XZ::getINormal(const BaseInteraction& c, const Vec3D& normal) const
70 {
71  return (c.getI()->getPosition().X - x_) * normal.X
72  + (c.getI()->getPosition().Z - z_) * normal.Z;
73 }
74 
75 Mdouble XZ::getPNormal(const BaseInteraction& c, const Vec3D& normal) const
76 {
77  return (c.getP()->getPosition().X - x_) * normal.X
78  + (c.getP()->getPosition().Z - z_) * normal.Z;
79 }
80 
81 Mdouble XZ::getCNormal(const BaseInteraction& c, const Vec3D& normal) const
82 {
83  return (c.getContactPoint().X - x_) * normal.X
84  + (c.getContactPoint().Z - z_) * normal.Z;
85 }
86 
88 {
89  return mathsFunc::square(c.getP()->getPosition().X - x_)
91  - mathsFunc::square(pNormal);
92 }
93 
94 std::string XZ::getName()
95 {
96  return "XZ";
97 }
Mdouble x_
Definition: XZ.h:124
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
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)...
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: XZ.cc:43
Stores information about interactions between two interactable objects; often particles but could be ...
void write(std::ostream &os) const
Writes the coordinates in human-readable form to an ostream.
Definition: XZ.cc:37
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
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: XZ.cc:54
Mdouble getTangentialSquared(const BaseInteraction &c, Mdouble pNormal) const
For the Interaction between particles/walls P and I, this function returns the square of the minimum ...
Definition: XZ.cc:87
static Mdouble getLength(const Vec3D &p)
Returns the length of the input vector in the non-averaged directions.
Definition: XZ.cc:64
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: XZ.cc:81
Mdouble z_
Definition: XZ.h:128
void setXZ(Mdouble x, Mdouble z)
Returns the position of the current CGPoint, in the non-averaged directions.
Definition: XZ.cc:48
static std::string getName()
Definition: XZ.cc:94
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: XZ.cc:75
Mdouble Y
Definition: Vector.h:65
static void writeNames(std::ostream &os)
Writes the coordinate names in human-readable form to an ostream.
Definition: XZ.cc:32
Definition: Vector.h:49
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: XZ.cc:69
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
Mdouble Z
Definition: Vector.h:65