42#ifndef UFO_GEOMETRY_LINE_SEGMENT_HPP
43#define UFO_GEOMETRY_LINE_SEGMENT_HPP
46#include <ufo/geometry/aabb.hpp>
47#include <ufo/numeric/vec.hpp>
67template <std::
size_t Dim = 3, std::
floating_po
int T =
float>
108 template <std::convertible_to<T> U>
118 [[nodiscard]]
static constexpr std::size_t
dimension() noexcept {
return Dim; }
159 T eps = std::numeric_limits<T>::epsilon()) const noexcept
177 [[nodiscard]]
constexpr T
volume() const noexcept {
return T(0); }
189template <std::
size_t Dim, std::
floating_po
int T>
195template <std::
size_t Dim, std::
floating_po
int T>
198 return out <<
"Start: [" << ls.
start <<
"], End: [" << ls.
end <<
"]";
201template <std::
floating_po
int T>
202using LineSegment1 = LineSegment<1, T>;
203template <std::
floating_po
int T>
204using LineSegment2 = LineSegment<2, T>;
205template <std::
floating_po
int T>
206using LineSegment3 = LineSegment<3, T>;
207template <std::
floating_po
int T>
208using LineSegment4 = LineSegment<4, T>;
210using LineSegment1f = LineSegment<1, float>;
211using LineSegment2f = LineSegment<2, float>;
212using LineSegment3f = LineSegment<3, float>;
213using LineSegment4f = LineSegment<4, float>;
215using LineSegment1d = LineSegment<1, double>;
216using LineSegment2d = LineSegment<2, double>;
217using LineSegment3d = LineSegment<3, double>;
218using LineSegment4d = LineSegment<4, double>;
222template <std::
size_t Dim, std::
floating_po
int T>
223 requires std::formattable<T, char>
224struct std::formatter<
ufo::LineSegment<Dim, T>> {
225 constexpr auto parse(std::format_parse_context& ctx) {
return ctx.begin(); }
229 return std::format_to(ctx.out(),
"Start: [{}], End: [{}]", ls.
start, ls.
end);
All vision-related classes and functions.
constexpr Vec< Geometry::dimension(), typename Geometry::value_type > max(Geometry const &g)
Returns the maximum coordinate of the minimum spanning axis-aligned bounding box of a geometry.
constexpr T norm(Quat< T > const &q) noexcept
Returns the Euclidean norm sqrt(w² + x² + y² + z²).
constexpr Vec< Geometry::dimension(), typename Geometry::value_type > min(Geometry const &g)
Returns the minimum coordinate of the minimum spanning axis-aligned bounding box of a geometry.
Axis-Aligned Bounding Box (AABB) in Dim-dimensional space.
Line segment in Dim-dimensional space.
constexpr LineSegment(LineSegment const &) noexcept=default
Copy constructor.
Vec< Dim, T > start
The start point of the line segment.
constexpr T diameter() const noexcept
Returns the diameter of the line segment.
constexpr T volume() const noexcept
Returns the volume of the line segment.
constexpr LineSegment() noexcept=default
Default constructor.
constexpr AABB< Dim, T > aabb() const noexcept
Returns the AABB of the line segment.
bool operator==(LineSegment const &) const =default
Equality operator.
Vec< Dim, T > end
The end point of the line segment.
constexpr T length() const noexcept
Returns the length of the line segment.
constexpr LineSegment(LineSegment< Dim, U > const &other) noexcept
Converting constructor from a line segment with a different scalar type.
static constexpr std::size_t dimension() noexcept
Returns the dimensionality of the line segment.
constexpr Vec< Dim, T > center() const noexcept
Returns the center of the line segment.
constexpr Vec< Dim, T > at(T t) const noexcept
Returns the point at parameter t along the line segment.
constexpr bool isDegenerate(T eps=std::numeric_limits< T >::epsilon()) const noexcept
Returns whether the line segment is degenerate.
A fixed-size arithmetic vector of up to 4 dimensions.