2#ifndef LIBSBX_MATH_PLANE_HPP_
3#define LIBSBX_MATH_PLANE_HPP_
6#include <libsbx/math/vector3.hpp>
16 using value_type = Type;
23 _distance{distance} { }
27 _distance{
plane.w()} { }
29 auto normal()
const noexcept ->
const vector_type& {
33 auto distance()
const noexcept -> value_type {
37 auto distance_to_point(
const vector_type& point)
const noexcept -> value_type {
38 return math::vector3::dot(_normal, point) + _distance;
42 const auto length = _normal.
length();
56 auto ray_intersect(
const sbx::math::ray&
ray) -> std::optional<sbx::math::vector3> {
57 const auto denominator = sbx::math::vector3::dot(_normal,
ray.
direction());
63 const auto t = -distance_to_point(
ray.
origin()) / denominator;
Definition: vector4.hpp:24
constexpr auto length() const noexcept -> length_type
Returns the length of the vector.
Definition: vector.ipp:202
3D ray with normalized direction.
Definition: ray.hpp:37
auto direction() const -> const vector3 &
Returns the ray direction.
Definition: ray.cpp:18
auto point_at(const std::float_t t) const -> vector3
Computes a point along the ray at parameter t.
Definition: ray.cpp:22
auto origin() const -> const vector3 &
Returns the ray origin.
Definition: ray.cpp:14
Core numeric concepts and type traits.
Ray type for geometric queries.
Definition: traits.hpp:11