IFEM 90A354
Point.h
Go to the documentation of this file.
1// $Id$
2//==============================================================================
12//==============================================================================
13
14#ifndef UTL_POINT_H
15#define UTL_POINT_H
16
17#include "Vec3.h"
18
19
20namespace utl
21{
28 class Point : public Vec4
29 {
30 Real par[3];
31
32 public:
34 Point() : Vec4(par) { par[0] = par[1] = par[2] = Real(0); }
35
37 explicit Point(const Vec3& X) : Vec4(X,Real(0),par)
38 {
39 par[0] = par[1] = par[2] = Real(0);
40 }
41
43 Point(const Vec3& X, const std::vector<Real>& U) : Vec4(X,Real(0),par)
44 {
45 for (size_t i = 0; i < 3; i++)
46 par[i] = i < U.size() ? U[i] : 0.0;
47 }
48
50 Point(const Point& X) : Vec4(X,X.t,par)
51 {
52 for (size_t i = 0; i < 3; i++)
53 par[i] = X.par[i];
54 }
55
57 explicit Point(const std::vector<Real>& X) : Vec4(X,par)
58 {
59 for (size_t i = 0; i < 3; i++)
60 par[i] = 3+i < X.size() ? X[3+i] : 0.0;
61 }
62
64 Point& operator=(const Vec4& X)
65 {
66 x = X.x;
67 y = X.y;
68 z = X.z;
69 t = X.t;
70 idx = X.idx;
71 if (X.u)
72 for (size_t i = 0; i < 3; i++)
73 par[i] = X.u[i];
74
75 return *this;
76 }
77
80 {
81 x += X.x;
82 y += X.y;
83 z += X.z;
84 t += X.t;
85 if (X.u)
86 for (size_t i = 0; i < 3; i++)
87 par[i] += X.u[i];
88
89 return *this;
90 }
91
94 {
95 x *= c;
96 y *= c;
97 z *= c;
98 t *= c;
99 for (size_t i = 0; i < 3; i++)
100 par[i] *= c;
101
102 return *this;
103 }
104
106 Point& operator/=(Real d) { return this->operator*=(Real(1)/d); }
107 };
108}
109
110
112inline utl::Point operator*(const utl::Point& a, Real value)
113{
114 return utl::Point({ value*a.x , value*a.y , value*a.z,
115 value*a.u[0], value*a.u[1], value*a.u[2] });
116}
117
118
120inline utl::Point operator*(Real value, const utl::Point& a)
121{
122 return utl::Point({ value*a.x , value*a.y , value*a.z,
123 value*a.u[0], value*a.u[1], value*a.u[2] });
124}
125
126
128inline utl::Point operator+(const utl::Point& a, const utl::Point& b)
129{
130 return utl::Point({ a.x +b.x , a.y +b.y , a.z +b.z,
131 a.u[0]+b.u[0], a.u[1]+b.u[1], a.u[2]+b.u[2] });
132}
133
134
135typedef std::vector<utl::Point> PointVec;
136
137#endif
#define Real
The floating point type to use.
Definition ImmersedBoundaries.h:18
std::vector< utl::Point > PointVec
An array of points.
Definition Point.h:135
utl::Point operator*(const utl::Point &a, Real value)
Multiplication of a point and a scalar.
Definition Point.h:112
utl::Point operator+(const utl::Point &a, const utl::Point &b)
Summation of two points.
Definition Point.h:128
Representation of a point in 3D space with some basic operations.
Simple class for representing a point in 3D space.
Definition Vec3.h:27
Real & x
Reference to X-component.
Definition Vec3.h:31
Real & z
Reference to Z-component.
Definition Vec3.h:33
Real & y
Reference to Y-component.
Definition Vec3.h:32
Simple class for representing a point in 3D space and time.
Definition Vec3.h:209
Real t
The time coordinate.
Definition Vec3.h:213
int idx
Nodal point index.
Definition Vec3.h:214
const Real * u
Spline parameters of point.
Definition Vec3.h:211
Class for representing points in 3D space.
Definition Point.h:29
Point(const std::vector< Real > &X)
Constructor creating a point from the given std::vector.
Definition Point.h:57
Real par[3]
Internal storage of spline parameters.
Definition Point.h:30
Point()
Default constructor.
Definition Point.h:34
Point & operator*=(Real c)
Multiplication with a scalar.
Definition Point.h:93
Point & operator=(const Vec4 &X)
Assignment operator.
Definition Point.h:64
Point(const Point &X)
Copy constructor.
Definition Point.h:50
Point & operator/=(Real d)
Division by a scalar.
Definition Point.h:106
Point(const Vec3 &X)
Constructor creating a point at the specified location.
Definition Point.h:37
Point(const Vec3 &X, const std::vector< Real > &U)
Constructor creating a point at the specified location.
Definition Point.h:43
Point & operator+=(const Vec4 &X)
Add the given vector X to *this.
Definition Point.h:79
General utility classes and functions.
Definition SIMoptions.h:22