Flow123d  release_2.2.0-914-gf1a3a4f
plucker.hh
Go to the documentation of this file.
1 /*!
2  *
3 * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file plucker.hh
15  * @brief Plucker coordinates class.
16  * @author Viktor Fris, Pavel Exner
17  *
18  */
19 
20 #include <armadillo>
21 #include <iostream>
22 #include "system/system.hh"
23 
24 
25 
26 #ifndef _PLUCKER_H
27 #define _PLUCKER_H
28 
29 /** @brief Plucker coordinates representing line given by points A,B.
30  *
31  * Plucker class represents a line by 6 dimensional vector.
32  * After inserting a three-dimensional points A and B, which represents the line,
33  * class creates plucker coordinates of the line.
34  *
35  * Class also can compute a product of two plucker coordinates.
36  *
37  * Description of Plücker Coordinates:
38  * https://en.wikipedia.org/wiki/Pl%C3%BCcker_coordinates
39  *
40  * Empty constructor is used for passing object to pointers from different places
41  * coordinates data are filled after calling method "compute"
42  * a flag "computed" is for comparison if coordinates data are filled
43  *
44  * question: is compute() used from outside ?
45  * answer: Yes
46  */
47 class Plucker{
48 private:
49 
50  arma::vec6 coordinates_; ///< Plucker coordinates.
51  double scale_;
52  bool computed_; ///< True, if Plucker coordinates are computed; false otherwise.
53 
54 public:
55  /** Default constructor.
56  * Plucker coordinates are not computed.
57  */
58  Plucker();
59  /** @brief Creates Plucker coordinates of a line AB.
60  * @param a - A point from AB line
61  * @param b - B point from AB line
62  */
63  Plucker(const arma::vec3 &a, const arma::vec3 &b);
64  /// Copy constructor.
65  Plucker(const Plucker &p);
66  /// Destructor.
67  ~Plucker(){};
68 
69  double scale() const
70  { return scale_; }
71 
72  /// Returns Plucker coordinate of @p index.
73  double operator[](const unsigned int index) const;
74 
75  /// Compute product of two Plucker coordinates.
76  double operator*(const Plucker &b);
77 
78  /// Sets the flag computed on false.
79  void clear();
80 
81  /// Return true if Plucker coordinates have been computed already.
82  bool is_computed() const;
83 
84  /** @brief Compute Plucker coordinates and set computed to true.
85  * @param a A point from AB line
86  * @param b B point from AB line (order of points determines orientation!)
87  */
88  void compute(const arma::vec3 &a, const arma::vec3 &b);
89 
90  /// Gets directional vector U.
91  arma::vec3 get_u_vector() const;
92 
93  /// Gets cross product vector UxA.
94  arma::vec3 get_ua_vector() const;
95 
96  /// Gets Plucker coordinates.
97  arma::vec6 get_plucker_coords() const;
98 
99  /// Friend output operator.
100  friend std::ostream& operator<< (std::ostream& os, const Plucker& p);
101 };
102 
103 /// Operator for printing Plucker coordinates.
104 std::ostream& operator<<(std::ostream& os, const Plucker& p);
105 
106 /****************** inline implementation *****************************/
108 { computed_ = false; }
109 
110 inline Plucker::Plucker(const arma::vec3 &a,const arma::vec3 &b)
111 { compute(a, b);
112  computed_ = true; }
113 
114 inline Plucker::Plucker(const Plucker &p)
116  computed_ = p.is_computed(); }
117 
118 inline double Plucker::operator[](const unsigned int index) const
120  return coordinates_[index]; }
121 
122 inline void Plucker::clear()
123 { computed_ = false; }
124 
125 inline bool Plucker::is_computed() const
126 { return computed_; }
127 
130  return coordinates_(arma::span(0,2)); }
131 
134  return coordinates_(arma::span(3,5)); }
135 
136 inline arma::vec6 Plucker::get_plucker_coords() const
138  return coordinates_; }
139 
140 #endif
141 
142 
arma::vec6 coordinates_
Plucker coordinates.
Definition: plucker.hh:50
arma::vec3 get_ua_vector() const
Gets cross product vector UxA.
Definition: plucker.hh:132
Plucker()
Definition: plucker.hh:107
double scale_
Definition: plucker.hh:51
arma::vec3 get_u_vector() const
Gets directional vector U.
Definition: plucker.hh:128
~Plucker()
Destructor.
Definition: plucker.hh:67
double operator*(const Plucker &b)
Compute product of two Plucker coordinates.
Definition: plucker.cc:7
friend std::ostream & operator<<(std::ostream &os, const Plucker &p)
Friend output operator.
double operator[](const unsigned int index) const
Returns Plucker coordinate of index.
Definition: plucker.hh:118
bool computed_
True, if Plucker coordinates are computed; false otherwise.
Definition: plucker.hh:52
void clear()
Sets the flag computed on false.
Definition: plucker.hh:122
#define ASSERT_DBG(expr)
Definition: asserts.hh:349
arma::vec6 get_plucker_coords() const
Gets Plucker coordinates.
Definition: plucker.hh:136
void compute(const arma::vec3 &a, const arma::vec3 &b)
Compute Plucker coordinates and set computed to true.
Definition: plucker.cc:11
bool is_computed() const
Return true if Plucker coordinates have been computed already.
Definition: plucker.hh:125
Plucker coordinates representing line given by points A,B.
Definition: plucker.hh:47
double scale() const
Definition: plucker.hh:69