![]() |
Pangolin
Header-only C++20 plane computational geometry library
|
Exact rational number type used when geometric results need fractions. More...
#include "core/bigint.hpp"#include <cmath>#include <iostream>#include <stdexcept>#include <numeric>#include <type_traits>#include <compare>#include <limits>#include <functional>#include <cstdint>#include <utility>#include <concepts>#include <cassert>#include <cstddef>Go to the source code of this file.
Classes | |
| struct | pgl::rational_int< T > |
| The integer type a Rational stores its parts in; any other type is its own answer. More... | |
| struct | pgl::rational_int< Rational< Int > > |
| class | pgl::Rational< Int > |
| Exact rational number class template. More... | |
| struct | pgl::DivisionResult< Number > |
| Default result type for an operation that may require division. More... | |
Namespaces | |
| namespace | pgl |
Concepts | |
| concept | pgl::RationalConcept |
| concept | pgl::NumericType |
Typedefs | |
| template<class T> | |
| using | pgl::rational_int_t = typename rational_int<T>::type |
| template<class T> | |
| using | pgl::grid_number_t |
| The integer type a coordinate rasterizes onto by default. | |
| template<typename T> | |
| using | pgl::to_integer_with_digits_t = typename to_integer_with_digits<T>::type |
| using | pgl::ERational = Rational<BigInt> |
| Exact, overflow-free result used when integral coordinates require fractions. | |
| template<class Number> | |
| using | pgl::division_result_t = typename DivisionResult<Number>::type |
| Convenience alias for DivisionResult. | |
Functions | |
| constexpr int | pgl::round_up_bits (int bits) |
Rational deduction guides | |
Explicit guides that pin class template argument deduction so it is consistent across compilers. The numerator constructor deliberately makes Int non-deducible (see its comment), so CTAD for a bare, non-built-in integer numerator such as pgl::BigInt is supplied here instead: as an explicit guide, its constraint is honored even by compilers (clang 18) that mishandle constraints on the guides synthesized from constrained constructors. Floating-point and built-in integer arguments are excluded so they continue to deduce the default Rational<int64_t> via the other constructors' guides. | |
| template<class T> requires (!pgl::detail::extended_integral<T> && !std::floating_point<T> && !RationalConcept<T>) | |
| pgl::Rational (T) -> Rational< T > | |
Variables | |
| template<class T> | |
| constexpr bool | pgl::is_Rational_v = is_Rational<T>::value |
Exact rational number type used when geometric results need fractions.
Intersections and measurements can opt into Rational to preserve exactness even when integral input coordinates produce non-integral output points.