From 27b51e8c35e62183583a80a8689591fdbaf031f9 Mon Sep 17 00:00:00 2001 From: xAlpharax <42233094+xAlpharax@users.noreply.github.com> Date: Sat, 2 Sep 2023 15:41:23 +0300 Subject: Initial migration of the project. It does work but would require some documentation. Changes to be committed: new file: LorenzAttractor.cpp new file: LorenzAttractor.h modified: README.md new file: main.cpp new file: run.sh new file: vectormath.h --- LorenzAttractor.h | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 LorenzAttractor.h (limited to 'LorenzAttractor.h') diff --git a/LorenzAttractor.h b/LorenzAttractor.h new file mode 100644 index 0000000..9ebb1cb --- /dev/null +++ b/LorenzAttractor.h @@ -0,0 +1,111 @@ +#include "vectormath.h" + +#include +#include +#include + +class LorenzAttractor +{ +private: + sf::Event event; + sf::Clock clock; + + double input_timer = 0; + double timestep; + + float g_screenWidth = 1920; + float g_screenHeight = 1080; + + bool isFullscreen = true; + bool endSubProgram = false; + + sf::View view; + + // Camera values + sf::Vector3f cam_position = { 0, 0, -50 }; + std::vector cam_angle = { 0, 0, 0 }; + sf::Vector3f display_position = { 0, 0, 100 }; + + std::vector point; + sf::Vector2f projected_point; + + // Attractor parameters + unsigned u = 0; + std::vector> params; + + // Rotation Matrices + Matrix3 rotMatrixX; + Matrix3 rotMatrixY; + Matrix3 rotMatrixZ; + + // Visual assets + std::vector> trail; // Contains "num_points" many "trail_length" previous coordinates + std::vector j; // Indices of the last position drawn (algorithm for drawing trails without reallocating memory) + sf::VertexArray line; // Line object to be drawn + std::vector circle; + std::vector colours; + std::vector> trail_colours_params; + + // Visual parameters + unsigned num_points = 300; + unsigned trail_length = 100; + float speed = 1.f; + + // Constants + float pi = 3.141592653589f; + + // Names per attractor + sf::Text text; + sf::Font font; + std::vector names = + { + "Lorenz Attractor", + "3-Cells CNN Attractor", + "Aizawa Attractor", + "Bouali Attractor", + "Chen-Lee Attractor", + "Halvorsen Attractor", + "Finance Attractor", + "Newton-Leipnik Attractor", + "Nose-Hoover Attractor", + "Thomas Attractor" + }; + +public: + LorenzAttractor(); + + sf::Uint8 clamp(float x) + { + if (x <= 0) + return 0; + else if (x >= 255) + return 255; + else return static_cast(x); + } + + float getRandomNumber(float MIN, float MAX) + { + std::random_device device; + std::mt19937 generator(device()); + std::uniform_real_distribution distribution(MIN, MAX); + return distribution(generator); + } + + int getRandomNumber(int MIN, int MAX) + { + std::random_device device; + std::mt19937 generator(device()); + std::uniform_int_distribution distribution(MIN, MAX); + return distribution(generator); + } + + void input(sf::RenderWindow &window); + + void update(); + + void draw(sf::RenderWindow &window); + + void run(sf::RenderWindow &window); + + ~LorenzAttractor(); +}; -- cgit v1.2.3