CEPS  24.01
Cardiac ElectroPhysiology Simulator
CepsVertex.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
34 #pragma once
35 
36 #include <Eigen/Dense>
37 #include <iomanip>
38 
40 
42 {
43 public:
45  CepsVertex (const CepsReal &x = 0.0, const CepsReal &y = 0.0, const CepsReal &z = 0.0);
46 
48  explicit CepsVertex (const CepsReal3D &coor);
49 
51  CepsVertex (const CepsVertex &) = default;
52 
54  CepsVertex (CepsVertex &&) noexcept = default;
55 
57  CepsVertex &
58  operator= (const CepsVertex &) = default;
59 
61  CepsVertex &
62  operator= (CepsVertex &&) noexcept = default;
63 
65  CepsVertex &
66  operator= (const CepsMathVertices &vec);
67 
69  CepsVertex &
70  operator= (const CepsReal3D &vec);
71 
73  virtual ~CepsVertex () = default;
74 
80  operator CepsMathVertex () const;
81 
82  // -------------------------------------------------------------------------
83  // Coordinates manipulation
84  // -------------------------------------------------------------------------
85 
87  void
88  setX (const CepsReal &x);
89 
91  void
92  setY (const CepsReal &y);
93 
95  void
96  setZ (const CepsReal &z);
97 
99  void
100  setCoordinate (const CepsUInt &dim, const CepsReal &coor);
101 
103  void
104  setCoordinates (const CepsReal &x, const CepsReal &y = 0., const CepsReal &z = 0.);
105 
107  void
108  setCoordinates (const CepsReal3D &coor);
109 
111  void
112  setCoordinates (const CepsReal *coors, const CepsUInt &n);
113 
115  void
116  scale (const CepsReal &scaleFactor);
117 
118  // -------------------------------------------------------------------------
119  // Coordinates data
120  // -------------------------------------------------------------------------
121 
123  const CepsReal &
124  x () const;
125 
127  const CepsReal &
128  y () const;
129 
131  const CepsReal &
132  z () const;
133 
135  CepsReal &
136  getCoordinate (const CepsSize &dim);
137 
139  const CepsReal &
140  getCoordinate (const CepsSize &dim) const;
141 
143  CepsReal &
144  operator[] (const CepsUInt &dim);
145 
147  const CepsReal &
148  operator[] (const CepsUInt &dim) const;
149 
151  CepsReal3D &
152  getCoordinates ();
153 
155  const CepsReal3D &
156  getCoordinates () const;
157 
160  getCoordinatesForEigen () const;
161 
162  // -------------------------------------------------------------------------
163  // Coordinates operations
164  // -------------------------------------------------------------------------
165 
171  CepsBool
172  equals (const CepsVertex &vert, const CepsReal &errorFactor = 1.0);
173 
175  CepsReal
176  norm2 (const CepsSize &dim = 3) const;
177 
185  CepsReal
186  normp (const CepsInt &p, const CepsSize &dim = 3) const;
187 
189  CepsReal
190  dot (const CepsVertex &other, const CepsSize &dim = 3) const;
191 
197  friend std::ostream &
198  operator<< (std::ostream &os, const CepsVertex &vertex);
199 
200 private:
202 };
203 
205 std::ostream &
206 operator<< (std::ostream &os, const CepsVertex &vertex);
207 
209 CepsReal
210 dotProduct (const CepsVertex &a, const CepsVertex &b, const CepsSize &dim = 3);
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
size_t CepsSize
Size unsigned.
Definition: CepsTypes.hpp:126
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
Eigen::Matrix< CepsScalar, 3, 1 > CepsMathVertex
Vertex, eigen format.
Definition: CepsTypes.hpp:135
Eigen::Matrix< CepsScalar, 3, Eigen::Dynamic > CepsMathVertices
Array of vertices, eigen format.
Definition: CepsTypes.hpp:136
CepsArray3< CepsReal > CepsReal3D
Three real scalars, used like this for compatibility in polynomials.
Definition: CepsTypes.hpp:178
int32_t CepsInt
Need 32 bit integer.
Definition: CepsTypes.hpp:106
CepsReal dotProduct(const CepsVertex &a, const CepsVertex &b, const CepsSize &dim=3)
Scalar product. dim restricts which components are used (1:(x), 2:(x,y), 3:(x,y,z))
Definition: CepsVertex.cpp:262
CepsVertex(const CepsReal &x=0.0, const CepsReal &y=0.0, const CepsReal &z=0.0)
Constructor with coordinates.
Definition: CepsVertex.cpp:39
void setX(const CepsReal &x)
Set vertex x coordinate.
Definition: CepsVertex.cpp:56
CepsMathVertex getCoordinatesForEigen() const
Get three coordinates.
Definition: CepsVertex.cpp:186
const CepsReal & x() const
Vertex x coordinate.
Definition: CepsVertex.cpp:126
void setCoordinates(const CepsReal &x, const CepsReal &y=0., const CepsReal &z=0.)
Set the 3 coordinates at once.
Definition: CepsVertex.cpp:87
CepsReal & getCoordinate(const CepsSize &dim)
Get coordinate of dimension 0 1 2, read & write.
Definition: CepsVertex.cpp:144
CepsReal dot(const CepsVertex &other, const CepsSize &dim=3) const
Scalar product. dim restricts which components are used (1:(x), 2:(x,y), 3:(x,y,z))
Definition: CepsVertex.cpp:240
CepsVertex(const CepsVertex &)=default
Copy constructor.
CepsVertex(CepsVertex &&) noexcept=default
Copy constructor.
void setY(const CepsReal &y)
Set vertex y coordinate.
Definition: CepsVertex.cpp:63
void scale(const CepsReal &scaleFactor)
Scale all coordinates of this node.
Definition: CepsVertex.cpp:111
const CepsReal & y() const
Vertex y coordinate.
Definition: CepsVertex.cpp:132
void setCoordinate(const CepsUInt &dim, const CepsReal &coor)
Set the three coordinates.
Definition: CepsVertex.cpp:77
CepsReal norm2(const CepsSize &dim=3) const
Euclidian norm of coordinates.
Definition: CepsVertex.cpp:202
CepsReal normp(const CepsInt &p, const CepsSize &dim=3) const
Norm p (for p =-1, 1, 2, etc) with p=-1 gives the inf norm.
Definition: CepsVertex.cpp:218
void setZ(const CepsReal &z)
Set vertex z coordinate.
Definition: CepsVertex.cpp:70
const CepsReal & z() const
Vertex z coordinate.
Definition: CepsVertex.cpp:138
CepsReal3D m_coor
Definition: CepsVertex.hpp:201
CepsReal3D & getCoordinates()
Get three coordinates, read & write.
Definition: CepsVertex.cpp:174
CepsBool equals(const CepsVertex &vert, const CepsReal &errorFactor=1.0)
Check for coordinates equality.
Definition: CepsVertex.cpp:192