src/maths.h

Sun, 19 Jan 2020 02:54:48 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 19 Jan 2020 02:54:48 +0200
changeset 22
6da867fa5429
parent 20
cef43609a374
child 24
1a0faaaceb84
permissions
-rw-r--r--

commit work on GL rendering

#pragma once
#include <cmath>

namespace math
{
	using std::abs;
	using std::sqrt;
	using std::sin;
	using std::cos;
	using std::tan;
	using std::atan;
	using std::atan2;
	using std::acos;
	using std::asin;
	using std::exp;
	using std::log;
	using std::log10;
	using std::hypot;
	using std::floor;
	using std::ceil;
	using std::trunc;
	using std::round;
	template<typename T, typename... Rest>
	inline auto hypot(T&& x, Rest&&... rest)
	{
		return math::hypot(x, math::hypot(rest...));
	}
	template<typename T, typename... Rest>
	const T& max(const T& x, const T& y)
	{
		if (x > y)
			return x;
		else
			return y;
	}
	template<typename T, typename... Rest>
	const T& max(const T& x, const T& y, Rest&&... rest)
	{
		return math::max(x, math::max(y, rest...));
	}
	template<typename T, typename... Rest>
	const T& min(const T& x, const T& y)
	{
		if (x < y)
			return x;
		else
			return y;
	}
	template<typename T, typename... Rest>
	const T& min(const T& x, const T& y, Rest&&... rest)
	{
		return math::min(x, math::min(y, rest...));
	}
	constexpr double infinity = std::numeric_limits<double>::infinity();
	constexpr long double pi = M_PIl;
}

mercurial