Sun, 19 Jan 2020 14:25:43 +0200
added license
| 24 | 1 | /* | 
| 2 | * LDForge: LDraw parts authoring CAD | |
| 3 | * Copyright (C) 2013 - 2020 Teemu Piippo | |
| 4 | * | |
| 5 | * This program is free software: you can redistribute it and/or modify | |
| 6 | * it under the terms of the GNU General Public License as published by | |
| 7 | * the Free Software Foundation, either version 3 of the License, or | |
| 8 | * (at your option) any later version. | |
| 9 | * | |
| 10 | * This program is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | * GNU General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU General Public License | |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 17 | */ | |
| 18 | ||
| 20 | 19 | #pragma once | 
| 20 | #include <cmath> | |
| 21 | ||
| 22 | namespace math | |
| 23 | { | |
| 24 | using std::abs; | |
| 25 | using std::sqrt; | |
| 26 | using std::sin; | |
| 27 | using std::cos; | |
| 28 | using std::tan; | |
| 29 | using std::atan; | |
| 30 | using std::atan2; | |
| 31 | using std::acos; | |
| 32 | using std::asin; | |
| 33 | using std::exp; | |
| 34 | using std::log; | |
| 35 | using std::log10; | |
| 36 | using std::hypot; | |
| 37 | using std::floor; | |
| 38 | using std::ceil; | |
| 39 | using std::trunc; | |
| 40 | using std::round; | |
| 41 | template<typename T, typename... Rest> | |
| 42 | inline auto hypot(T&& x, Rest&&... rest) | |
| 43 | { | |
| 44 | return math::hypot(x, math::hypot(rest...)); | |
| 45 | } | |
| 46 | template<typename T, typename... Rest> | |
| 47 | const T& max(const T& x, const T& y) | |
| 48 | { | |
| 49 | if (x > y) | |
| 50 | return x; | |
| 51 | else | |
| 52 | return y; | |
| 53 | } | |
| 54 | template<typename T, typename... Rest> | |
| 55 | const T& max(const T& x, const T& y, Rest&&... rest) | |
| 56 | { | |
| 57 | return math::max(x, math::max(y, rest...)); | |
| 58 | } | |
| 59 | template<typename T, typename... Rest> | |
| 60 | const T& min(const T& x, const T& y) | |
| 61 | { | |
| 62 | if (x < y) | |
| 63 | return x; | |
| 64 | else | |
| 65 | return y; | |
| 66 | } | |
| 67 | template<typename T, typename... Rest> | |
| 68 | const T& min(const T& x, const T& y, Rest&&... rest) | |
| 69 | { | |
| 70 | return math::min(x, math::min(y, rest...)); | |
| 71 | } | |
| 72 | constexpr double infinity = std::numeric_limits<double>::infinity(); | |
| 73 | constexpr long double pi = M_PIl; | |
| 74 | } |