00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TETRAHEDRON_HPP
00021 #define TETRAHEDRON_HPP
00022
00032 #include <Cell.hpp>
00033 #include <Triangle.hpp>
00034
00035 #include <TinyMatrix.hpp>
00036
00037 class Tetrahedron
00038 : public Cell
00039 {
00040 public:
00041 enum {
00042 NumberOfVertices = 4,
00043 NumberOfFaces = 4,
00044 NumberOfEdges = 6
00045 };
00046
00047 typedef Triangle FaceType;
00048
00049 static const size_t faces[NumberOfFaces][FaceType::NumberOfVertices];
00050 static const size_t edges[NumberOfEdges][Edge::NumberOfVertices];
00051
00052 virtual Cell::Type type() const
00053 {
00054 return Cell::tetrahedron;
00055 }
00056
00066 inline void getBarycentricCoordinates(const TinyVector<3, real_t>& X,
00067 TinyVector<4, real_t>& lambda) const
00068 {
00069 TinyVector<4, real_t> X2;
00070 for (size_t i=0; i<3; ++i) X2[i] = X[i];
00071 X2[3] = 1;
00072
00073 TinyMatrix<4, 4, real_t> M = 0;
00074 for (size_t i=0; i<4; ++i) {
00075 const Vertex& V = (*this)(i);
00076 for (size_t j=0; j<3; ++j) {
00077 M(j, i) = V[j];
00078 }
00079 }
00080
00081 for (size_t i=0; i<4; ++i) {
00082 M(3,i) = 1;
00083 }
00084
00085 lambda = X2/M;
00086 }
00087
00089 size_t numberOfVertices() const
00090 {
00091 return NumberOfVertices;
00092 }
00093
00095 size_t numberOfEdges() const
00096 {
00097 return NumberOfEdges;
00098 }
00099
00101 inline const Tetrahedron& operator=(const Tetrahedron& T)
00102 {
00103 Cell::operator=(T);
00104 return *this;
00105 }
00106
00108 Tetrahedron()
00109 : Cell(Tetrahedron::NumberOfVertices)
00110 {
00111 ;
00112 }
00113
00114 Tetrahedron(Vertex& x0,
00115 Vertex& x1,
00116 Vertex& x2,
00117 Vertex& x3,
00118 const size_t& ref = 0);
00119
00120 ~Tetrahedron()
00121 {
00122 ;
00123 }
00124
00125 };
00126
00127 #endif // TETRAHEDRON_HPP
00128