add tesseract frame

This commit is contained in:
2018-12-21 09:07:24 -05:00
parent 876f1edb85
commit d77e347bf4
3 changed files with 33 additions and 7 deletions

View File

@@ -121,8 +121,9 @@ Mesh<prim + 1> joinCap(Mesh<prim> m, Mesh<prim> n) {
return concat(join(m, n), concat(fill(m), fill(n)));
}
Mesh<4> thicken(const Mesh<3> &m, float thickness) {
return joinCap(offset(m, glm::vec4(0, 0, 0, -thickness / 2)), offset(m, glm::vec4(0, 0, 0, thickness / 2)));
template<unsigned int prim>
Mesh<prim + 1> thicken(const Mesh<prim> &m, glm::vec4 width) {
return joinCap(m - width / 2.f, m + width / 2.f);
}
template<unsigned int prim>
@@ -149,4 +150,10 @@ Mesh<prim> operator/(Mesh<prim> m, float scl) { return scale(m, 1.f / scl); }
template<unsigned int prim>
Mesh<prim> operator*(glm::mat4 mat, Mesh<prim> m) { return transform(m, mat); }
template<unsigned int prim>
Mesh<prim> simplify(Mesh<prim> m) {
// todo remove redundant vertices and primitives
return Mesh<prim>({}, {});
}
#endif //SIMPLEX_MESH_H

View File

@@ -47,4 +47,23 @@ Mesh<4> tesseract() {
rot_zw(T) * pair;
}
Mesh<4> tesseract_frame(float width) {
Mesh<4> edge = tesseract() * glm::vec4(width, width, width, 1);
auto o = glm::vec3(1 - width);
Mesh<4> set = (edge + glm::vec4(+o.x, +o.y, +o.z, 0)) +
(edge + glm::vec4(+o.x, +o.y, -o.z, 0)) +
(edge + glm::vec4(+o.x, -o.y, +o.z, 0)) +
(edge + glm::vec4(+o.x, -o.y, -o.z, 0)) +
(edge + glm::vec4(-o.x, +o.y, +o.z, 0)) +
(edge + glm::vec4(-o.x, +o.y, -o.z, 0)) +
(edge + glm::vec4(-o.x, -o.y, +o.z, 0)) +
(edge + glm::vec4(-o.x, -o.y, -o.z, 0));
return set +
rot_xw(T) * set +
rot_yw(T) * set +
rot_zw(T) * set;
}
#endif //SIMPLEX_SOLIDS_H