55 lines
922 B
C++
55 lines
922 B
C++
#include "utils.h"
|
|
|
|
using namespace Util;
|
|
|
|
rgb::rgb(uint8_t r, uint8_t g, uint8_t b)
|
|
: r(r), g(g), b(b)
|
|
{
|
|
}
|
|
|
|
Vec2i::Vec2i(int x, int y) : x(x), y(y)
|
|
{
|
|
}
|
|
|
|
Vec2f::Vec2f(float x, float y) : x(x), y(y)
|
|
{
|
|
}
|
|
|
|
Vec2d::Vec2d(double x, double y) : x(x), y(y)
|
|
{
|
|
}
|
|
|
|
BigFloat::BigFloat(uint32_t prec)
|
|
{
|
|
mpfr_init2(this->val, prec);
|
|
}
|
|
|
|
void BigFloat::setValue(double val)
|
|
{
|
|
mpfr_set_d(this->val, val, MPFR_RNDD);
|
|
}
|
|
|
|
std::string BigFloat::to_str()
|
|
{
|
|
char buf[this->precision/2];
|
|
|
|
mpfr_snprintf(buf, this->precision/2, "%.60RNf", this->val);
|
|
|
|
std::string s(buf);
|
|
|
|
return s;
|
|
}
|
|
|
|
Vec2bf::Vec2bf(double x, double y, uint32_t prec)
|
|
: x(BigFloat(prec)), y(BigFloat(prec))
|
|
{
|
|
this->x.setValue(x);
|
|
this->y.setValue(y);
|
|
}
|
|
/*
|
|
BigFloat operator + (BigFloat const &f);
|
|
BigFloat operator - (BigFloat const &f);
|
|
BigFloat operator * (BigFloat const &f);
|
|
BigFloat operator / (BigFloat const &f);
|
|
*/
|