Flow123d  DF_profiler_memory_monitor-83fd579
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(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 
#define ASSERT(expr)
Definition: asserts.hh:351
ArrayMatSet set(uint index)
Definition: armor.hh:886
Plucker coordinates representing line given by points A,B.
Definition: plucker.hh:45
Armor::Array< double > points_
Definition: plucker.hh:51
arma::vec6 coordinates_
Plucker coordinates.
Definition: plucker.hh:48
Space< 3 >::Point Point
Definition: plucker.hh:54
double scale_
Definition: plucker.hh:49
void compute()
Compute Plucker coordinates and set computed to true.
Definition: plucker.cc:43
double operator*(const Plucker &b)
Compute product of two Plucker coordinates.
Definition: plucker.cc:38
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
Plucker()
Definition: plucker.cc:5
ostream & operator<<(ostream &os, const Plucker &p)
Operator for printing Plucker coordinates.
Definition: plucker.cc:52
Plucker coordinates class.