Flow123d  master-f44eb46
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 "system/armor.hh"
24 #include "mesh/point.hh"
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  */
45 class Plucker{
46 private:
47 
48  arma::vec6 coordinates_; ///< Plucker coordinates.
49  double scale_;
50  bool computed_; ///< True, if Plucker coordinates are computed; false otherwise.
52 
53 public:
54  typedef typename Space<3>::Point Point;
55  /** Default constructor.
56  * Creates empty object, cannot call compute later!
57  */
58  Plucker();
59  /** @brief Creates Plucker coordinates object for a line AB.
60  * Does NOT compute Plucker coordinates.
61  * Does set end points and computes direction vector.
62  * @param a - A point from AB line
63  * @param b - B point from AB line
64  */
65  Plucker(Point a, Point b);
66  /** @brief The same as above constructor,
67  * but can compute Pl. coordinates immediately if @p compute_pc.
68  */
69  Plucker(Point a, const Point b, bool compute_pc);
70 
71  /// Destructor.
72  ~Plucker(){};
73 
74  double scale() const
75  { return scale_; }
76 
77  /// Returns Plucker coordinate of @p index.
78  double operator[](const unsigned int index) const;
79 
80  /// Compute product of two Plucker coordinates.
81  double operator*(const Plucker &b);
82 
83  /// Sets the flag computed on false.
84  void clear();
85 
86  /// Return true if Plucker coordinates have been computed already.
87  bool is_computed() const;
88 
89  /// Gets coordinates of point.
90  arma::vec3 point(unsigned int idx) const;
91 
92  /** @brief Compute Plucker coordinates and set computed to true.
93  */
94  void compute();
95 
96  /// Gets directional vector U.
97  arma::vec3 get_u_vector() const;
98 
99  /// Gets cross product vector UxA.
100  arma::vec3 get_ua_vector() const;
101 
102  /// Gets Plucker coordinates.
103  arma::vec6 get_plucker_coords() const;
104 
105  /// Friend output operator.
106  friend std::ostream& operator<< (std::ostream& os, const Plucker& p);
107 };
108 
109 /// Operator for printing Plucker coordinates.
110 std::ostream& operator<<(std::ostream& os, const Plucker& p);
111 
112 /****************** inline implementation *****************************/
113 inline double Plucker::operator[](const unsigned int index) const
114 { ASSERT(computed_);
115  return coordinates_[index]; }
116 
117 inline void Plucker::clear()
118 { computed_ = false; }
119 
120 inline bool Plucker::is_computed() const
121 { return computed_; }
122 
123 inline arma::vec3 Plucker::point(unsigned int idx) const
124 { return points_.vec<3>(idx); }
125 
127 { //ASSERT(computed_);
128  return coordinates_(arma::span(0,2)); }
129 
131 { ASSERT(computed_);
132  return coordinates_(arma::span(3,5)); }
133 
134 inline arma::vec6 Plucker::get_plucker_coords() const
135 { ASSERT(computed_);
136  return coordinates_; }
137 
138 #endif
139 
140 
#define ASSERT(expr)
Definition: asserts.hh:351
ArmaVec< Type, nr > vec(uint mat_index) const
Definition: armor.hh:821
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 unsigned int index) const
Returns Plucker coordinate of index.
Definition: plucker.hh:113
arma::vec6 get_plucker_coords() const
Gets Plucker coordinates.
Definition: plucker.hh:134
double operator*(const Plucker &b)
Compute product of two Plucker coordinates.
Definition: plucker.cc:38
~Plucker()
Destructor.
Definition: plucker.hh:72
void clear()
Sets the flag computed on false.
Definition: plucker.hh:117
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
bool is_computed() const
Return true if Plucker coordinates have been computed already.
Definition: plucker.hh:120
double scale() const
Definition: plucker.hh:74
arma::vec3 get_u_vector() const
Gets directional vector U.
Definition: plucker.hh:126
friend std::ostream & operator<<(std::ostream &os, const Plucker &p)
Friend output operator.
Plucker()
Definition: plucker.cc:5
arma::vec3 get_ua_vector() const
Gets cross product vector UxA.
Definition: plucker.hh:130
Armor::ArmaVec< double, spacedim > Point
Definition: point.hh:42
std::ostream & operator<<(std::ostream &os, const Plucker &p)
Operator for printing Plucker coordinates.
Definition: plucker.cc:52