HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
line_segment.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
9#pragma once
10
11#include "point.hpp"
12
13namespace hi {
14inline namespace v1 {
15
20public:
21 constexpr line_segment(line_segment const &) noexcept = default;
22 constexpr line_segment(line_segment &&) noexcept = default;
23 constexpr line_segment &operator=(line_segment const &) noexcept = default;
24 constexpr line_segment &operator=(line_segment &&) noexcept = default;
25
26 [[nodiscard]] constexpr line_segment(point3 p, vector3 v) noexcept : _p(p), _v(v) {}
27
28 [[nodiscard]] constexpr line_segment(point3 p0, point3 p1) noexcept : line_segment(p0, p1 - p0) {}
29
30 [[nodiscard]] constexpr point3 origin() const noexcept
31 {
32 return _p;
33 }
34
35 [[nodiscard]] constexpr vector3 direction() const noexcept
36 {
37 return _v;
38 }
39
40 [[nodiscard]] constexpr friend float hypot(line_segment const &rhs) noexcept
41 {
42 return hypot(rhs._v);
43 }
44
45 template<std::size_t I>
46 [[nodiscard]] constexpr friend point3 get(line_segment const &rhs) noexcept
47 {
48 if constexpr (I == 0) {
49 return rhs._p;
50 } else if constexpr (I == 1) {
51 return rhs._p + rhs._v;
52 } else {
54 }
55 }
56
57 [[nodiscard]] constexpr friend point3 midpoint(line_segment const &rhs) noexcept
58 {
59 return rhs._p + rhs._v * 0.5f;
60 }
61
62private:
63 point3 _p;
64 vector3 _v;
65};
66
67
68}}
69
#define hi_static_no_default(...)
This part of the code should not be reachable, unless a programming bug.
Definition assert.hpp:308
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
Line segment.
Definition line_segment.hpp:19