use multiplicities class; fix cmakelists typo
This commit is contained in:
@@ -13,6 +13,6 @@ add_custom_command(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/shaders
|
||||
)
|
||||
|
||||
add_executable(coxeter scr/coxeter.cpp)
|
||||
add_executable(coxeter src/coxeter.cpp)
|
||||
add_executable(mirror src/mirrors.cpp)
|
||||
target_link_libraries(mirror PRIVATE glm)
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include "util/mirrors.hpp"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto normals = mirror<3>({
|
||||
{},
|
||||
{4},
|
||||
{2, 3}
|
||||
});
|
||||
auto normals = mirror<3>(Multiplicites<3>({
|
||||
{0, 1, 4},
|
||||
{1, 2, 3}
|
||||
}));
|
||||
|
||||
for (const auto &normal : normals) {
|
||||
std::cout << glm::to_string(normal) << std::endl;
|
||||
|
||||
@@ -4,6 +4,38 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
struct Mult {
|
||||
int a, b, mult;
|
||||
};
|
||||
|
||||
template<int N>
|
||||
struct Multiplicites {
|
||||
std::vector<int> mults;
|
||||
|
||||
explicit Multiplicites(std::vector<Mult> vals) {
|
||||
mults = std::vector<int>(N * (N - 1) / 2, 2);
|
||||
for (const auto &mult : vals) {
|
||||
set(mult.a, mult.b, mult.mult);
|
||||
}
|
||||
}
|
||||
|
||||
void set(int a, int b, int mult) {
|
||||
if (a > N or b > N) throw std::logic_error("mirror does not exist");
|
||||
if (a == b) throw std::logic_error("cannot compare mirror to itself");
|
||||
if (a < b) std::swap(a, b); // a is bigger
|
||||
|
||||
mults[a + b] = mult;
|
||||
}
|
||||
|
||||
int get(int a, int b) const {
|
||||
if (a > N or b > N) throw std::logic_error("mirror does not exist");
|
||||
if (a == b) throw std::logic_error("cannot compare mirror to itself");
|
||||
if (a < b) std::swap(a, b); // a is bigger
|
||||
|
||||
return mults[a + b];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct Table {
|
||||
int N;
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
#include <iomanip>
|
||||
|
||||
#include "numeric.hpp"
|
||||
#include "coxeter.hpp"
|
||||
|
||||
template<int N>
|
||||
std::vector<glm::vec4> mirror(const float (&arr)[N][N]) {
|
||||
std::vector<glm::vec4> mirror(const Multiplicites<N> &mults) {
|
||||
static_assert(1 <= N and N <= 4, "Vector size is unsupported");
|
||||
|
||||
std::vector<glm::vec4> mirrors{};
|
||||
@@ -16,7 +17,7 @@ std::vector<glm::vec4> mirror(const float (&arr)[N][N]) {
|
||||
glm::vec4 vp{};
|
||||
for (int m = 0; m < p; ++m) {
|
||||
glm::vec4 vq = mirrors[m];
|
||||
vp[m] = (cos(M_PI / arr[p][m]) - dot(m, vp, vq)) / vq[m];
|
||||
vp[m] = (cos(M_PI / mults.get(p, m)) - dot(m, vp, vq)) / vq[m];
|
||||
}
|
||||
vp[p] = std::sqrt(1 - glm::dot(vp, vp));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user