42#ifndef UFO_GEOMETRY_PLANE_HPP
43#define UFO_GEOMETRY_PLANE_HPP
46#include <ufo/numeric/vec.hpp>
54#include "ufo/geometry/aabb.hpp"
68template <std::
size_t Dim = 3, std::
floating_po
int T =
float>
85 constexpr Plane() noexcept = default;
116 auto aux = v_2 - v_1;
131 auto aux_1 = v_1 - v_2;
132 auto aux_2 = v_3 - v_2;
140 template <std::convertible_to<T> U>
150 [[nodiscard]]
static constexpr std::size_t
dimension() noexcept {
return Dim; }
173 [[nodiscard]]
constexpr T
volume() const noexcept {
return T(0); }
179 [[nodiscard]]
constexpr T
diameter() const noexcept
181 return std::numeric_limits<T>::infinity();
199template <std::
size_t Dim, std::
floating_po
int T>
202 return out <<
"Normal: [" << plane.
normal <<
"], Distance: " << plane.
distance;
205using Plane3f = Plane<3, float>;
206using Plane3d = Plane<3, double>;
210template <std::
size_t Dim, std::
floating_po
int T>
211 requires std::formattable<T, char>
212struct std::formatter<
ufo::Plane<Dim, T>> {
213 constexpr auto parse(std::format_parse_context& ctx) {
return ctx.begin(); }
217 return std::format_to(ctx.out(),
"Normal: [{}], Distance: {}", plane.
normal,
constexpr T dot(Quat< T > const &a, Quat< T > const &b) noexcept
Computes the four-component dot product a.w*b.w + a.x*b.x + a.y*b.y + a.z*b.z.
All vision-related classes and functions.
constexpr Quat< T > normalize(Quat< T > const &q) noexcept
Returns a unit quaternion in the same direction as q.
constexpr Quat< T > cross(Quat< T > const &q1, Quat< T > const &q2) noexcept
Computes the Hamilton cross product of two quaternions.
Axis-Aligned Bounding Box (AABB) in Dim-dimensional space.
bool operator==(Plane const &) const =default
Equality operator.
constexpr T diameter() const noexcept
Returns the diameter of the plane.
Vec< Dim, T > normal
The normal of the plane.
constexpr bool isDegenerate() const noexcept
Returns whether the plane is degenerate.
T distance
The distance from the origin.
constexpr Plane(Plane< Dim, U > const &other) noexcept
Conversion operator to a plane with a different scalar type.
constexpr Plane(Vec< Dim, T > const &v_1, Vec< Dim, T > const &v_2) noexcept
Constructs a plane from two points.
constexpr T volume() const noexcept
Returns the volume of the plane.
static constexpr std::size_t dimension() noexcept
Returns the dimensionality of the plane.
constexpr Plane(Vec< Dim, T > const &v_1, Vec< Dim, T > const &v_2, Vec< Dim, T > const &v_3) noexcept
Constructs a plane from three points.
constexpr AABB< Dim, T > aabb() const noexcept
Returns the AABB of the plane.
constexpr Plane() noexcept=default
Default constructor.
constexpr Plane(Vec< Dim, T > const &normal, T distance) noexcept
Constructs a plane from a normal and a distance.
A fixed-size arithmetic vector of up to 4 dimensions.