MercuryDPM
Beta
|
Implementation of a 3D vector (by Vitaliy). More...
#include <Vector.h>
Public Member Functions | |
Vec3D () | |
constructor More... | |
Vec3D (const Mdouble x, const Mdouble y, const Mdouble z) | |
Alternative constructor, taking the three elements as arguments. More... | |
void | setZero () |
Sets all elements to zero. More... | |
bool | isZero () const |
Checks if ALL elements are zero. More... | |
Vec3D | operator+ (const Vec3D &a) const |
Adds another vector. More... | |
Vec3D | operator- (const Vec3D &a) const |
Subtracts another vector. More... | |
Vec3D | operator+ (const Mdouble a) const |
Adds a scalar. More... | |
Vec3D | operator- (const Mdouble a) const |
Subtracts a scalar. More... | |
Vec3D | operator* (const Mdouble a) const |
Multiplies by a scalar. More... | |
Vec3D | operator/ (const Mdouble a) const |
Divides by a scalar. More... | |
Vec3D & | operator+= (const Vec3D &a) |
Adds another vector. More... | |
Vec3D & | operator-= (const Vec3D &a) |
Subtracts another vector. More... | |
Vec3D & | operator*= (const Mdouble a) |
Multiplies by a scalar. More... | |
Vec3D & | operator/= (const Mdouble a) |
Divides by a scalar. More... | |
void | normalize () |
Makes this Vec3D unit length. More... | |
void | setLength (Mdouble length) |
Make this Vec3D a certain length. More... | |
Mdouble | getLength () const |
Calculates the length of this Vec3D: \( \sqrt{a\cdot a} \). More... | |
Mdouble | getLengthSquared () const |
Calculates the squared length of this Vec3D: \( a\cdot a \). More... | |
Mdouble | getComponent (const int index) const |
Returns the requested component of this Vec3D. More... | |
void | setComponent (const int index, const double val) |
Sets the requested component of this Vec3D to the requested value. More... | |
Vec3D | getCylindricalCoordinates () const |
Returns the representation of this Vec3D in cylindrical coordinates. More... | |
Vec3D | getFromCylindricalCoordinates () const |
Returns the representation of this Vec3D in cartesian coordinates. More... | |
bool | isEqualTo (const Vec3D &other, const double tol) const |
Checks if the length this Vec3D is equal the length of other with a certain tolerance. More... | |
Static Public Member Functions | |
static Mdouble | dot (const Vec3D &a, const Vec3D &b) |
Calculates the dot product of two Vec3D: \( a \cdot b\). More... | |
static Vec3D | max (const Vec3D &a, const Vec3D &b) |
Calculates the pointwise maximum of two Vec3D. More... | |
static Vec3D | min (const Vec3D &a, const Vec3D &b) |
Calculates the pointwise minimum of two Vec3D. More... | |
static Vec3D | square (const Vec3D &a) |
Calculates the pointwise square of a Vec3D. More... | |
static Vec3D | sqrt (const Vec3D &a) |
Calculates the pointwise square root of a Vec3D. More... | |
static Vec3D | cross (const Vec3D &a, const Vec3D &b) |
Calculates the cross product of two Vec3D: \( a \times b\). More... | |
static Mdouble | getDistance (const Vec3D &a, const Vec3D &b) |
Calculates the distance between two Vec3D: \( \sqrt{\left(a-b\right) \cdot \left(a-b\right)} \). More... | |
static Mdouble | getDistanceSquared (const Vec3D &a, const Vec3D &b) |
Calculates the squared distance between two Vec3D: \( \left(a-b\right) \cdot \left(a-b\right) \). More... | |
static Mdouble | getLength (const Vec3D &a) |
Calculates the length of a Vec3D: \( \sqrt{a\cdot a} \). More... | |
static Mdouble | getLengthSquared (const Vec3D &a) |
Calculates the squared length of a Vec3D: \( a\cdot a \). More... | |
static Vec3D | getUnitVector (const Vec3D &a) |
Returns a unit Vec3D based on a. More... | |
Public Attributes | |
Mdouble | X |
the vector components More... | |
Mdouble | Y |
Mdouble | Z |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Vec3D &a) |
Adds elements to an output stream. More... | |
std::istream & | operator>> (std::istream &is, Vec3D &a) |
Adds elements to an input stream. More... | |
Vec3D | operator+ (const Mdouble a, const Vec3D &b) |
Adds a scalar to a vector. More... | |
Vec3D | operator- (const Mdouble a, const Vec3D &b) |
Subtracts the elements of a vector from a scalar. More... | |
Vec3D | operator- (const Vec3D &a) |
Subtracts a vector. More... | |
Vec3D | operator* (const Mdouble a, const Vec3D &b) |
Multiplies all elements by a scalar. More... | |
Implementation of a 3D vector (by Vitaliy).
Modifications 21:9:2009 - Added the inclusion guards and some include objects
Vec3D::Vec3D | ( | ) |
constructor
Default constructor
Definition at line 31 of file Vector.cc.
References setZero().
Referenced by cross(), getCylindricalCoordinates(), getFromCylindricalCoordinates(), getUnitVector(), max(), min(), operator*(), operator+(), operator-(), operator/(), sqrt(), and square().
Calculates the cross product of two Vec3D: \( a \times b\).
Calculates the cross product of two vectors NB: this is a STATIC function!
[in] | a | the first vector |
[in] | b | the second vector |
Definition at line 268 of file Vector.cc.
References Vec3D(), X, Y, and Z.
Referenced by ChuteWithHopper::addHopper(), IntersectionOfWalls::addObject(), DPMBase::computeForcesDueToWalls(), FrictionInteraction::computeFrictionForce(), DPMBase::computeInternalForces(), IntersectionOfWalls::createOpenPrism(), IntersectionOfWalls::createPrism(), BaseInteractable::getVelocityAtContact(), and AngledPeriodicBoundary::set().
Calculates the dot product of two Vec3D: \( a \cdot b\).
Calculates the dot product of two vectors. NB: this is a STATIC function!
[in] | a | the first vector |
[in] | b | the second vector |
Definition at line 187 of file Vector.cc.
Referenced by IntersectionOfWalls::addObject(), SlidingFrictionInteraction::computeFrictionForce(), FrictionInteraction::computeFrictionForce(), LinearPlasticViscoelasticInteraction::computeLinearPlasticViscoelasticForce(), HertzianViscoelasticInteraction::computeNormalForce(), LinearViscoelasticInteraction::computeNormalForce(), AngledPeriodicBoundary::distance(), BaseInteraction::gatherContactStatistics(), DeletionBoundary::getDistance(), MaserBoundary::getDistance(), PeriodicBoundary::getDistance(), InfiniteWall::getDistance(), AxisymmetricIntersectionOfWalls::getDistanceAndNormal(), IntersectionOfWalls::getDistanceAndNormal(), AngledPeriodicBoundary::getOpeningAngle(), InfiniteWallWithHole::getWallDistance(), FrictionInteraction::integrate(), InfiniteWallWithHole::move_time(), DeletionBoundary::set(), AngledPeriodicBoundary::set(), PeriodicBoundary::set(), InfiniteWallWithHole::set(), AngledPeriodicBoundary::shiftPosition(), AngledPeriodicBoundary::shiftPositions(), DPMBase::writeEneTimestep(), and BaseInteraction::writeToFStat().
Mdouble Vec3D::getComponent | ( | const int | index | ) | const |
Returns the requested component of this Vec3D.
returns the vector element belonging to the given index.
[in] | index | the index of interest (should be 0, 1 or 2) |
Definition at line 323 of file Vector.cc.
Vec3D Vec3D::getCylindricalCoordinates | ( | ) | const |
Calculates the distance between two Vec3D: \( \sqrt{\left(a-b\right) \cdot \left(a-b\right)} \).
Calculates the distance (i.e. the length of the difference) between two vectors NB: this is a STATIC function!
[in] | a | the first vector |
[in] | b | the second vector |
Definition at line 280 of file Vector.cc.
References getDistanceSquared().
Calculates the squared distance between two Vec3D: \( \left(a-b\right) \cdot \left(a-b\right) \).
Calculates the square of the distance (i.e. the length of the difference) between two vectors. NB: this is a STATIC function!
[in] | a | the first vector |
[in] | b | the second vector |
Definition at line 293 of file Vector.cc.
Referenced by DPMBase::areInContact(), DPMBase::checkParticleForInteraction(), and getDistance().
Vec3D Vec3D::getFromCylindricalCoordinates | ( | ) | const |
Calculates the length of a Vec3D: \( \sqrt{a\cdot a} \).
Calculates the length of a given vector NB: this is a STATIC function!
[in] | a | vector to be measured. |
Definition at line 427 of file Vector.cc.
References getLength().
Referenced by BaseInteraction::gatherContactStatistics(), Screw::getDistanceAndNormal(), CylindricalWall::getDistanceAndNormal(), AxisymmetricIntersectionOfWalls::getDistanceAndNormal(), Coil::getDistanceAndNormal(), InfiniteWallWithHole::getDistanceAndNormal(), getLength(), SlidingFrictionInteraction::getTangentialOverlap(), Chute::setChuteAngle(), and BaseInteraction::writeToFStat().
Mdouble Vec3D::getLength | ( | ) | const |
Calculates the length of this Vec3D: \( \sqrt{a\cdot a} \).
Calculates the length of this vector
Definition at line 416 of file Vector.cc.
References getLengthSquared().
Referenced by normalize(), AngledPeriodicBoundary::set(), setLength(), and InfiniteWall::setNormal().
Calculates the squared length of a Vec3D: \( a\cdot a \).
Calculates the square of the length of a given vector. NB: this is a STATIC function!
[in] | a | the vector. |
Definition at line 304 of file Vector.cc.
Referenced by ChuteWithHopper::addHopper(), SlidingFrictionInteraction::computeFrictionForce(), FrictionInteraction::computeFrictionForce(), IntersectionOfWalls::getDistanceAndNormal(), SlidingFrictionInteraction::getElasticEnergy(), FrictionInteraction::getElasticEnergy(), BaseParticle::getKineticEnergy(), getUnitVector(), and Quarternion::integrate().
Mdouble Vec3D::getLengthSquared | ( | ) | const |
Calculates the squared length of this Vec3D: \( a\cdot a \).
Calculates the square of the length of itself
Definition at line 313 of file Vector.cc.
Referenced by BaseParticle::getInteractionWith(), getLength(), and isEqualTo().
Returns a unit Vec3D based on a.
Calculates the unit vector of a given vector (unless it is a vector with zero length; in that case it returns a 3D vector with each element equal to zero). NB: this is a STATIC function!
[in] | a | the vector of interest |
Definition at line 441 of file Vector.cc.
References getLengthSquared(), and Vec3D().
Referenced by IntersectionOfWalls::createOpenPrism(), and IntersectionOfWalls::createPrism().
bool Vec3D::isEqualTo | ( | const Vec3D & | other, |
const double | tol | ||
) | const |
Checks if the length this Vec3D is equal the length of other with a certain tolerance.
Checks if the length of the vector is equal to the one given in the first argument (other), with a tolerance given in the second argument (tol).
[in] | other | the 3D vector to check against |
[in] | tol | the tolerance |
Definition at line 390 of file Vector.cc.
References getLengthSquared().
bool Vec3D::isZero | ( | ) | const |
Calculates the pointwise maximum of two Vec3D.
Calculates the pointwise maximum of two vectors. NB: this is a STATIC function!
[in] | a | the first vector |
[in] | b | the second vector |
Definition at line 200 of file Vector.cc.
References Vec3D(), X, Y, and Z.
Calculates the pointwise minimum of two Vec3D.
Calculates the pointwise minimum of two vectors. NB: this is a STATIC function!
[in] | a | the first vector |
[in] | b | the second vector |
Definition at line 213 of file Vector.cc.
References Vec3D(), X, Y, and Z.
void Vec3D::normalize | ( | ) |
Makes this Vec3D unit length.
Normalises the vector, i.e. divides all elements by the vectors length (resulting in a vector in the same direction, but with unit length).
Definition at line 234 of file Vector.cc.
References getLength().
Referenced by IntersectionOfWalls::addObject(), and Quarternion::Quarternion().
void Vec3D::setComponent | ( | const int | index, |
const double | val | ||
) |
Sets the requested component of this Vec3D to the requested value.
Sets the element of the vector belonging to the first argument (index) to the value given in the second argument (val).
[in] | index | index of element of interest, |
[in] | val | value to be set |
Definition at line 345 of file Vector.cc.
void Vec3D::setLength | ( | Mdouble | length | ) |
Make this Vec3D a certain length.
Sets the length of the vector to a given scalar (while maintaining the direction).
[in] | length | the length to be set |
Definition at line 244 of file Vector.cc.
References getLength().
void Vec3D::setZero | ( | ) |
Sets all elements to zero.
Sets each element to zero.
Definition at line 52 of file Vector.cc.
Referenced by BaseInteractable::BaseInteractable(), BaseInteraction::BaseInteraction(), BaseParticle::BaseParticle(), Coil::Coil(), FrictionInteraction::FrictionInteraction(), Screw::Screw(), SlidingFrictionInteraction::SlidingFrictionInteraction(), StatisticsPoint< T >::StatisticsPoint(), and Vec3D().
Calculates the pointwise square root of a Vec3D.
Calculates the pointwise square root of a given vector. NB: this is a STATIC function!
[in] | a | the vector to be pointwise square rooted |
Definition at line 256 of file Vector.cc.
References Vec3D(), X, Y, and Z.
Calculates the pointwise square of a Vec3D.
Calculates the pointwise square of the vector. NB: this is a STATIC function!
[in] | a | the vector to be squared. |
Definition at line 225 of file Vector.cc.
References Vec3D(), X, Y, and Z.
Multiplies all elements by a scalar.
Multiplies each element of a given vector (b) by a given scalar (a). NB: this is a global function and a friend of the Vec3D class. Gets called when a scalar multiplication of the form (Mdouble) * (Vec3D) is performed.
[in] | a | the scalar |
[in] | b | the vector |
Definition at line 522 of file Vector.cc.
Adds a scalar to a vector.
Adds a scalar to the elements of given vector NB this is a global function and a friend of the Vec3D class. Gets called when addition operation of the form (Mdouble) + (Vec3D) is performed.
[in] | a | the scalar to be added |
[in] | b | the vector the scalar gets added to. |
Definition at line 484 of file Vector.cc.
Subtracts the elements of a vector from a scalar.
Subtracts each element of a given vector from a scalar NB this is a global function and a friend of the Vec3D class. Gets called when subtraction operation of the form (Mdouble) - (Vec3D) is performed.
[in] | a | the scalar |
[in] | b | the vector to be subtracted the scalar gets subtracted from. |
Definition at line 497 of file Vector.cc.
Subtracts a vector.
Returns the negative of a given vector. NB: this is a global function and a friend of the Vec3D class. Gets called when a negation operation of the form - (Vec3D) is performed.
[in] | a | the vector to be negated |
Definition at line 509 of file Vector.cc.
|
friend |
Adds elements to an output stream.
Adds all elements of the vector to an output stream. NB: this is a global function and a friend of the Vec3D class!
[in] | os | the output stream, |
[in] | a | The vector of interest |
Definition at line 457 of file Vector.cc.
|
friend |
Adds elements to an input stream.
Reads all elements of a given vector from an input stream. NB: this is a global function and a friend of the Vec3D class!
[in,out] | is | the input stream |
[in,out] | a | the vector to be read in |
Definition at line 470 of file Vector.cc.
Mdouble Vec3D::X |
the vector components
Definition at line 52 of file Vector.h.
Referenced by ChuteWithHopper::addHopper(), CircularPeriodicBoundary::checkBoundaryAfterParticleMoved(), Chute::cleanChute(), Chute::createBottom(), CircularPeriodicBoundary::createPeriodicParticles(), Matrix3D::cross(), cross(), dot(), Matrix3D::dyadic(), ChuteInsertionBoundary::generateParticle(), CubeInsertionBoundary::generateParticle(), getComponent(), getCylindricalCoordinates(), BaseParticle::getDisplacement2(), Screw::getDistanceAndNormal(), CylindricalWall::getDistanceAndNormal(), AxisymmetricIntersectionOfWalls::getDistanceAndNormal(), Coil::getDistanceAndNormal(), InfiniteWallWithHole::getDistanceAndNormal(), getDistanceSquared(), getFromCylindricalCoordinates(), InfiniteWallWithHole::getHoleDistance(), LeesEdwardsBoundary::getHorizontalDistance(), getLengthSquared(), Mercury2D::hGridFindOneSidedContacts(), Mercury3D::hGridFindOneSidedContacts(), Mercury2D::hGridHasParticleContacts(), Mercury2D::hGridUpdateParticle(), Mercury3D::hGridUpdateParticle(), Quarternion::integrate(), mathsFunc::isEqual(), isZero(), max(), min(), Matrix3D::operator*(), operator*(), operator*(), operator*=(), operator+(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/=(), operator<<(), operator>>(), Quarternion::Quarternion(), DPMBase::readNextDataFile(), ParticleHandler::readOldObject(), CircularPeriodicBoundary::rotateParticle(), MatrixSymmetric3D::selfDyadic(), AngledPeriodicBoundary::set(), setComponent(), ChuteBottom::setupInitialConditions(), setZero(), sqrt(), square(), MatrixSymmetric3D::symmetrisedDyadic(), and Vec3D().
Mdouble Vec3D::Y |
Definition at line 52 of file Vector.h.
Referenced by CircularPeriodicBoundary::checkBoundaryAfterParticleMoved(), Chute::createBottom(), CircularPeriodicBoundary::createPeriodicParticles(), Matrix3D::cross(), cross(), dot(), Matrix3D::dyadic(), ChuteInsertionBoundary::generateParticle(), CubeInsertionBoundary::generateParticle(), getComponent(), getCylindricalCoordinates(), BaseParticle::getDisplacement2(), Screw::getDistanceAndNormal(), CylindricalWall::getDistanceAndNormal(), Coil::getDistanceAndNormal(), InfiniteWallWithHole::getDistanceAndNormal(), getDistanceSquared(), getFromCylindricalCoordinates(), InfiniteWallWithHole::getHoleDistance(), getLengthSquared(), LeesEdwardsBoundary::getVerticalDistance(), Mercury2D::hGridFindOneSidedContacts(), Mercury3D::hGridFindOneSidedContacts(), Mercury2D::hGridHasParticleContacts(), Mercury2D::hGridUpdateParticle(), Mercury3D::hGridUpdateParticle(), Quarternion::integrate(), mathsFunc::isEqual(), isZero(), max(), min(), Matrix3D::operator*(), operator*(), operator*(), operator*=(), operator+(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/=(), operator<<(), operator>>(), Quarternion::Quarternion(), DPMBase::readNextDataFile(), ParticleHandler::readOldObject(), CircularPeriodicBoundary::rotateParticle(), MatrixSymmetric3D::selfDyadic(), AngledPeriodicBoundary::set(), setComponent(), ChuteBottom::setupInitialConditions(), setZero(), sqrt(), square(), MatrixSymmetric3D::symmetrisedDyadic(), and Vec3D().
Mdouble Vec3D::Z |
Definition at line 52 of file Vector.h.
Referenced by ChuteWithHopper::addHopper(), Matrix3D::cross(), cross(), dot(), Matrix3D::dyadic(), ChuteInsertionBoundary::generateParticle(), CubeInsertionBoundary::generateParticle(), getComponent(), getCylindricalCoordinates(), BaseParticle::getDisplacement2(), Screw::getDistanceAndNormal(), CylindricalWall::getDistanceAndNormal(), AxisymmetricIntersectionOfWalls::getDistanceAndNormal(), Coil::getDistanceAndNormal(), InfiniteWallWithHole::getDistanceAndNormal(), getDistanceSquared(), getFromCylindricalCoordinates(), getLengthSquared(), Mercury3D::hGridFindOneSidedContacts(), Mercury3D::hGridUpdateParticle(), Quarternion::integrate(), mathsFunc::isEqual(), isZero(), max(), min(), Matrix3D::operator*(), operator*(), operator*(), operator*=(), operator+(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/=(), operator<<(), operator>>(), Quarternion::Quarternion(), DPMBase::readNextDataFile(), ParticleHandler::readOldObject(), CircularPeriodicBoundary::rotateParticle(), MatrixSymmetric3D::selfDyadic(), AngledPeriodicBoundary::set(), setComponent(), ChuteBottom::setupInitialConditions(), setZero(), sqrt(), square(), MatrixSymmetric3D::symmetrisedDyadic(), and Vec3D().