From ca9bbea0a0a3ec98fa6774a9d2c75f01974b0a68 Mon Sep 17 00:00:00 2001 From: xAlpharax <42233094+xAlpharax@users.noreply.github.com> Date: Mon, 4 Sep 2023 02:57:57 +0300 Subject: Final form. Changes to be committed: new file: Inconsolata-Regular.ttf modified: LorenzAttractor.cpp modified: LorenzAttractor.h modified: vectormath.h modified: README.md modified: main.cpp modified: run.sh --- Inconsolata-Regular.ttf | Bin 0 -> 84868 bytes LICENSE | 21 --------------------- LorenzAttractor.cpp | 2 +- LorenzAttractor.h | 7 ++++--- README.md | 48 +++++++++++++++++++++++++++++++++--------------- main.cpp | 12 ++++++------ run.sh | 4 +++- vectormath.h | 15 +++++++++++++-- 8 files changed, 60 insertions(+), 49 deletions(-) create mode 100644 Inconsolata-Regular.ttf delete mode 100644 LICENSE diff --git a/Inconsolata-Regular.ttf b/Inconsolata-Regular.ttf new file mode 100644 index 0000000..4ea3681 Binary files /dev/null and b/Inconsolata-Regular.ttf differ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index a95740b..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Alphara - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/LorenzAttractor.cpp b/LorenzAttractor.cpp index 70d66bd..87c0ece 100644 --- a/LorenzAttractor.cpp +++ b/LorenzAttractor.cpp @@ -3,7 +3,7 @@ LorenzAttractor::LorenzAttractor() { // Text - font.loadFromFile("/usr/share/fontforge/pixmaps/Inconsolata-Regular.ttf"); + font.loadFromFile("./Inconsolata-Regular.ttf"); text.setFont(font); text.setString(names[u]); text.setScale(0.1f, 0.1f); diff --git a/LorenzAttractor.h b/LorenzAttractor.h index 9ebb1cb..b1873e5 100644 --- a/LorenzAttractor.h +++ b/LorenzAttractor.h @@ -1,8 +1,9 @@ +#include + #include "vectormath.h" -#include #include -#include +#include class LorenzAttractor { @@ -47,7 +48,7 @@ private: std::vector> trail_colours_params; // Visual parameters - unsigned num_points = 300; + unsigned num_points = 500; unsigned trail_length = 100; float speed = 1.f; diff --git a/README.md b/README.md index 1c201c3..a1683c2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Visualize and experiment with Chaos Equations and Strange Attractors. This repo consists of a fork of [this repository](https://github.com/orfeasliossatos/Coding-Projects) which was tweaked and ported to Linux. -[Video demonstration](https://youtu.be/idpOunnpKTo?si=GenFkDGUzg6Co1Zy) (from the original creator): https://youtu.be/idpOunnpKTo?si=GenFkDGUzg6Co1Zy +[Video demonstration](https://youtu.be/idpOunnpKTo?si=GenFkDGUzg6Co1Zy) (from the [original creator](https://github.com/orfeasliossatos)) ## Requirements @@ -12,20 +12,38 @@ This project uses SFML. You may easily find SFML and SFML-devel in your package ## Usage -Run `./run.sh` to compile and execute the program. +To compile and execute the program do: -### Controls - -H to switch to the next attractor - -W/A/S/D for moving in the plane - -Space/Shift to move up and down +```bash +./run.sh +``` -Up/Down/Left/Right to turn the camera - -These will feel familiar to Minecraft players ;) - -### Todo: +### Controls -Pick a font that every distro ships. +Intuitive "Minecraft" controls. "H" and "h" act the same. + +> W/A/S/D for moving in the plane +> +> Space/Shift to move up and down +> +> Up/Down/Left/Right to turn the camera + +Or as [AnonymoZ](https://github.com/AnonymoZ) put it: + +> Move to the next attractor with “H” and to the previous attractor with “G”. +> +> Press “Page Up” and “Page Down” now to control the speed of the motion. +> +> Use the Arrow Keys, “W, A, S, D” and also “LShift and Space” to move the camera. +> +> The Arrow Keys will only tilt the camera angle, while “LShift”, “Space”, “A” and “D” move “↑”, “↓”, “←”, “→” respectively. +> +> And finally “W” and “S” zoom in and out of the canvas. +> +> Press “Esc” to exit the program. +> +> Change to fullscreen or not with “F”. + +### Cool thing + +![Image](https://cdn.discordapp.com/attachments/663775769293750302/1148043114414620753/image.png) diff --git a/main.cpp b/main.cpp index 68813dd..bb69394 100644 --- a/main.cpp +++ b/main.cpp @@ -1,23 +1,23 @@ -#include "LorenzAttractor.h" #include +#include "LorenzAttractor.h" int main() { - /// Create a window + /// Create the window bool isFullscreen = true; sf::RenderWindow window; - window.create(sf::VideoMode(1980, 1080), "Attractors", (isFullscreen ? sf::Style::Fullscreen : sf::Style::Default), sf::ContextSettings()); - // window.create(sf::VideoMode(1980, 1080), "Attractors", sf::Style::Default, sf::ContextSettings()); + window.create(sf::VideoMode(1980, 1080), "Chaotic Attractors", (isFullscreen ? sf::Style::Fullscreen : sf::Style::Default), sf::ContextSettings()); window.setPosition(sf::Vector2i(0, 0)); window.setVerticalSyncEnabled(true); - window.setFramerateLimit(144); + window.setFramerateLimit(60); /// Create an instance of the LorenzAttractor class LorenzAttractor lorenz; - /// Run the Lorenz Attractor simulation + /// Run the simulation lorenz.run(window); + /// Profit } diff --git a/run.sh b/run.sh index 576894e..4a18fdf 100755 --- a/run.sh +++ b/run.sh @@ -6,4 +6,6 @@ g++ -c main.cpp -o main.o g++ -c LorenzAttractor.cpp -o LorenzAttractor.o -g++ main.o LorenzAttractor.o -o MyProgram -lsfml-graphics -lsfml-window -lsfml-system +g++ main.o LorenzAttractor.o -o ChaoticAttractors -lsfml-graphics -lsfml-window -lsfml-system + +./ChaoticAttractors diff --git a/vectormath.h b/vectormath.h index 874502f..7aaf917 100644 --- a/vectormath.h +++ b/vectormath.h @@ -1,8 +1,7 @@ -#pragma once #include +#include #include #include -#include #include ///////////////////// @@ -115,7 +114,9 @@ public: delete[] m_data; } }; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + template std::ostream& operator<<(std::ostream &out, Matrix3 &m) { @@ -128,7 +129,9 @@ std::ostream& operator<<(std::ostream &out, Matrix3 &m) return out; } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + template bool operator==(Matrix3 m1, Matrix3 m2) { @@ -154,7 +157,9 @@ bool operator!=(Matrix3 m1, Matrix3 m2) return false; else return true; } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + template Matrix3 operator+(const Matrix3 &left, const Matrix3 &right) { @@ -172,7 +177,9 @@ Matrix3& operator+=(Matrix3 &left, const Matrix3 &right) return left; } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + template Matrix3 operator-(const Matrix3 &left, const Matrix3 &right) { @@ -200,7 +207,9 @@ Matrix3& operator-(Matrix3 &left) return left; } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + template Matrix3& operator*=(Matrix3 &left, const U &right) { @@ -245,6 +254,7 @@ Matrix3 operator*(Matrix3 &left, Matrix3 &right) } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + template Matrix3& operator/=(Matrix3 &left, U right) { @@ -261,6 +271,7 @@ Matrix3 operator/(Matrix3 left, U right) {left[1][0] / right, left[1][1] / right, left[1][2] / right}, {left[2][0] / right, left[2][1] / right, left[2][2] / right} }; } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////// -- cgit v1.2.3