compro_library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub siro53/compro_library

:heavy_check_mark: geometry/is-in-circle.hpp

Depends on

Required by

Verified with

Code

#pragma once

#include "circle.hpp"

namespace geometry {
    // 点pが円cの内部(円周上も含む)に入っているかどうか
    inline bool isInCircle(const Circle &c, const Point &p) {
        D d = std::abs(c.p - p);
        return (equal(d, c.r) || d < c.r - EPS);
    }
} // namespace geometry
#line 2 "geometry/is-in-circle.hpp"

#line 2 "geometry/circle.hpp"

#line 2 "geometry/base.hpp"

#include <cmath>
#include <complex>

namespace geometry {
    // Point : 複素数型を位置ベクトルとして扱う
    // 実軸(real)をx軸、挙軸(imag)をy軸として見る
    using D = long double;
    using Point = std::complex<D>;
    const D EPS = 1e-7;
    const D PI = std::acos(D(-1));

    inline bool equal(const D &a, const D &b) { return std::fabs(a - b) < EPS; }
} // namespace geometry
#line 4 "geometry/circle.hpp"

namespace geometry {
    // Circle : 円を表す構造体
    // pが中心の位置ベクトル、rは半径
    struct Circle {
        Point p;
        D r;

        Circle() = default;

        Circle(Point p, D r) : p(p), r(r) {}
    };
} // namespace geometry
#line 4 "geometry/is-in-circle.hpp"

namespace geometry {
    // 点pが円cの内部(円周上も含む)に入っているかどうか
    inline bool isInCircle(const Circle &c, const Point &p) {
        D d = std::abs(c.p - p);
        return (equal(d, c.r) || d < c.r - EPS);
    }
} // namespace geometry
Back to top page