/* The GPLv3 License (GPLv3) Copyright (c) 2022 Akos Horvath This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #pragma once #include #include "./mpreal.h" #include #include namespace Util { typedef struct { double r; double g; double b; } rgb; typedef struct { double h; // ∈ [0, 360] double s; // ∈ [0, 1] double v; // ∈ [0, 1] } hsv; class Vec2i { public: int x; int y; Vec2i(int x, int y); }; class Vec2f { public: float x; float y; Vec2f(float x, float y); }; class Vec2d { public: double x; double y; Vec2d(double x, double y); }; //class BigFloat { //public: // uint32_t precision; // mpfr_t val; // // BigFloat(uint32_t prec); // ~BigFloat(); // static BigFloat BigFloat_d(double d, uint32_t prec); // static BigFloat abs(const BigFloat &bf); // void setValue(double val); // std::string to_str() const; // BigFloat operator / (const BigFloat &f); // // inline BigFloat operator - (const BigFloat &f) const // { // BigFloat res = BigFloat(f.precision); // mpfr_sub(res.val, this->val, f.val, MPFR_RNDD); // // return res; // } // // inline BigFloat operator - (const double d) const // { // // BigFloat bd = BigFloat(this->precision); // // bd.setValue(d); // BigFloat res = BigFloat(this->precision); // mpfr_sub_d(res.val, this->val, d, MPFR_RNDD); // // return res; // } // // inline BigFloat operator * (const BigFloat &f) const // { // BigFloat res = BigFloat(f.precision); // mpfr_mul(res.val, this->val, f.val, MPFR_RNDD); // // return res; // } // // inline BigFloat operator * (const double d) const // { // // BigFloat bd = BigFloat(this->precision); // // bd.setValue(d); // BigFloat res = BigFloat(this->precision); // mpfr_mul_d(res.val, this->val, d, MPFR_RNDD); // // return res; // } // // inline BigFloat operator + (const BigFloat &f) const // { // BigFloat res = BigFloat(f.precision); // mpfr_add(res.val, this->val, f.val, MPFR_RNDD); // // return res; // } // // inline BigFloat operator + (const double d) const // { // // BigFloat bd = BigFloat(this->precision); // // bd.setValue(d); // BigFloat res = BigFloat(this->precision); // mpfr_add_d(res.val, this->val, d, MPFR_RNDD); // // return res; // } // // bool operator < (const BigFloat &f) // { // if (mpfr_cmp(this->val, f.val) < 0) // return true; // return false; // } // // bool operator > (const BigFloat &f) // { // if (mpfr_cmp(this->val, f.val) > 0) // return true; // return false; // } // // bool operator <= (const BigFloat &f) // { // int v = mpfr_cmp(this->val, f.val); // // if (v < 0 || v == 0) // return true; // return false; // } // // bool operator >= (const BigFloat &f) // { // int v = mpfr_cmp(this->val, f.val); // // if (v > 0 || v == 0) // return true; // return false; // } // // bool operator < (const double d) // { // if (mpfr_cmp_d(this->val, d) < 0) // return true; // return false; // } // // bool operator > (const double d) // { // if (mpfr_cmp_d(this->val, d) > 0) // return true; // return false; // } // // bool operator <= (const double d) // { // int v = mpfr_cmp_d(this->val, d); // // //std::cout << "comp: " << v << std::endl; // // if (v < 0 || v == 0) // return true; // return false; // } // // bool operator >= (const double d) // { // int v = mpfr_cmp_d(this->val, d); // // if (v > 0 || v == 0) // return true; // return false; // } //}; void init(uint32_t prec); double linear_interpolate(double v0, double v1, float t); class Vec2mp { public: mpfr::mpreal x; mpfr::mpreal y; Vec2mp(mpfr::mpreal x, mpfr::mpreal y); Vec2mp(double x, double y); }; }