summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-09-04 02:57:57 +0300
committerxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-09-04 02:57:57 +0300
commitca9bbea0a0a3ec98fa6774a9d2c75f01974b0a68 (patch)
treeb79c0a05824603c50fc7513ef82f660b89870087
parent55b7ecc50187f3039bf747c04b68601dfda45a6b (diff)
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
-rw-r--r--Inconsolata-Regular.ttfbin0 -> 84868 bytes
-rw-r--r--LICENSE21
-rw-r--r--LorenzAttractor.cpp2
-rw-r--r--LorenzAttractor.h7
-rw-r--r--README.md48
-rw-r--r--main.cpp12
-rwxr-xr-xrun.sh4
-rw-r--r--vectormath.h15
8 files changed, 60 insertions, 49 deletions
diff --git a/Inconsolata-Regular.ttf b/Inconsolata-Regular.ttf
new file mode 100644
index 0000000..4ea3681
--- /dev/null
+++ b/Inconsolata-Regular.ttf
Binary files 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 <SFML/Graphics.hpp>
+
#include "vectormath.h"
-#include <random>
#include <string>
-#include <SFML/Graphics.hpp>
+#include <random>
class LorenzAttractor
{
@@ -47,7 +48,7 @@ private:
std::vector<std::vector<float>> 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 <SFML/Graphics.hpp>
+#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 <SFML/Graphics.hpp>
+#include <initializer_list>
#include <iostream>
#include <assert.h>
-#include <initializer_list>
#include <math.h>
/////////////////////
@@ -115,7 +114,9 @@ public:
delete[] m_data;
}
};
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
template<typename T>
std::ostream& operator<<(std::ostream &out, Matrix3<T> &m)
{
@@ -128,7 +129,9 @@ std::ostream& operator<<(std::ostream &out, Matrix3<T> &m)
return out;
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
template<typename T>
bool operator==(Matrix3<T> m1, Matrix3<T> m2)
{
@@ -154,7 +157,9 @@ bool operator!=(Matrix3<T> m1, Matrix3<T> m2)
return false;
else return true;
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
template<typename T>
Matrix3<T> operator+(const Matrix3<T> &left, const Matrix3<T> &right)
{
@@ -172,7 +177,9 @@ Matrix3<T>& operator+=(Matrix3<T> &left, const Matrix3<T> &right)
return left;
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
template<typename T>
Matrix3<T> operator-(const Matrix3<T> &left, const Matrix3<T> &right)
{
@@ -200,7 +207,9 @@ Matrix3<T>& operator-(Matrix3<T> &left)
return left;
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
template<typename T, typename U>
Matrix3<T>& operator*=(Matrix3<T> &left, const U &right)
{
@@ -245,6 +254,7 @@ Matrix3<T> operator*(Matrix3<T> &left, Matrix3<T> &right)
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
template<typename T, typename U>
Matrix3<T>& operator/=(Matrix3<T> &left, U right)
{
@@ -261,6 +271,7 @@ Matrix3<T> operator/(Matrix3<T> 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} };
}
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////