MercuryDPM
Alpha
|
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 |
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: . More... | |
Mdouble | getLengthSquared () const |
Calculates the squared length of this Vec3D: . 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: . 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: . More... | |
static Mdouble | getDistance (const Vec3D &a, const Vec3D &b) |
Calculates the distance between two Vec3D: . More... | |
static Mdouble | getDistanceSquared (const Vec3D &a, const Vec3D &b) |
Calculates the squared distance between two Vec3D: . More... | |
static Mdouble | getLength (const Vec3D &a) |
Calculates the length of a Vec3D: . More... | |
static Mdouble | getLengthSquared (const Vec3D &a) |
Calculates the squared length of a Vec3D: . 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 Vec3D &a) |
Adds a scalar to 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: .
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 255 of file Vector.cc.
References Vec3D(), X, Y, and Z.
Referenced by ChuteWithHopper::addHopper(), IntersectionOfWalls::addObject(), DPMBase::computeForcesDueToWalls(), FrictionInteraction::computeFrictionForce(), MindlinRollingTorsionInteraction::computeFrictionForce(), DPMBase::computeInternalForces(), IntersectionOfWalls::createOpenPrism(), IntersectionOfWalls::createPrism(), BaseInteractable::getVelocityAtContact(), TriangulatedWall::readVTK(), and AngledPeriodicBoundary::set().
Calculates the dot product of two Vec3D: .
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 167 of file Vector.cc.
Referenced by IntersectionOfWalls::addObject(), SlidingFrictionInteraction::computeFrictionForce(), FrictionInteraction::computeFrictionForce(), MindlinInteraction::computeFrictionForce(), MindlinRollingTorsionInteraction::computeFrictionForce(), LinearPlasticViscoelasticInteraction::computeLinearPlasticViscoelasticForce(), HertzianViscoelasticInteraction::computeNormalForce(), SinterInteraction::computeNormalForce(), LinearViscoelasticInteraction::computeNormalForce(), HertzianSinterInteraction::computeSinterForce(), AxisymmetricIntersectionOfWalls::convertLimits(), AngledPeriodicBoundary::distance(), BaseInteraction::gatherContactStatistics(), DeletionBoundary::getDistance(), TriangulatedWall::Face::getDistance(), MaserBoundary::getDistance(), InfiniteWall::getDistance(), PeriodicBoundary::getDistance(), TriangulatedWall::Face::getDistanceAndNormal(), AxisymmetricIntersectionOfWalls::getDistanceAndNormal(), IntersectionOfWalls::getDistanceAndNormal(), DPMBase::getGravitationalEnergy(), InteractionHandler::getInteraction(), BaseWall::getLinePlaneIntersect(), AngledPeriodicBoundary::getOpeningAngle(), MindlinInteraction::getTangentialOverlap(), InfiniteWallWithHole::getWallDistance(), FrictionInteraction::integrate(), MindlinRollingTorsionInteraction::integrate(), PeriodicBoundary::isClosestToLeftBoundary(), BaseWall::isInsideWallVTK(), InfiniteWallWithHole::move_time(), BaseWall::projectOntoWallVTK(), DeletionBoundary::set(), AngledPeriodicBoundary::set(), PeriodicBoundary::set(), InfiniteWallWithHole::set(), AngledPeriodicBoundary::shiftPosition(), AngledPeriodicBoundary::shiftPositions(), MindlinInteraction::updateK_t(), 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 310 of file Vector.cc.
Vec3D Vec3D::getCylindricalCoordinates | ( | ) | const |
Calculates the distance between two Vec3D: .
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 267 of file Vector.cc.
References getDistanceSquared().
Calculates the squared distance between two Vec3D: .
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 280 of file Vector.cc.
Referenced by DPMBase::areInContact(), DPMBase::checkParticleForInteractionLocal(), and getDistance().
Vec3D Vec3D::getFromCylindricalCoordinates | ( | ) | const |
Returns the representation of this Vec3D in cartesian coordinates.
Transforms the (cylindrical) vector to cartesian coordinates
Definition at line 363 of file Vector.cc.
References mathsFunc::cos(), mathsFunc::sin(), Vec3D(), X, Y, and Z.
Calculates the length of a Vec3D: .
Calculates the length of a given vector NB: this is a STATIC function!
[in] | a | vector to be measured. |
Definition at line 414 of file Vector.cc.
References getLength().
Referenced by MindlinInteraction::computeFrictionForce(), BaseInteraction::gatherContactStatistics(), CylindricalWall::getDistanceAndNormal(), Coil::getDistanceAndNormal(), AxisymmetricIntersectionOfWalls::getDistanceAndNormal(), InfiniteWallWithHole::getDistanceAndNormal(), getLength(), SlidingFrictionInteraction::getTangentialOverlap(), MindlinInteraction::getTangentialOverlap(), FileReader::read(), Chute::setChuteAngle(), MindlinInteraction::updateK_t(), and BaseInteraction::writeToFStat().
Mdouble Vec3D::getLength | ( | ) | const |
Calculates the length of this Vec3D: .
Calculates the length of this vector
Definition at line 403 of file Vector.cc.
References getLengthSquared().
Referenced by SphericalWall::getDistance(), TriangulatedWall::Face::getDistanceAndNormal(), SphericalWall::getDistanceAndNormal(), normalize(), AngledPeriodicBoundary::set(), and InfiniteWall::setNormal().
Calculates the squared length of a Vec3D: .
Calculates the square of the length of a given vector. NB: this is a STATIC function!
[in] | a | the vector. |
Definition at line 291 of file Vector.cc.
Referenced by ChuteWithHopper::addHopper(), SlidingFrictionInteraction::computeFrictionForce(), FrictionInteraction::computeFrictionForce(), MindlinRollingTorsionInteraction::computeFrictionForce(), IntersectionOfWalls::getDistanceAndNormal(), SlidingFrictionInteraction::getElasticEnergy(), FrictionInteraction::getElasticEnergy(), MindlinInteraction::getElasticEnergy(), MindlinRollingTorsionInteraction::getElasticEnergy(), BaseParticle::getKineticEnergy(), getUnitVector(), and Quarternion::integrate().
Mdouble Vec3D::getLengthSquared | ( | ) | const |
Calculates the squared length of this Vec3D: .
Calculates the square of the length of itself
Definition at line 300 of file Vector.cc.
Referenced by AxisymmetricIntersectionOfWalls::convertLimits(), TriangulatedWall::Face::getDistanceAndNormal(), 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 428 of file Vector.cc.
References getLengthSquared(), and Vec3D().
Referenced by IntersectionOfWalls::createOpenPrism(), IntersectionOfWalls::createPrism(), MindlinInteraction::getTangentialOverlap(), TriangulatedWall::readVTK(), and MindlinInteraction::updateK_t().
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 377 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 180 of file Vector.cc.
References Vec3D(), X, Y, and Z.
Referenced by FileReader::read().
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 193 of file Vector.cc.
References Vec3D(), X, Y, and Z.
Referenced by FileReader::read().
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 214 of file Vector.cc.
References getLength(), logger, and WARN.
Referenced by IntersectionOfWalls::addObject(), Screw::getDistanceAndNormal(), Quarternion::Quarternion(), and setLength().
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 332 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 230 of file Vector.cc.
References normalize().
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(), MindlinInteraction::MindlinInteraction(), MindlinRollingTorsionInteraction::MindlinRollingTorsionInteraction(), 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 243 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 205 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 483 of file Vector.cc.
Adds a scalar to a vector.
Subtracts the elements of a vector from a scalar
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 470 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 444 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 457 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(), AxisymmetricIntersectionOfWalls::convertLimits(), Chute::createBottom(), CircularPeriodicBoundary::createPeriodicParticles(), InfiniteWall::createVTK(), Matrix3D::cross(), cross(), dot(), Matrix3D::dyadic(), ChuteInsertionBoundary::generateParticle(), CubeInsertionBoundary::generateParticle(), getComponent(), getCylindricalCoordinates(), BaseParticle::getDisplacement2(), Screw::getDistanceAndNormal(), CylindricalWall::getDistanceAndNormal(), Coil::getDistanceAndNormal(), AxisymmetricIntersectionOfWalls::getDistanceAndNormal(), InfiniteWallWithHole::getDistanceAndNormal(), getDistanceSquared(), getFromCylindricalCoordinates(), InfiniteWallWithHole::getHoleDistance(), ShearBoxBoundary::getHorizontalDistance(), LeesEdwardsBoundary::getHorizontalDistance(), getLengthSquared(), Screw::getTriangulation(), Mercury2D::hGridFindOneSidedContacts(), Mercury3D::hGridFindOneSidedContacts(), Mercury2D::hGridHasParticleContacts(), Mercury3D::hGridUpdateParticle(), Mercury2D::hGridUpdateParticle(), Quarternion::integrate(), mathsFunc::isEqual(), isZero(), max(), min(), Matrix3D::operator*(), operator*(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/=(), operator<<(), operator>>(), Quarternion::Quarternion(), DPMBase::readNextDataFile(), ParticleHandler::readOldObject(), TriangulatedWall::readVTK(), CircularPeriodicBoundary::rotateParticle(), MatrixSymmetric3D::selfDyadic(), AngledPeriodicBoundary::set(), setComponent(), DPMBase::setMax(), DPMBase::setMin(), ChuteBottom::setupInitialConditions(), setZero(), sqrt(), square(), MatrixSymmetric3D::symmetrisedDyadic(), Vec3D(), and AxisymmetricIntersectionOfWalls::writeVTK().
Mdouble Vec3D::Y |
Definition at line 52 of file Vector.h.
Referenced by CircularPeriodicBoundary::checkBoundaryAfterParticleMoved(), AxisymmetricIntersectionOfWalls::convertLimits(), Chute::createBottom(), CircularPeriodicBoundary::createPeriodicParticles(), InfiniteWall::createVTK(), 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(), Screw::getTriangulation(), LeesEdwardsBoundary::getVerticalDistance(), ShearBoxBoundary::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>>(), Quarternion::Quarternion(), DPMBase::readNextDataFile(), ParticleHandler::readOldObject(), TriangulatedWall::readVTK(), CircularPeriodicBoundary::rotateParticle(), MatrixSymmetric3D::selfDyadic(), AngledPeriodicBoundary::set(), setComponent(), DPMBase::setMax(), DPMBase::setMin(), ChuteBottom::setupInitialConditions(), setZero(), sqrt(), square(), MatrixSymmetric3D::symmetrisedDyadic(), Vec3D(), and AxisymmetricIntersectionOfWalls::writeVTK().
Mdouble Vec3D::Z |
Definition at line 52 of file Vector.h.
Referenced by ChuteWithHopper::addHopper(), AxisymmetricIntersectionOfWalls::convertLimits(), InfiniteWall::createVTK(), Matrix3D::cross(), cross(), dot(), Matrix3D::dyadic(), ChuteInsertionBoundary::generateParticle(), CubeInsertionBoundary::generateParticle(), getComponent(), getCylindricalCoordinates(), BaseParticle::getDisplacement2(), Screw::getDistanceAndNormal(), CylindricalWall::getDistanceAndNormal(), Coil::getDistanceAndNormal(), AxisymmetricIntersectionOfWalls::getDistanceAndNormal(), InfiniteWallWithHole::getDistanceAndNormal(), getDistanceSquared(), getFromCylindricalCoordinates(), getLengthSquared(), Screw::getTriangulation(), 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>>(), Quarternion::Quarternion(), DPMBase::readNextDataFile(), ParticleHandler::readOldObject(), TriangulatedWall::readVTK(), CircularPeriodicBoundary::rotateParticle(), MatrixSymmetric3D::selfDyadic(), AngledPeriodicBoundary::set(), setComponent(), DPMBase::setMax(), DPMBase::setMin(), ChuteBottom::setupInitialConditions(), setZero(), ShearBoxBoundary::shiftHorizontalPosition(), sqrt(), square(), MatrixSymmetric3D::symmetrisedDyadic(), Vec3D(), and AxisymmetricIntersectionOfWalls::writeVTK().