1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once


#include <tuple><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "utility/functional.hpp"

#include "geometry/point.hpp"
#include "geometry/line.hpp"
#include "geometry/segment.hpp"


namespace uni {


template<class Point>
struct arrow : segment<Point> {
    using point_type = Point;
    using value_type = typename point_type::value_type;

    constexpr arrow() noexcept = default;

    // p0 -> p1
    constexpr arrow(const point_type& p0, const point_type& p1) noexcept(NO_EXCEPT) { this->_p0 = p0, this->_p1 = p1; }

    constexpr auto relation(const point_type& p) noexcept(NO_EXCEPT);<--- Derived function 'arrow::relation'<--- Derived function 'arrow::relation'
};


template<class Point>
constexpr auto arrow<Point>::relation(const Point& p) noexcept(NO_EXCEPT) {<--- Derived function 'arrow < uni :: point < long double > >::relation'<--- Derived function 'arrow < uni :: point < long double > >::relation'
    if(this->_p0 == p || this->_p1 == p) return positional_relation::on;

    const auto q0 = this->_p1 - this->_p0, q1 = p - this->_p0;

    const auto comp_qr = compare(cross(q0, q1));
    if(comp_qr > 0) return positional_relation::counter_clockwise;
    if(comp_qr < 0) return positional_relation::clockwise;
    if(compare(q0 * q1) < 0) return positional_relation::backward;
    if(compare(std::norm(q0), std::norm(q1)) < 0) return positional_relation::forward;
    return positional_relation::in;
}


} // namespace uni


namespace std {


template<class Point, class C, class S>
auto& operator>>(basic_istream<C, S>& in, uni::arrow<Point>& v) noexcept(NO_EXCEPT) {
    Point x, y; in >> x >> y;
    v = { x, y };
    return in;
}


} // namespace std