Flow123d  release_3.0.0-1025-gd4d7c13
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 #include "mesh/nodes.hh"
24 
25 #ifndef _PLUCKER_H
26 #define _PLUCKER_H
27 
28 /** @brief Plucker coordinates representing line given by points A,B.
29  *
30  * Plucker class represents a line by 6 dimensional vector.
31  * After inserting a three-dimensional points A and B, which represents the line,
32  * class creates plucker coordinates of the line.
33  *
34  * Class also can compute a product of two plucker coordinates.
35  *
36  * Description of Plücker Coordinates:
37  * https://en.wikipedia.org/wiki/Pl%C3%BCcker_coordinates
38  *
39  * Empty constructor is used for passing object to pointers from different places
40  * coordinates data are filled after calling method "compute"
41  * a flag "computed" is for comparison if coordinates data are filled
42  *
43  */
44 class Plucker{
45 private:
46 
47  arma::vec6 coordinates_; ///< Plucker coordinates.
48  double scale_;
49  bool computed_; ///< True, if Plucker coordinates are computed; false otherwise.
50  const Node* points_[2];
51 
52 public:
53  /** Default constructor.
54  * Creates empty object, cannot call compute later!
55  */
56  Plucker();
57  /** @brief Creates Plucker coordinates object for a line AB.
58  * Does NOT compute Plucker coordinates.
59  * Does set end points and computes direction vector.
60  * @param a - A point from AB line
61  * @param b - B point from AB line
62  */
63  Plucker(const Node* a, const Node* b);
64  /** @brief The same as above constructor,
65  * but can compute Pl. coordinates immediately if @p compute_pc.
66  */
67  Plucker(const Node* a, const Node* b, bool compute_pc);
68 
69  /// Destructor.
70  ~Plucker(){};
71 
72  double scale() const
73  { return scale_; }
74 
75  /// Returns Plucker coordinate of @p index.
76  double operator[](const unsigned int index) const;
77 
78  /// Compute product of two Plucker coordinates.
79  double operator*(const Plucker &b);
80 
81  /// Sets the flag computed on false.
82  void clear();
83 
84  /// Return true if Plucker coordinates have been computed already.
85  bool is_computed() const;
86 
87  /// Gets coordinates of point.
88  arma::vec3 point(unsigned int idx) const;
89 
90  /** @brief Compute Plucker coordinates and set computed to true.
91  */
92  void compute();
93 
94  /// Gets directional vector U.
95  arma::vec3 get_u_vector() const;
96 
97  /// Gets cross product vector UxA.
98  arma::vec3 get_ua_vector() const;
99 
100  /// Gets Plucker coordinates.
101  arma::vec6 get_plucker_coords() const;
102 
103  /// Friend output operator.
104  friend std::ostream& operator<< (std::ostream& os, const Plucker& p);
105 };
106 
107 /// Operator for printing Plucker coordinates.
108 std::ostream& operator<<(std::ostream& os, const Plucker& p);
109 
110 /****************** inline implementation *****************************/
111 inline double Plucker::operator[](const unsigned int index) const
113  return coordinates_[index]; }
114 
115 inline void Plucker::clear()
116 { computed_ = false; }
117 
118 inline bool Plucker::is_computed() const
119 { return computed_; }
120 
121 inline arma::vec3 Plucker::point(unsigned int idx) const
122 { return points_[idx]->point(); }
123 
125 { //ASSERT_DBG(computed_);
126  return coordinates_(arma::span(0,2)); }
127 
130  return coordinates_(arma::span(3,5)); }
131 
132 inline arma::vec6 Plucker::get_plucker_coords() const
134  return coordinates_; }
135 
136 #endif
137 
138 
arma::vec6 coordinates_
Plucker coordinates.
Definition: plucker.hh:47
Definition: nodes.hh:31
Nodes of a mesh.
arma::vec3 get_ua_vector() const
Gets cross product vector UxA.
Definition: plucker.hh:128
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
arma::vec3 get_u_vector() const
Gets directional vector U.
Definition: plucker.hh:124
const Node * points_[2]
Definition: plucker.hh:50
~Plucker()
Destructor.
Definition: plucker.hh:70
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.
double operator[](const unsigned int index) const
Returns Plucker coordinate of index.
Definition: plucker.hh:111
bool computed_
True, if Plucker coordinates are computed; false otherwise.
Definition: plucker.hh:49
void clear()
Sets the flag computed on false.
Definition: plucker.hh:115
arma::vec3 point(unsigned int idx) const
Gets coordinates of point.
Definition: plucker.hh:121
#define ASSERT_DBG(expr)
Definition: asserts.hh:349
arma::vec6 get_plucker_coords() const
Gets Plucker coordinates.
Definition: plucker.hh:132
arma::vec3 & point()
Definition: nodes.hh:67
bool is_computed() const
Return true if Plucker coordinates have been computed already.
Definition: plucker.hh:118
Plucker coordinates representing line given by points A,B.
Definition: plucker.hh:44
double scale() const
Definition: plucker.hh:72