12 #include "matrixBlaze.h"
65 explicit Point3(
const std::vector<double> &p) {
69 else if (p.size() == 1)
71 else if (p.size() == 2) {
74 }
else if (p.size() == 3) {
94 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
96 std::string tabS =
"";
97 for (
int i = 0; i < nt; i++)
100 std::ostringstream oss;
101 oss << tabS <<
"(" <<
d_x <<
", " <<
d_y <<
", " <<
d_z <<
")";
113 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
189 auto l_sq = (is_unit ? 1. : this->
length() * this->
length());
201 auto l_sq = (is_unit ? 1. : this->
length() * this->
length());
214 auto ahat = this->
unit();
215 auto bhat = b.
unit();
216 return std::acos(ahat.dot(bhat));
227 tmp(0, 0) = this->d_x * this->
d_x;
228 tmp(0, 1) = this->d_x * this->
d_y;
229 tmp(0, 2) = this->d_x * this->
d_z;
231 tmp(1, 0) = this->d_y * this->
d_x;
232 tmp(1, 1) = this->d_y * this->
d_y;
233 tmp(1, 2) = this->d_y * this->
d_z;
235 tmp(2, 0) = this->d_z * this->
d_x;
236 tmp(2, 1) = this->d_z * this->
d_y;
237 tmp(2, 2) = this->d_z * this->
d_z;
251 tmp(0, 0) = this->d_x * b.
d_x;
252 tmp(0, 1) = this->d_x * b.
d_y;
253 tmp(0, 2) = this->d_x * b.
d_z;
255 tmp(1, 0) = this->d_y * b.
d_x;
256 tmp(1, 1) = this->d_y * b.
d_y;
257 tmp(1, 2) = this->d_y * b.
d_z;
259 tmp(2, 0) = this->d_z * b.
d_x;
260 tmp(2, 1) = this->d_z * b.
d_y;
261 tmp(2, 2) = this->d_z * b.
d_z;
331 return {lhs.
d_x + rhs, lhs.
d_y + rhs, lhs.
d_z + rhs};
341 return {lhs + rhs.
d_x, lhs + rhs.
d_y, lhs + rhs.
d_z};
351 return {lhs.
d_x - rhs, lhs.
d_y - rhs, lhs.
d_z - rhs};
361 return {lhs - rhs.
d_x, lhs - rhs.
d_y, lhs - rhs.
d_z};
519 os << p.
d_x <<
" " << p.
d_y <<
" " << p.
d_z << std::endl;
Collection of methods useful in simulation.
Definition: DataManager.h:50
std::ostream & operator<<(std::ostream &os, const Point3 p)
Definition: point.h:518
blaze::StaticMatrix< double, 3UL, 3UL > Matrix33
Blaze: Definition of 3 x 3 matrix.
Definition: matrixBlaze.h:23
blaze::StaticVector< double, 3UL > Vector3
Blaze: Definition of 3D vector.
Definition: matrixBlaze.h:28
A structure to represent 3d vectors.
Definition: point.h:29
double length() const
Computes the Euclidean length of the vector.
Definition: point.h:119
double angle(Point3 b) const
Computes the angle between vector given by this and the vector b.
Definition: point.h:212
friend Point3 operator*(const double lhs, Point3 rhs)
Subtracts a scalar to the point.
Definition: point.h:370
friend Point3 operator+(Point3 lhs, const double rhs)
Adds a scalar to the point.
Definition: point.h:330
Point3 & operator/=(const double b)
Divides a point by a scalar.
Definition: point.h:469
Point3 unit() const
Returns the unit vector.
Definition: point.h:144
friend Point3 operator/(Point3 lhs, const double rhs)
Divides a scalar to the point.
Definition: point.h:381
void print(int nt=0, int lvl=0) const
Prints the information.
Definition: point.h:113
Point3 & operator-=(const Point3 &b)
Subtracts a point.
Definition: point.h:443
Point3 & operator-=(const double b)
Subtracts a scalar to the point.
Definition: point.h:404
util::Matrix33 toMatrix()
Computes the dot product of the vector and its transpose.
Definition: point.h:223
Point3()
Constructor.
Definition: point.h:43
friend Point3 operator+(const double lhs, Point3 rhs)
Adds two points.
Definition: point.h:340
Point3 projectNormal(const Point3 &b, bool is_unit=false) const
Computes projection of vector on plane with normal as this vector.
Definition: point.h:200
Point3(T x, T y, T z)
Constructor.
Definition: point.h:52
Point3 & operator+=(const double b)
Add a scalar to the point.
Definition: point.h:391
Point3 & operator*=(const double b)
Multiplies a scalar to the point.
Definition: point.h:417
friend double operator*(Point3 lhs, const Point3 rhs)
Multiplies a constant to the point.
Definition: point.h:309
Point3 unit()
Returns the unit vector.
Definition: point.h:132
util::Matrix33 toMatrix(const util::Point3 b)
Computes the dot product of the vector x and the transpose of y.
Definition: point.h:247
util::Vector3 toVector()
Converts the point to an blaze vector.
Definition: point.h:270
double lengthSq() const
Computes the Euclidean length of the vector.
Definition: point.h:125
const double & operator[](size_t i) const
Access the 0th component of a point.
Definition: point.h:497
Point3 & operator*=(const Point3 &b)
Multiplies a point.
Definition: point.h:456
friend Point3 operator-(const double lhs, Point3 rhs)
Subtracts a scalar to the point.
Definition: point.h:360
friend std::ostream & operator<<(std::ostream &os, const Point3 p)
Print the point's value to the standard output stream.
Definition: point.h:518
friend Point3 operator-(Point3 lhs, const double rhs)
Subtracts a scalar to the point.
Definition: point.h:350
double d_x
the x coordinate
Definition: point.h:32
double d_y
the y coordinate
Definition: point.h:35
Point3 project(const Point3 &b, bool is_unit=false) const
Computes projection of vector on this vector.
Definition: point.h:188
std::string printStr(int nt=0, int lvl=0) const
Prints the information.
Definition: point.h:94
double dist(const Point3 &b) const
Computes the distance between a given point from this point.
Definition: point.h:165
friend Point3 operator-(Point3 lhs, const Point3 &rhs)
Substracts two points.
Definition: point.h:298
Point3(const std::vector< double > &p)
Constructor.
Definition: point.h:65
friend Point3 operator*(Point3 lhs, const double rhs)
Adds two points.
Definition: point.h:319
double d_z
the z coordinate
Definition: point.h:38
Point3(const Point3 &p)
Copy constructor.
Definition: point.h:85
friend Point3 operator+(Point3 lhs, const Point3 &rhs)
Adds two points.
Definition: point.h:287
Point3(T x[3])
Constructor.
Definition: point.h:59
double & operator[](size_t i)
Access the 0th component of a point.
Definition: point.h:482
Point3 & operator+=(const Point3 &b)
Adds a point.
Definition: point.h:430
double dot(const Point3 &b) const
Computes the dot product of this vector with another point.
Definition: point.h:157
Point3 cross(const Point3 &b) const
Computes the cross product between this vector and given vector.
Definition: point.h:176