39 {
x = X;
y = Y;
z = Z; }
42 {
for (
size_t i = 0; i < 3; i++)
v[i] = i < n ? pos[i] :
Real(0); }
44 Vec3(
const std::vector<Real>& X) :
x(
v[0]),
y(
v[1]),
z(
v[2])
45 {
for (
size_t i = 0; i < 3; i++)
v[i] = i < X.size() ? X[i] :
Real(0); }
48 {
x = X.
x;
y = X.
y;
z = X.
z; }
74 std::vector<Real>
vec(
size_t n = 3)
const
75 {
return std::vector<Real>(
v,
v + (n < 3 ? n : 3)); }
106 Real asum()
const {
return std::fabs(
x) + std::fabs(
y) + std::fabs(
z); }
117 double len = this->
length();
118 if (len <= tol)
return len;
119 x /= len;
y /= len;
z /= len;
126 x = a.
y*b.
z - a.
z*b.
y;
127 y = a.
z*b.
x - a.
x*b.
z;
128 z = a.
x*b.
y - a.
y*b.
x;
135 if (fabs(
x-a.
x) <= tol)
136 if (fabs(
y-a.
y) <= tol)
137 if (fabs(
z-a.
z) <= tol)
160 for (
int i = 2; i >= 0; i--)
161 if (
v[i]+tol < a.
v[i])
163 else if (
v[i]-tol > a.
v[i])
172 for (
int i = 0; i < 3; i++)
173 if (
v[i]+tol < a.
v[i] ||
v[i]-tol > b.
v[i])
180 virtual std::ostream&
print(std::ostream& os,
double tol = 1.0e-12)
const
260 t = X.size() > 3 ? X[3] :
Real(0);
291 const Vec4* x4 =
dynamic_cast<const Vec4*
>(&X);
305 std::ostream&
print(std::ostream& os,
double tol = 1.0e-12)
const override
307 if (
idx >= 0) os <<
"(idx="<<
idx <<
") ";
309 if (
u) os <<
" ("<<
u[0] <<
" "<<
u[1] <<
" "<<
u[2] <<
")";
310 if (
t >
Real(0)) os <<
" "<<
t;
#define Real
The floating point type to use.
Definition: ImmersedBoundaries.h:18
std::vector< Vec3 > Vec3Vec
An array of point vectors.
Definition: Vec3.h:318
std::pair< Vec3, Real > PointValue
A point with associated value.
Definition: Vec3.h:317
std::pair< Vec3, Vec3 > Vec3Pair
A pair of two point vectors.
Definition: Vec3.h:316
std::vector< PointValue > PointValues
An array of point values.
Definition: Vec3.h:319
Simple class for representing a point in 3D space.
Definition: Vec3.h:27
Vec3 & operator+=(const Vec3 &X)
Add the given vector X to *this.
Definition: Vec3.h:83
virtual std::ostream & print(std::ostream &os, double tol=1.0e-12) const
Print out a vector.
Definition: Vec3.h:180
bool lessThan(const Vec3 &a, double tol=1.0e-6) const
Check if one vector is less than the other.
Definition: Vec3.h:158
Vec3(const Vec3 &X, const Vec3 &Y)
Constructor creating a cross product of two other vectors.
Definition: Vec3.h:50
Real & operator()(int i)
Indexing operator for component assignment (1-based).
Definition: Vec3.h:66
const Real & operator[](int i) const
Indexing operator for component reference (0-based).
Definition: Vec3.h:64
Real asum() const
Return the sum of absolute values of the vector components.
Definition: Vec3.h:106
Real length2() const
Return the square of the length of the vector.
Definition: Vec3.h:109
bool equal(const Vec3 &a, double tol=1.0e-6) const
Equality check between two vectors.
Definition: Vec3.h:133
Vec3 & operator/=(Real d)
Division by a scalar.
Definition: Vec3.h:80
Real & x
Reference to X-component.
Definition: Vec3.h:31
const Real & operator()(int i) const
Indexing operator for component reference (1-based).
Definition: Vec3.h:62
Vec3 & cross(const Vec3 &a, const Vec3 &b)
Cross product between two vectors.
Definition: Vec3.h:124
virtual ~Vec3()
Empty destructor.
Definition: Vec3.h:54
Vec3 & operator=(Real val)
Overloaded assignment operator.
Definition: Vec3.h:59
Real v[3]
The actual point vector.
Definition: Vec3.h:28
Vec3()
Default constructor creating a point at origin.
Definition: Vec3.h:36
static double comparisonTolerance
Coordinate comparison tolerance.
Definition: Vec3.h:200
Real sum() const
Return the sum of the vector components.
Definition: Vec3.h:104
Vec3 operator-() const
Negation operator.
Definition: Vec3.h:101
Vec3 & operator=(const Vec3 &X)
Assignment operator.
Definition: Vec3.h:57
std::vector< Real > vec(size_t n=3) const
Conversion to std::vector.
Definition: Vec3.h:74
bool isZero(double tol=1.0e-6) const
Check if the vector is zero with the given tolerance.
Definition: Vec3.h:144
const Real * ptr() const
Reference through a pointer.
Definition: Vec3.h:71
Vec3 & operator*=(Real c)
Multiplication with a scalar.
Definition: Vec3.h:78
double length() const
Return the length of the vector.
Definition: Vec3.h:112
Real & z
Reference to Z-component.
Definition: Vec3.h:33
Vec3(const std::vector< Real > &X)
Constructor creating a point from the given std::vector.
Definition: Vec3.h:44
Real normalize(double tol=1.0e-16)
Normalize the vector and return its length.
Definition: Vec3.h:115
Real & y
Reference to Y-component.
Definition: Vec3.h:32
Real & operator[](int i)
Indexing operator for component assignment (0-based).
Definition: Vec3.h:68
Vec3(const Real *pos, size_t n=3)
Constructor creating a point at the specified location.
Definition: Vec3.h:41
Vec3 & operator-=(const Vec3 &X)
Subtract the given vector X from *this.
Definition: Vec3.h:92
Vec3(const Vec3 &X)
Copy constructor.
Definition: Vec3.h:47
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.
Definition: Vec3.h:170
Vec3(Real X, Real Y, Real Z=Real(0))
Constructor creating a point at the specified location.
Definition: Vec3.h:38
Simple class for representing a point in 3D space and time.
Definition: Vec3.h:209
Vec4(Real T)
Constructor creating a point at origin and time T.
Definition: Vec3.h:225
Vec4(const Vec3 &X, Real T=Real(0), int id=-1)
Constructor creating a point at the specified location.
Definition: Vec3.h:241
Vec4(Real X, Real Y, Real Z, Real T=Real(0))
Constructor creating a point at the specified location.
Definition: Vec3.h:233
Vec4(const Vec4 &X)
Copy constructor.
Definition: Vec3.h:265
Real t
The time coordinate.
Definition: Vec3.h:213
Vec4(const std::vector< Real > &X, const Real *par=nullptr)
Constructor creating a point from the given std::vector.
Definition: Vec3.h:257
Vec4 & operator=(const Vec4 &X)
Assignment operator.
Definition: Vec3.h:273
Vec4 & operator=(Real val)
Overloaded assignment operator.
Definition: Vec3.h:286
std::ostream & print(std::ostream &os, double tol=1.0e-12) const override
Print out a vector.
Definition: Vec3.h:305
Vec4(const Real *par=nullptr, Real T=Real(0))
Default constructor creating a point at origin.
Definition: Vec3.h:217
Vec4 & assign(const Vec3 &X)
Assignment method.
Definition: Vec3.h:289
int idx
Nodal point index.
Definition: Vec3.h:214
const Real * u
Spline parameters of point.
Definition: Vec3.h:211
Vec4(const Vec3 &X, Real T, const Real *par)
Constructor creating a point at the specified location.
Definition: Vec3.h:249