vertex enumeration working, but orientation is wrong.
This commit is contained in:
@@ -16,3 +16,5 @@ add_custom_command(
|
||||
add_executable(coxeter src/coxeter.cpp)
|
||||
add_executable(mirror src/mirrors.cpp)
|
||||
target_link_libraries(mirror PRIVATE glm)
|
||||
add_executable(mesh src/mesh.cpp)
|
||||
target_link_libraries(mesh PRIVATE glm)
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include "util/mesh.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -13,7 +16,7 @@ class CosetsWindow : public Window {
|
||||
GLuint tri;
|
||||
|
||||
GLuint verts;
|
||||
static const unsigned VERTS_N = 8;
|
||||
std::vector<glm::vec4> verts_data;
|
||||
|
||||
public:
|
||||
void init() override {
|
||||
@@ -29,21 +32,16 @@ public:
|
||||
|
||||
program = build_program("main", vs, fs);
|
||||
|
||||
glm::vec4 verts_data[VERTS_N]{
|
||||
{+0.5, +0.5, +0.5, +0.0},
|
||||
{+0.5, -0.5, +0.5, +0.0},
|
||||
{-0.5, -0.5, +0.5, +0.0},
|
||||
{-0.5, +0.5, +0.5, +0.0},
|
||||
|
||||
{+0.5, +0.5, +0.5, -0.5},
|
||||
{+0.5, -0.5, +0.5, -0.5},
|
||||
{-0.5, -0.5, +0.5, +0.5},
|
||||
{-0.5, +0.5, +0.5, +0.5},
|
||||
};
|
||||
verts_data = vertices<3>({}, Multiplicites<3>({
|
||||
{0, 1, 4},
|
||||
{1, 2, 3}
|
||||
}), {
|
||||
2.0f, .05f, 0.05f
|
||||
});
|
||||
|
||||
glGenBuffers(1, &verts);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, verts);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4 * VERTS_N, verts_data, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec4) * verts_data.size(), &verts_data[0], GL_STATIC_DRAW);
|
||||
|
||||
|
||||
glGenVertexArrays(1, &tri);
|
||||
@@ -78,7 +76,7 @@ public:
|
||||
glPointSize(10.f);
|
||||
|
||||
glBindVertexArray(tri);
|
||||
glDrawArrays(GL_POINTS, 0, VERTS_N);
|
||||
glDrawArrays(GL_POINTS, 0, verts_data.size());
|
||||
|
||||
swapbuffers();
|
||||
}
|
||||
|
||||
16
cosets/src/mesh.cpp
Normal file
16
cosets/src/mesh.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "util/mesh.hpp"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto vs = vertices<3>({}, Multiplicites<3>({
|
||||
{0, 1, 4},
|
||||
{1, 2, 3}
|
||||
}), {
|
||||
1.0f, 1.0f, 1.0f
|
||||
});
|
||||
|
||||
for (const auto &v : vs) {
|
||||
std::cout << glm::to_string(v) << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
60
cosets/src/util/mesh.hpp
Normal file
60
cosets/src/util/mesh.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include "coxeter.hpp"
|
||||
#include "mirrors.hpp"
|
||||
#include "numeric.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
template<int N>
|
||||
std::vector<glm::vec4>
|
||||
vertices(const std::vector<int> &subgens, const Multiplicites<N> &mults, const float (&coords)[N]) {
|
||||
std::vector<std::vector<int>> rels{};
|
||||
rels.reserve(N + N * (N - 1) / 2);
|
||||
|
||||
for (int i = 0; i < N; ++i) {
|
||||
rels.push_back({i, i});
|
||||
}
|
||||
for (int a = 0; a < N; ++a) {
|
||||
for (int b = 0; b < a; ++b) {
|
||||
int mult = mults.get(a, b);
|
||||
|
||||
std::vector<int> rel{};
|
||||
for (int i = 0; i < mult; ++i) {
|
||||
rel.push_back(a);
|
||||
rel.push_back(b);
|
||||
}
|
||||
rels.push_back(rel);
|
||||
}
|
||||
}
|
||||
|
||||
Table *table = solve(N, subgens, rels);
|
||||
|
||||
// std::cout << table->size() << std::endl;
|
||||
// std::cout << *table << std::endl;
|
||||
|
||||
// for (const auto &v : table->words()) {
|
||||
// std::cout << "[ ";
|
||||
// for (auto e : v) {
|
||||
// std::cout << e << " ";
|
||||
// }
|
||||
// std::cout << "]\n";
|
||||
// }
|
||||
|
||||
const std::vector<glm::vec4> &normals = mirror<3>(mults);
|
||||
const std::vector<glm::vec4> &corners = plane_intersections(normals);
|
||||
const std::vector<float> coords_vec(coords, coords + N);
|
||||
const glm::vec4 &identity = glm::normalize(barycentric(corners, coords_vec));
|
||||
|
||||
std::vector<glm::vec4> verts(table->size());
|
||||
|
||||
for (const auto &word : table->words()) {
|
||||
glm::vec4 vert = identity;
|
||||
for (const auto &gen : word) {
|
||||
vert = reflect(vert, normals[gen]);
|
||||
}
|
||||
verts.push_back(vert);
|
||||
}
|
||||
|
||||
return verts;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ std::vector<glm::vec4> plane_intersections(std::vector<glm::vec4> normals) {
|
||||
std::vector<glm::vec4> results(N);
|
||||
|
||||
for (int i = 0; i < N; ++i) {
|
||||
results[i] = gram_schmidt_last(normals);
|
||||
results[i] = glm::normalize(gram_schmidt_last(normals));
|
||||
std::rotate(normals.begin(), normals.begin() + 1, normals.end());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user