Flow123d  release_2.2.0-914-gf1a3a4f
plucker.cc
Go to the documentation of this file.
1 #include "plucker.hh"
2 
3 using namespace std;
4 
5 
6 
7 double Plucker::operator*(const Plucker &b){
8  return (coordinates_[0]*b[3]) + (coordinates_[1]*b[4]) + (coordinates_[2]*b[5]) + (coordinates_[3]*b[0]) + (coordinates_[4]*b[1]) +(coordinates_[5]*b[2]);
9 };
10 
11 void Plucker::compute(const arma::vec3 &a,const arma::vec3 &b){
12 
13  coordinates_[0] = b[0] - a[0];
14  coordinates_[1] = b[1] - a[1];
15  coordinates_[2] = b[2] - a[2];
16  coordinates_[3] = coordinates_[1]*a[2] - coordinates_[2]*a[1];
17  coordinates_[4] = coordinates_[2]*a[0] - coordinates_[0]*a[2];
18  coordinates_[5] = coordinates_[0]*a[1] - coordinates_[1]*a[0];
19  computed_ = true;
20 
21  scale_=0;
22  scale_ = std::max( scale_, std::fabs(coordinates_[0]));
23  scale_ = std::max( scale_, std::fabs(coordinates_[1]));
24  scale_ = std::max( scale_, std::fabs(coordinates_[2]));
25 };
26 
27 ostream& operator<<(ostream& os, const Plucker& p)
28 {
29  if(p.computed_){
30  os <<"(" << p.coordinates_[0] << "," << p.coordinates_[1] << "," << p.coordinates_[2] << ","
31  << p.coordinates_[3] << "," << p.coordinates_[4] << "," << p.coordinates_[5] << ")";
32  }else{
33  os << "NULL (Plucker coords have not been computed)";
34  }
35  return os;
36 }
37 
38 
arma::vec6 coordinates_
Plucker coordinates.
Definition: plucker.hh:50
Plucker coordinates class.
double operator*(const Plucker &b)
Compute product of two Plucker coordinates.
Definition: plucker.cc:7
ostream & operator<<(ostream &os, const Plucker &p)
Operator for printing Plucker coordinates.
Definition: plucker.cc:27
bool computed_
True, if Plucker coordinates are computed; false otherwise.
Definition: plucker.hh:52
void compute(const arma::vec3 &a, const arma::vec3 &b)
Compute Plucker coordinates and set computed to true.
Definition: plucker.cc:11
Plucker coordinates representing line given by points A,B.
Definition: plucker.hh:47