diff --git a/Fractal.cpp b/Fractal.cpp index b4bbb5e..7933294 100644 --- a/Fractal.cpp +++ b/Fractal.cpp @@ -22,11 +22,6 @@ void Fractal::setRenderFunction(std::functionhasChanged = true; } -std::complex Fractal::scale_point(std::complex point) { - std::complex aux(point.real() / (double)this->image_width * this->domain.width() + this->domain.x_min, point.imag() / (double)this->image_height * this->domain.height() + domain.y_min); - return aux; -} - sf::Image Fractal::getFrame(){ if (this->hasChanged) { @@ -60,7 +55,7 @@ sf::Image Fractal::getFrame(){ void Fractal::moveTo(int x, int y) { std::complex point(x, y); - point = this->scale_point(point); + point = scale_point(point); this->domain.centralize(point); this->hasChanged = true; } @@ -75,10 +70,5 @@ void Fractal::zoom(double factor, bool invert) { this->hasChanged = true; } -int Fractal::compute_max_iterations(int window_width, double domain_width) { - int max = 50 * std::pow(std::log10(window_width / domain_width), 1.25); - return (max > 0)? max : 0; -} - diff --git a/Fractal.hpp b/Fractal.hpp index 6e42eb0..937e830 100644 --- a/Fractal.hpp +++ b/Fractal.hpp @@ -63,7 +63,7 @@ struct Domain { } - void centralize(std::complex point) { + void centralize(const std::complex& point) { double x_frac = width() / 2; double y_frac = height() / 2; @@ -88,9 +88,15 @@ private: sf::Image frame; bool hasChanged; Domain domain; + + inline std::complex scale_point(const std::complex& point) { + return std::complex(point.real() / (double)this->image_width * this->domain.width() + this->domain.x_min, point.imag() / (double)this->image_height * this->domain.height() + domain.y_min); + } - std::complex scale_point(std::complex point); - int compute_max_iterations(int window_width, double domain_width); + inline int compute_max_iterations(const int& window_width, const double& domain_width) { + int max = 50 * std::pow(std::log10(window_width / domain_width), 1.25); + return (max > 0)? max : 0; + } public: diff --git a/functions.hpp b/functions.hpp index 9486cb4..5c6ed69 100644 --- a/functions.hpp +++ b/functions.hpp @@ -7,7 +7,7 @@ typedef std::complex (*fractal_function)(std::complex, std::complex); template -int fractal_function_template(std::complex point, int max_iterations) { +int fractal_function_template(const std::complex& point, const int& max_iterations) { std::complex z(0); int iter = 0;