Flow123d  JS_before_hm-1621-g63a12c7
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_(3, 1, 2)
10 {}
11 
12 
14 : Plucker()
15 {
16  points_.set(0) = a;
17  points_.set(1) = b;
18  coordinates_(arma::span(0,2)) = point(1) - point(0);
19 
20  // Check empty
21  ASSERT_DBG(arma::norm(coordinates_(arma::span(0,2)),2) > 0);
22 
23  scale_ = 0;
24  scale_ = std::max( scale_, std::fabs(coordinates_[0]));
25  scale_ = std::max( scale_, std::fabs(coordinates_[1]));
26  scale_ = std::max( scale_, std::fabs(coordinates_[2]));
27 
28  computed_ = false;
29 }
30 
31 Plucker::Plucker(Point a, Point b, bool compute_pc)
32 : Plucker(a,b)
33 {
34  if(compute_pc) compute();
35 }
36 
37 
38 double Plucker::operator*(const Plucker &b){
39  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]);
40 }
41 
42 
44  if(computed_) return;
45 
46  coordinates_[3] = coordinates_[1]*point(0)[2] - coordinates_[2]*point(0)[1];
47  coordinates_[4] = coordinates_[2]*point(0)[0] - coordinates_[0]*point(0)[2];
48  coordinates_[5] = coordinates_[0]*point(0)[1] - coordinates_[1]*point(0)[0];
49  computed_ = true;
50 }
51 
52 ostream& operator<<(ostream& os, const Plucker& p)
53 {
54  if(p.computed_){
55  os <<"(" << p.coordinates_[0] << "," << p.coordinates_[1] << "," << p.coordinates_[2] << ","
56  << p.coordinates_[3] << "," << p.coordinates_[4] << "," << p.coordinates_[5] << ")";
57  }else{
58  os << "NULL (Plucker coords have not been computed)";
59  }
60  return os;
61 }
62 
63 
arma::vec6 coordinates_
Plucker coordinates.
Definition: plucker.hh:48
Plucker coordinates class.
Plucker()
Definition: plucker.cc:5
Armor::Array< double > points_
Definition: plucker.hh:51
double scale_
Definition: plucker.hh:49
Space< 3 >::Point Point
Definition: plucker.hh:54
void compute()
Compute Plucker coordinates and set computed to true.
Definition: plucker.cc:43
ArrayMatSet set(uint index)
Definition: armor.hh:838
double operator*(const Plucker &b)
Compute product of two Plucker coordinates.
Definition: plucker.cc:38
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:50
arma::vec3 point(unsigned int idx) const
Gets coordinates of point.
Definition: plucker.hh:123
#define ASSERT_DBG(expr)
Plucker coordinates representing line given by points A,B.
Definition: plucker.hh:45