NetDEM v1.0
Loading...
Searching...
No Matches
gjk_simplex.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "utils_math.hpp"
4
5namespace netdem {
6
18class Simplex {
19public:
22
23private:
25 int size{0};
26
27public:
30
39 Simplex(Vec3d const &a) {
40 size = 1;
41
42 points[0] = a;
43 }
44
54 Simplex(Vec3d const &a, Vec3d const &b) {
55 size = 2;
56
57 points[0] = a;
58 points[1] = b;
59 }
60
71 Simplex(Vec3d const &a, Vec3d const &b, Vec3d const &c) {
72 size = 3;
73
74 points[0] = a;
75 points[1] = b;
76 points[2] = c;
77 }
78
90 Simplex(Vec3d const &a, Vec3d const &b, Vec3d const &c, Vec3d const &d) {
91 size = 4;
92
93 points[0] = a;
94 points[1] = b;
95 points[2] = c;
96 points[3] = d;
97 }
98
100 int Size() { return size; };
101
110 void PushBack(Vec3d const &p) {
111 points[size] = p;
112 size += 1;
113 }
114
124 void PushFront(Vec3d const &p) {
125 for (int i = size; i > 0; i--) {
126 points[size] = points[size - 1];
127 }
128 points[0] = p;
129 size += 1;
130 }
131};
132
133} // namespace netdem
A simplex class for representing a convex hull in n-dimensional space.
Definition gjk_simplex.hpp:18
Simplex(Vec3d const &a, Vec3d const &b, Vec3d const &c, Vec3d const &d)
Construct a simplex with four vertices.
Definition gjk_simplex.hpp:90
Simplex(Vec3d const &a, Vec3d const &b)
Construct a simplex with two vertices.
Definition gjk_simplex.hpp:54
Simplex()
Definition gjk_simplex.hpp:29
void PushFront(Vec3d const &p)
Add a new vertex to the front of the simplex.
Definition gjk_simplex.hpp:124
void PushBack(Vec3d const &p)
Add a new vertex to the end of the simplex.
Definition gjk_simplex.hpp:110
Simplex(Vec3d const &a)
Construct a simplex with one vertex.
Definition gjk_simplex.hpp:39
VecNT< Vec3d, 4 > points
Definition gjk_simplex.hpp:21
Simplex(Vec3d const &a, Vec3d const &b, Vec3d const &c)
Construct a simplex with three vertices.
Definition gjk_simplex.hpp:71
int Size()
Definition gjk_simplex.hpp:100
Definition bond_entry.hpp:7
std::array< double, 3 > Vec3d
Definition utils_macros.hpp:18
std::array< T, N > VecNT
Definition utils_macros.hpp:32