This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub Luzhiled/comp-geometry
#include "src/real-geometry/angle/get-smaller-angle.hpp"
#pragma once #include "src/real-geometry/class/point.hpp" #include "src/real-geometry/common/const/pi.hpp" #include <algorithm> #include <cmath> namespace geometry { template< typename R > R get_smaller_angle(const point &a, const point &b, const point &c) { const point u(a - b), v(c - b); R alpha = std::atan2(u.y(), u.x()); R beta = std::atan2(v.y(), v.x()); if (alpha > beta) std::swap(alpha, beta); R theta = beta - alpha; return std::min(theta, 2 * pi() - theta); } }
#line 2 "src/real-geometry/angle/get-smaller-angle.hpp" #line 2 "src/real-geometry/class/point.hpp" #line 2 "src/real-geometry/class/vector.hpp" #include <complex> #include <iostream> namespace geometry { template< typename R > class vec2d : public std::complex< R > { using complex = std::complex< R >; public: using complex::complex; vec2d(const complex &c): complex::complex(c) {} const R x() const { return this->real(); } const R y() const { return this->imag(); } friend vec2d operator*(const vec2d &v, const R &k) { return vec2d(v.x() * k, v.y() * k); } friend vec2d operator*(const R &k, const vec2d &v) { return vec2d(v.x() * k, v.y() * k); } friend std::istream &operator>>(std::istream &is, vec2d &v) { R x, y; is >> x >> y; v = vec2d(x, y); return is; } }; } #line 4 "src/real-geometry/class/point.hpp" #include <vector> namespace geometry { template< typename R > using point = vec2d<R>; template< typename R > using points = std::vector< point< R > >; } #line 2 "src/real-geometry/common/const/pi.hpp" #line 2 "src/real-geometry/common/float-alias.hpp" namespace geometry { using f80 = long double; using f64 = double; } #line 4 "src/real-geometry/common/const/pi.hpp" #include <cmath> namespace geometry { static f80 pi() { static const f80 PI = acosl(-1); // no need `std::`. (?) return PI; } } #line 5 "src/real-geometry/angle/get-smaller-angle.hpp" #include <algorithm> #line 8 "src/real-geometry/angle/get-smaller-angle.hpp" namespace geometry { template< typename R > R get_smaller_angle(const point &a, const point &b, const point &c) { const point u(a - b), v(c - b); R alpha = std::atan2(u.y(), u.x()); R beta = std::atan2(v.y(), v.x()); if (alpha > beta) std::swap(alpha, beta); R theta = beta - alpha; return std::min(theta, 2 * pi() - theta); } }