Mon, 20 Jun 2022 18:40:22 +0300
Made message log a model
#pragma once #include "basics.h" #include "model.h" namespace ldraw { /// Determines how quadrilaterals are split into triangles enum class Diagonal { Diagonal_13, Diagonal_24 }; std::pair<Triangle, Triangle> splitTriangles( const Quadrilateral& q, ldraw::Diagonal diagonal); /* void makeUnofficial(ModelEditor &editor); */ constexpr float circleAngle(int divisions, int i) { constexpr float ofs = 0.5 * pi<>; float factor = -2.0f * pi<> / divisions; return i * factor + ofs; } constexpr glm::vec2 rimpoint(int divisions, int i) { const float angle = circleAngle(divisions, i); return glm::vec2{std::sin(angle), std::cos(angle)}; } template<typename Fn> void circleAngles(int segments, int divisions, Fn&& fn) { for (int i = 0; i < segments; i += 1) { const float a1 = circleAngle(divisions, i - 1); const float a2 = circleAngle(divisions, i); const float a3 = circleAngle(divisions, i + 1); fn(a1, a2, a3); } } template<typename Fn> void circle(int segments, int divisions, Fn&& fn) { circleAngles(segments, divisions, [&fn]( const float a1, const float a2, const float a3 ){ fn( glm::vec2{std::sin(a1), std::cos(a1)}, glm::vec2{std::sin(a2), std::cos(a2)}, glm::vec2{std::sin(a3), std::cos(a3)} ); }); } } ModelElement inverted(const ModelElement &element);