IFEM  90A354
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | List of all members
Vec3 Class Reference

Simple class for representing a point in 3D space. More...

#include <Vec3.h>

Inheritance diagram for Vec3:
Inheritance graph
[legend]

Public Member Functions

 Vec3 ()
 Default constructor creating a point at origin.
 
 Vec3 (Real X, Real Y, Real Z=Real(0))
 Constructor creating a point at the specified location.
 
 Vec3 (const Real *pos, size_t n=3)
 Constructor creating a point at the specified location.
 
 Vec3 (const std::vector< Real > &X)
 Constructor creating a point from the given std::vector.
 
 Vec3 (const Vec3 &X)
 Copy constructor.
 
 Vec3 (const Vec3 &X, const Vec3 &Y)
 Constructor creating a cross product of two other vectors.
 
virtual ~Vec3 ()
 Empty destructor.
 
Vec3operator= (const Vec3 &X)
 Assignment operator.
 
Vec3operator= (Real val)
 Overloaded assignment operator.
 
const Realoperator() (int i) const
 Indexing operator for component reference (1-based).
 
const Realoperator[] (int i) const
 Indexing operator for component reference (0-based).
 
Realoperator() (int i)
 Indexing operator for component assignment (1-based).
 
Realoperator[] (int i)
 Indexing operator for component assignment (0-based).
 
const Realptr () const
 Reference through a pointer.
 
std::vector< Realvec (size_t n=3) const
 Conversion to std::vector.
 
Vec3operator*= (Real c)
 Multiplication with a scalar.
 
Vec3operator/= (Real d)
 Division by a scalar.
 
Vec3operator+= (const Vec3 &X)
 Add the given vector X to *this.
 
Vec3operator-= (const Vec3 &X)
 Subtract the given vector X from *this.
 
Vec3 operator- () const
 Negation operator.
 
Real sum () const
 Return the sum of the vector components.
 
Real asum () const
 Return the sum of absolute values of the vector components.
 
Real length2 () const
 Return the square of the length of the vector.
 
double length () const
 Return the length of the vector.
 
Real normalize (double tol=1.0e-16)
 Normalize the vector and return its length.
 
Vec3cross (const Vec3 &a, const Vec3 &b)
 Cross product between two vectors.
 
bool equal (const Vec3 &a, double tol=1.0e-6) const
 Equality check between two vectors.
 
bool isZero (double tol=1.0e-6) const
 Check if the vector is zero with the given tolerance.
 
bool lessThan (const Vec3 &a, double tol=1.0e-6) const
 Check if one vector is less than the other. More...
 
bool inside (const Vec3 &a, const Vec3 &b, double tol=1.0e-6) const
 Check if a vector is inside the box defined by two other vectors.
 
virtual std::ostream & print (std::ostream &os, double tol=1.0e-12) const
 Print out a vector.
 

Public Attributes

Realx
 Reference to X-component.
 
Realy
 Reference to Y-component.
 
Realz
 Reference to Z-component.
 

Static Public Attributes

static double comparisonTolerance = 1.0e-4
 Coordinate comparison tolerance.
 

Private Attributes

Real v [3]
 The actual point vector.
 

Detailed Description

Simple class for representing a point in 3D space.

Member Function Documentation

◆ lessThan()

bool Vec3::lessThan ( const Vec3 a,
double  tol = 1.0e-6 
) const
inline

Check if one vector is less than the other.

First we compare the z-coordinates. Only if the z-coordinates are equal, we compare the y-coordinates, and if they are equal too, we finally compare the x-coordinates.

References v.

Referenced by operator<().


The documentation for this class was generated from the following files: