Flow123d  master-c754b67
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 
Space::Point
Armor::ArmaVec< double, spacedim > Point
Definition: point.hh:42
Plucker::is_computed
bool is_computed() const
Return true if Plucker coordinates have been computed already.
Definition: plucker.hh:120
Plucker::~Plucker
~Plucker()
Destructor.
Definition: plucker.hh:72
armor.hh
Plucker::Point
Space< 3 >::Point Point
Definition: plucker.hh:54
Plucker
Plucker coordinates representing line given by points A,B.
Definition: plucker.hh:45
Plucker::scale
double scale() const
Definition: plucker.hh:74
Plucker::point
arma::vec3 point(unsigned int idx) const
Gets coordinates of point.
Definition: plucker.hh:123
Plucker::operator*
double operator*(const Plucker &b)
Compute product of two Plucker coordinates.
Definition: plucker.cc:38
ASSERT
#define ASSERT(expr)
Definition: asserts.hh:351
point.hh
Armor::Array::vec
ArmaVec< Type, nr > vec(uint mat_index) const
Definition: armor.hh:821
Plucker::computed_
bool computed_
True, if Plucker coordinates are computed; false otherwise.
Definition: plucker.hh:50
Plucker::clear
void clear()
Sets the flag computed on false.
Definition: plucker.hh:117
system.hh
arma::vec3
Definition: doxy_dummy_defs.hh:17
Plucker::operator<<
friend std::ostream & operator<<(std::ostream &os, const Plucker &p)
Friend output operator.
Plucker::get_ua_vector
arma::vec3 get_ua_vector() const
Gets cross product vector UxA.
Definition: plucker.hh:130
Plucker::get_u_vector
arma::vec3 get_u_vector() const
Gets directional vector U.
Definition: plucker.hh:126
Plucker::get_plucker_coords
arma::vec6 get_plucker_coords() const
Gets Plucker coordinates.
Definition: plucker.hh:134
operator<<
std::ostream & operator<<(std::ostream &os, const Plucker &p)
Operator for printing Plucker coordinates.
Definition: plucker.cc:52
Plucker::points_
Armor::Array< double > points_
Definition: plucker.hh:51
Plucker::Plucker
Plucker()
Definition: plucker.cc:5
Plucker::compute
void compute()
Compute Plucker coordinates and set computed to true.
Definition: plucker.cc:43
Plucker::coordinates_
arma::vec6 coordinates_
Plucker coordinates.
Definition: plucker.hh:48
Armor::Array< double >
Plucker::scale_
double scale_
Definition: plucker.hh:49
Plucker::operator[]
double operator[](const unsigned int index) const
Returns Plucker coordinate of index.
Definition: plucker.hh:113