30 #include <dolfin/log/log.h> 31 #include <dolfin/common/Array.h> 52 explicit Point(
const double x=0.0,
const double y=0.0,
const double z=0.0)
61 Point(std::size_t dim,
const double*
x) : _x({{0.0, 0.0, 0.0}})
63 for (std::size_t i = 0; i < dim; i++)
73 for (std::size_t i = 0; i <
x.size(); i++)
81 Point(
const Point& p) : _x({{p._x[0], p._x[1], p._x[2]}}) {}
95 { dolfin_assert(i < 3);
return _x[i]; }
105 { dolfin_assert(i < 3);
return _x[i]; }
133 {
return _x.data(); }
140 {
return _x.data(); }
156 {
Point q(_x[0] + p._x[0], _x[1] + p._x[1], _x[2] + p._x[2]);
return q; }
162 {
Point q(_x[0] - p._x[0], _x[1] - p._x[1], _x[2] - p._x[2]);
return q; }
166 { _x[0] += p._x[0]; _x[1] += p._x[1]; _x[2] += p._x[2];
return *
this; }
170 { _x[0] -= p._x[0]; _x[1] -= p._x[1]; _x[2] -= p._x[2];
return *
this; }
174 {
Point p(-_x[0], -_x[1], -_x[2]);
return p; }
178 {
Point p(a*_x[0], a*_x[1], a*_x[2]);
return p; }
182 { _x[0] *= a; _x[1] *= a; _x[2] *= a;
return *
this; }
186 {
Point p(_x[0]/a, _x[1]/a, _x[2]/a);
return p; }
190 { _x[0] /= a; _x[1] /= a; _x[2] /= a;
return *
this; }
194 { _x = {{p._x[0], p._x[1], p._x[2]}};
return *
this; }
198 {
return _x == p._x; }
202 {
return _x != p._x; }
245 {
return std::sqrt(_x[0]*_x[0] + _x[1]*_x[1] + _x[2]*_x[2]); }
260 {
return _x[0]*_x[0] + _x[1]*_x[1] + _x[2]*_x[2]; }
308 std::string
str(
bool verbose=
false)
const;
312 std::array<double, 3> _x;
322 { stream << point.
str(
false);
return stream; }
Point(const Point &p)
Definition: Point.h:81
double y() const
Definition: Point.h:118
double norm() const
Definition: Point.h:244
std::string str(bool verbose=false) const
Definition: Point.cpp:70
double distance(const Point &p) const
Definition: Point.h:229
const Point cross(const Point &p) const
Definition: Point.cpp:33
double z() const
Definition: Point.h:125
const Point & operator=(const Point &p)
Assignment operator.
Definition: Point.h:193
~Point()
Destructor.
Definition: Point.h:84
Point(const Array< double > &x)
Definition: Point.h:71
Point operator*(double a) const
Multiplication with scalar.
Definition: Point.h:177
const Point & operator-=(const Point &p)
Subtract given point.
Definition: Point.h:169
Point operator-()
Unary minus.
Definition: Point.h:173
double x() const
Definition: Point.h:111
Point operator/(double a) const
Division by scalar.
Definition: Point.h:185
bool operator==(const Point &p) const
Equal to operator.
Definition: Point.h:197
std::array< double, 3 > array() const
Definition: Point.h:147
Point rotate(const Point &a, double theta) const
Definition: Point.cpp:58
Point(std::size_t dim, const double *x)
Definition: Point.h:61
double * coordinates()
Definition: Point.h:132
bool operator!=(const Point &p) const
Not equal to operator.
Definition: Point.h:201
const double * coordinates() const
Definition: Point.h:139
double squared_distance(const Point &p) const
Definition: Point.cpp:44
double squared_norm() const
Definition: Point.h:259
Point operator+(const Point &p) const
Definition: Point.h:155
double & operator[](std::size_t i)
Definition: Point.h:94
std::ostream & operator<<(std::ostream &stream, const Point &point)
Output of Point to stream.
Definition: Point.h:321
double dot(const Point &p) const
Definition: Point.cpp:53
const Point & operator/=(double a)
Incremental division by scalar.
Definition: Point.h:189
const Point & operator+=(const Point &p)
Add given point.
Definition: Point.h:165
const Point & operator*=(double a)
Incremental multiplication with scalar.
Definition: Point.h:181
Point(const double x=0.0, const double y=0.0, const double z=0.0)
Definition: Point.h:52