SimpleFastOpenAtomicVisualiser
Loading...
Searching...
No Matches
meshes.h
Go to the documentation of this file.
1#ifndef MESHES_H
2#define MESHES_H
3
4#include <triangle.h>
5
11template <class T>
12const T phi = (1.0+2.23606797749979)*0.5;
13
19template <class T>
20const std::vector<vec3<T>> DODECAHEDRON_VERTICES =
21{
22 vec3<T>(1.0, 1.0, 1.0)/phi<T>,
23 vec3<T>(1.0, 1.0, -1.0)/phi<T>,
24 vec3<T>(1.0, -1.0, 1.0)/phi<T>,
25 vec3<T>(-1.0, 1.0, 1.0)/phi<T>,
26 vec3<T>(-1.0, -1.0, -1.0)/phi<T>,
27 vec3<T>(-1.0, -1.0, 1.0)/phi<T>,
28 vec3<T>(-1.0, 1.0, -1.0)/phi<T>,
29 vec3<T>(1.0, -1.0, -1.0)/phi<T>,
30 vec3<T>(0.0, phi<T>, 1.0/phi<T>)/phi<T>,
31 vec3<T>(0.0, phi<T>, -1.0/phi<T>)/phi<T>,
32 vec3<T>(0.0, -phi<T>, 1.0/phi<T>)/phi<T>,
33 vec3<T>(0.0, -phi<T>, -1.0/phi<T>)/phi<T>,
34 vec3<T>(1.0/phi<T>, 0.0, phi<T>)/phi<T>,
35 vec3<T>(1.0/phi<T>, 0.0, -phi<T>)/phi<T>,
36 vec3<T>(-1.0/phi<T>, 0.0, phi<T>)/phi<T>,
37 vec3<T>(-1.0/phi<T>, 0.0, -phi<T>)/phi<T>,
38 vec3<T>(phi<T>, 1.0/phi<T>, 0.0)/phi<T>,
39 vec3<T>(phi<T>, -1.0/phi<T>, 0.0)/phi<T>,
40 vec3<T>(-phi<T>, 1.0/phi<T>, 0.0)/phi<T>,
41 vec3<T>(-phi<T>, -1.0/phi<T>, 0.0)/phi<T>
42};
43
49template <class T>
50const std::vector<Trixel<T>> DODECAHEDRON =
51{
88};
89
95template <class T>
96const T ICOSAHEDRON_X = 0.525731112119133606;
97
103template <class T>
104const T ICOSAHEDRON_Z = 0.850650808352039932;
105
111template <class T>
118
124template <class T>
125const std::vector<Trixel<T>> ICOSAHEDRON =
126{
147};
148
154template <class T>
155const std::vector<vec3<T>> OCTAHEDRON_VERTICES =
156{
157 {0.0,0.0,1.0},
158 {1.0,0.0,0.0},
159 {0.0,1.0,0.0},
160 {-1.0,0.0,0.0},
161 {0.0,-1.0,0.0},
162 {0.0,0.0,-1.0}
163};
164
170template <class T>
182
183template <class T>
184const T INV_SQRT3 = 1.0/1.7320508075688772;
185
191template <class T>
192const std::vector<vec3<T>> TETRAHEDRON_VERTICES =
193{
194 vec3<T>(1.0, 1.0, 1.0)*INV_SQRT3<T>,
195 vec3<T>(-1.0,1.0, -1.0)*INV_SQRT3<T>,
196 vec3<T>(1.0, -1.0, -1.0)*INV_SQRT3<T>,
197 vec3<T>(-1.0, -1.0, 1.0)*INV_SQRT3<T>
198};
199
205template <class T>
213
214template <class T>
215const T INV_SQRT2 = 1.0/1.4142135623730951;
216
222template <class T>
223const std::vector<vec3<T>> CUBE_VERTICES =
224{
225 INV_SQRT2<T>*vec3<T>(-1.0, -1.0, 1.0),
226 INV_SQRT2<T>*vec3<T>(1.0, -1.0, 1.0),
227 INV_SQRT2<T>*vec3<T>(1.0, 1.0, 1.0),
228 INV_SQRT2<T>*vec3<T>(-1.0, 1.0, 1.0),
229 INV_SQRT2<T>*vec3<T>(-1.0, -1.0, -1.0),
230 INV_SQRT2<T>*vec3<T>(1.0, -1.0, -1.0),
231 INV_SQRT2<T>*vec3<T>(1.0, 1.0, -1.0),
232 INV_SQRT2<T>*vec3<T>(-1.0, 1.0, -1.0)
233};
234
240template <class T>
256
257template <class T>
258const T SQRT3 = 1.7320508075688772;
259
260template <class T>
261const T SQRT6 = 2.449489742783178;
262
263// 1.0/std::sqrt((1.0/12.0)*std::pow(1.0 + std::sqrt(6.0),2.0) + std::pow(-0.5*std::sqrt(6.0) - 0.5,2.0));
264template <class T>
265const T C = 0.5021179759100816;
266
272template <class T>
273const std::vector<vec3<T>> TRIAUGMENTED_TRIANGULAR_PRISM_VERTICES =
274{
275 C<T>*vec3<T>(0.0, -2.0/SQRT3<T>, 1.0),
276 C<T>*vec3<T>(0.0, -2.0/SQRT3<T>, -1.0),
277 C<T>*vec3<T>(1.0, 1.0/SQRT3<T>, 1.0),
278 C<T>*vec3<T>(-1.0, 1.0/SQRT3<T>, 1.0),
279 C<T>*vec3<T>(1.0, 1.0/SQRT3<T>, -1.0),
280 C<T>*vec3<T>(-1.0, 1.0/SQRT3<T>, -1.0),
281 C<T>*vec3<T>(0.0, (1.0+SQRT6<T>)/SQRT3<T>, 0.0),
282 C<T>*vec3<T>((1.0+SQRT6<T>)/2.0, -(1.0+SQRT6<T>)/(2.0*SQRT3<T>), 0.0),
283 C<T>*vec3<T>(-(1.0+SQRT6<T>)/2.0, -(1.0+SQRT6<T>)/(2.0*SQRT3<T>), 0.0)
284};
285
291template <class T>
292const std::vector<Trixel<T>> TRIAUGMENTED_TRIANGULAR_PRISM =
293{
308};
309
316template <class T>
317void centreMesh(std::vector<Trixel<T>> & mesh)
318{
319 vec3<T> com = vec3<T>(0.0);
320 for (const auto & tri : mesh)
321 {
322 com += tri.x + tri.y + tri.z;
323 }
324 com /= float(mesh.size()*3);
325 for (auto & tri : mesh){
326 tri.x -= com;
327 tri.y -= com;
328 tri.z -= com;
329 }
330}
331
332#endif /* MESHES_H */
glm::vec< L, float, glm::qualifier::highp > vec
Definition commandLine.h:214
const T SQRT6
Definition meshes.h:261
const std::vector< vec3< T > > CUBE_VERTICES
A centred Cube's vertices.
Definition meshes.h:223
const T ICOSAHEDRON_X
Golden ratio scaled for a unit icosahedron.
Definition meshes.h:96
const T INV_SQRT2
Definition meshes.h:215
const T phi
Golden ratio.
Definition meshes.h:12
const T SQRT3
Definition meshes.h:258
const std::vector< Trixel< T > > CUBE
A centred Cube's triangulation.
Definition meshes.h:241
const std::vector< Trixel< T > > OCTAHEDRON
A centred Octahedron's triangulation.
Definition meshes.h:171
const std::vector< vec3< T > > DODECAHEDRON_VERTICES
A centred Dodecahedron's vertices.
Definition meshes.h:20
const std::vector< Trixel< T > > TETRAHEDRON
A centred Tetrahedron's triangulation.
Definition meshes.h:206
void centreMesh(std::vector< Trixel< T > > &mesh)
Centre a triangulation at (0,0,0).
Definition meshes.h:317
const std::vector< vec3< T > > OCTAHEDRON_VERTICES
A centred Octahedron's vertices.
Definition meshes.h:155
const std::vector< Trixel< T > > TRIAUGMENTED_TRIANGULAR_PRISM
A centred Triagmented triangular prism's triangulation.
Definition meshes.h:292
const std::vector< vec3< T > > TRIAUGMENTED_TRIANGULAR_PRISM_VERTICES
A centred Triagmented triangular prism's vertices.
Definition meshes.h:273
const std::vector< vec3< T > > ICOSAHEDRON_VERTICES
A centred Icosahedron's vertices.
Definition meshes.h:112
const std::vector< Trixel< T > > ICOSAHEDRON
A centred Icosahedrons's triangulation.
Definition meshes.h:125
const std::vector< vec3< T > > TETRAHEDRON_VERTICES
A centred Tetrahedron's vertices.
Definition meshes.h:192
const std::vector< Trixel< T > > DODECAHEDRON
A centred Dodecahedron's triangulation.
Definition meshes.h:50
const T C
Definition meshes.h:265
const T INV_SQRT3
Definition meshes.h:184
const T ICOSAHEDRON_Z
1 scaled for a unit icosahedron.
Definition meshes.h:104