Flow123d  release_3.0.0-1133-g1943bc6
plucker.cc
Go to the documentation of this file.
1 #include "plucker.hh"
2 
3 using namespace std;
4 
6 : coordinates_({0,0,0,0,0,0}),
7  scale_(0),
8  computed_(false),
9  points_({nullptr,nullptr})
10 {}
11 
12 
13 Plucker::Plucker(const Node* a, const Node* b)
14 {
15  ASSERT_DBG(a);
16  ASSERT_DBG(b);
17  points_[0] = a;
18  points_[1] = b;
19  coordinates_(arma::span(0,2)) = point(1) - point(0);
20 
21  // Check empty
22  ASSERT_DBG(arma::norm(coordinates_(arma::span(0,2)),2) > 0);
23 
24  scale_ = 0;
25  scale_ = std::max( scale_, std::fabs(coordinates_[0]));
26  scale_ = std::max( scale_, std::fabs(coordinates_[1]));
27  scale_ = std::max( scale_, std::fabs(coordinates_[2]));
28 
29  computed_ = false;
30 }
31 
32 Plucker::Plucker(const Node* a, const Node* b, bool compute_pc)
33 : Plucker(a,b)
34 {
35  if(compute_pc) compute();
36 }
37 
38 
39 double Plucker::operator*(const Plucker &b){
40  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]);
41 };
42 
43 
45  if(computed_) return;
46 
47  ASSERT_DBG(points_[0]);
48  ASSERT_DBG(points_[1]);
49  coordinates_[3] = coordinates_[1]*point(0)[2] - coordinates_[2]*point(0)[1];
50  coordinates_[4] = coordinates_[2]*point(0)[0] - coordinates_[0]*point(0)[2];
51  coordinates_[5] = coordinates_[0]*point(0)[1] - coordinates_[1]*point(0)[0];
52  computed_ = true;
53 };
54 
55 ostream& operator<<(ostream& os, const Plucker& p)
56 {
57  if(p.computed_){
58  os <<"(" << p.coordinates_[0] << "," << p.coordinates_[1] << "," << p.coordinates_[2] << ","
59  << p.coordinates_[3] << "," << p.coordinates_[4] << "," << p.coordinates_[5] << ")";
60  }else{
61  os << "NULL (Plucker coords have not been computed)";
62  }
63  return os;
64 }
65 
66 
arma::vec6 coordinates_
Plucker coordinates.
Definition: plucker.hh:47
Definition: nodes.hh:31
Plucker coordinates class.
Plucker()
Definition: plucker.cc:5
double scale_
Definition: plucker.hh:48
void compute()
Compute Plucker coordinates and set computed to true.
Definition: plucker.cc:44
const Node * points_[2]
Definition: plucker.hh:50
double operator*(const Plucker &b)
Compute product of two Plucker coordinates.
Definition: plucker.cc:39
friend std::ostream & operator<<(std::ostream &os, const Plucker &p)
Friend output operator.
bool computed_
True, if Plucker coordinates are computed; false otherwise.
Definition: plucker.hh:49
arma::vec3 point(unsigned int idx) const
Gets coordinates of point.
Definition: plucker.hh:121
#define ASSERT_DBG(expr)
Definition: asserts.hh:349
Plucker coordinates representing line given by points A,B.
Definition: plucker.hh:44