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-point-on-segment.hpp

Depends on

Required by

Verified with

Code

#pragma once

#include "base.hpp"

namespace geometry {
    // 点cが"線分"ab上にあるか
    inline bool isPointOnSegment(const Point &a, const Point &b, const Point &c) {
        // |a-c| + |c-b| <= |a-b| なら線分上
        return (std::abs(a - c) + std::abs(c - b) < std::abs(a - b) + EPS);
    }
} // namespace geometry
#line 2 "geometry/is-point-on-segment.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/is-point-on-segment.hpp"

namespace geometry {
    // 点cが"線分"ab上にあるか
    inline bool isPointOnSegment(const Point &a, const Point &b, const Point &c) {
        // |a-c| + |c-b| <= |a-b| なら線分上
        return (std::abs(a - c) + std::abs(c - b) < std::abs(a - b) + EPS);
    }
} // namespace geometry
Back to top page