#include <muu/plane.h>
template <typename Scalar>
plane struct
A plane.
Template parameters | |
---|---|
Scalar | The plane's scalar component type. Must be a floating-point type. |
Public types
-
using constants = muu::
constants<plane> - Compile-time plane constants.
- using scalar_type = Scalar
- The plane's scalar type.
-
using vector_type = vector<scalar_
type, 3> - The three-dimensional muu::
vector with the same scalar_ type as the plane.
Public static functions
-
static auto from_triangle(const vector_
type& p0, const vector_ type& p1, const vector_ type& p2) -> plane constexpr noexcept - Constructs a plane from a triangle.
-
static auto from_triangle(const triangle<scalar_
type>& tri) -> plane constexpr noexcept - Constructs a plane from a triangle.
Constructors, destructors, conversion operators
- plane() defaulted noexcept
- Default constructor. Values are not initialized.
- plane(const plane&) defaulted constexpr noexcept
- Copy constructor.
-
plane(const vector_
type& n, scalar_ type d) constexpr noexcept - Constructs a plane from
n
andd
terms. -
plane(const vector_
type& position, const vector_ type& direction) constexpr noexcept - Constructs a plane from a position and normal direction.
-
plane(const vector_
type& p0, const vector_ type& p1, const vector_ type& p2) constexpr noexcept - Constructs a plane from a triangle.
-
plane(const triangle<scalar_
type>& tri) explicit constexpr noexcept - Constructs a plane from a triangle.
-
template <typename S>plane(const plane<S>& p) explicit constexpr noexcept
- Converting constructor.
-
template <typename T>plane(const T& obj) constexpr noexcept
- Constructs a plane from an implicitly bit-castable type.
Public functions
Public variables
-
vector_
type normal - The plane's normal direction.
-
scalar_
type d - The
d
term of the plane equation.
Containment
-
static auto contains(const plane& p,
const vector_
type& point, scalar_ type epsilon = default_ epsilon<scalar_ type>) -> bool constexpr noexcept - Returns true if a plane contains a point.
-
auto contains(const vector_
type& point, scalar_ type epsilon = default_ epsilon<scalar_ type>) const -> bool constexpr noexcept - Returns true if the plane contains a point.
Distance and projection
-
static auto distance(const plane& p,
const vector_
type& point) -> scalar_ type constexpr noexcept - Returns the unsigned distance of a point from a plane.
-
static auto origin(const plane& p) -> vector_
type constexpr noexcept - Returns the 'origin' (basis point) of a plane.
-
static auto project(const plane& p,
const vector_
type& point) -> vector_ type constexpr noexcept - Returns the projection of a point onto a plane.
-
static auto project(const plane& p,
const line_
segment<scalar_ type>& seg) -> line_ segment<scalar_ type> constexpr noexcept - Returns the projection of a line segment onto a plane.
-
template <typename... T>static auto same_side(const plane& p, const vector_
type& point1, const vector_ type& point2, const T&... pointN) -> bool constexpr noexcept - Returns true if all the given points lie on the same side of a plane.
-
static auto signed_distance(const plane& p,
const vector_
type& point) -> scalar_ type constexpr noexcept - Returns the signed distance of a point from a plane.
-
auto distance(const vector_
type& point) const -> scalar_ type constexpr noexcept - Returns the unsigned distance of a point from the plane.
-
auto origin() const -> vector_
type constexpr noexcept - Returns the 'origin' (basis point) of the plane.
-
auto project(const vector_
type& point) const -> vector_ type constexpr noexcept - Returns the projection of a point onto the plane.
-
auto project(const line_
segment<scalar_ type>& seg) const -> line_ segment<scalar_ type> constexpr noexcept - Returns the projection of a line segment onto the plane.
-
template <typename... T>auto same_side(const vector_
type& point1, const vector_ type& point2, const T&... pointN) const -> bool constexpr noexcept - Returns true if all the given points lie on the same side of the plane.
-
auto signed_distance(const vector_
type& point) const -> scalar_ type constexpr noexcept - Returns the signed distance of a point from the plane.
Equality (approximate)
-
template <typename T>static auto approx_equal(const plane& p1, const plane<T>& p2, epsilon_
type<scalar_ type, T> epsilon = default_ epsilon<scalar_ type, T>) -> bool constexpr noexcept - Returns true if two planes are approximately equal.
-
static auto approx_zero(const plane& p,
scalar_
type epsilon = default_ epsilon<scalar_ type>) -> bool constexpr noexcept - Returns true if all the scalar components in a plane are approximately equal to zero.
-
template <typename T>auto approx_equal(const plane<T>& p, epsilon_
type<scalar_ type, T> epsilon = default_ epsilon<scalar_ type, T>) const -> bool constexpr noexcept - Returns true if the plane is approximately equal to another.
-
auto approx_zero(scalar_
type epsilon = default_ epsilon<scalar_ type>) const -> bool constexpr noexcept - Returns true if all the scalar components in the plane are approximately equal to zero.
Equality (exact)
- static auto infinity_or_nan(const plane& p) -> bool constexpr noexcept
- Returns true if any of the scalar components of a plane are infinity or NaN.
- static auto zero(const plane& p) -> bool constexpr noexcept
- Returns true if all the scalar components of a plane are exactly zero.
- auto infinity_or_nan() const -> bool constexpr noexcept
- Returns true if any of the scalar components of the plane are infinity or NaN.
- auto zero() const -> bool constexpr noexcept
- Returns true if all the scalar components of the plane are exactly zero.
-
template <typename T>auto operator!=(const plane& lhs, const plane<T>& rhs) -> bool constexpr noexcept
- Returns true if two planes are not exactly equal.
-
template <typename T>auto operator==(const plane& lhs, const plane<T>& rhs) -> bool constexpr noexcept
- Returns true if two planes are exactly equal.
Intersection
-
static auto intersects(const plane& p,
const line_
segment<scalar_ type>& seg) -> bool constexpr noexcept - Returns true if a plane intersects a line segment.
-
static auto intersects(const plane& p,
const bounding_
box<scalar_ type>& bb) -> bool constexpr noexcept - Returns true if a plane intersects a bounding box.
-
auto intersects(const line_
segment<scalar_ type>& seg) const -> bool constexpr noexcept - Returns true if the plane intersects a line segment.
-
auto intersects(const bounding_
box<scalar_ type>& bb) const -> bool constexpr noexcept - Returns true if the plane intersects a bounding box.
Normalization
- static auto normalize(const plane& p) -> plane constexpr noexcept
- Normalizes a plane.
- static auto normalized(const plane& p) -> bool constexpr noexcept
- Returns true if a plane is normalized.
- auto normalize() -> plane& constexpr noexcept
- Normalizes the plane (in-place).
- auto normalized() const -> bool constexpr noexcept
- Returns true if the plane is normalized.
Scalar accessors
-
auto data() -> scalar_
type* constexpr noexcept - Returns a pointer to the first scalar component in the plane.
-
auto data() const -> constscalar_
type* constexpr noexcept - Returns a pointer to the first scalar component in the plane.
Transformation
-
static auto transform(const plane& p,
const matrix<scalar_
type, 4, 4>& tx) -> plane constexpr noexcept - Transforms a plane from one coordinate space to another.
-
auto transform(const matrix<scalar_
type, 4, 4>& tx) -> plane& constexpr noexcept - Transforms the plane from one coordinate space to another (in-place).
Friends
-
template <typename Char, typename Traits>auto operator<<(std::
basic_ostream<Char, Traits>& os, const plane& p) -> std:: basic_ostream<Char, Traits>& - Writes a plane out to a text stream.
Function documentation
template <typename Scalar>
template <typename T>
muu::plane::plane(const T& obj) constexpr noexcept
template <typename T>
Constructs a plane from an implicitly bit-castable type.
Template parameters | |
---|---|
T | A bit-castable type. |
template <typename Scalar>
template <typename... T>
static bool muu::plane::same_side(const plane& p,
const vector_ type& point1,
const vector_ type& point2,
const T&... pointN) constexpr noexcept
template <typename... T>
Returns true if all the given points lie on the same side of a plane.
template <typename Scalar>
template <typename... T>
bool muu::plane::same_side(const vector_ type& point1,
const vector_ type& point2,
const T&... pointN) const constexpr noexcept
template <typename... T>
Returns true if all the given points lie on the same side of the plane.
template <typename Scalar>
bool muu::plane::zero() const constexpr noexcept
Returns true if all the scalar components of the plane are exactly zero.
template <typename Scalar>
template <typename T>
bool muu::plane::operator!=(const plane& lhs,
const plane<T>& rhs) constexpr noexcept
template <typename T>
Returns true if two planes are not exactly equal.
template <typename Scalar>
template <typename T>
bool muu::plane::operator==(const plane& lhs,
const plane<T>& rhs) constexpr noexcept
template <typename T>
Returns true if two planes are exactly equal.
template <typename Scalar>
static plane muu::plane::transform(const plane& p,
const matrix<scalar_ type, 4, 4>& tx) constexpr noexcept
Transforms a plane from one coordinate space to another.
Parameters | |
---|---|
p | The plane to transform. |
tx | The transform to apply. |
Returns | Returns the plane transformed into the new coordinate space. |
template <typename Scalar>
plane& muu::plane::transform(const matrix<scalar_ type, 4, 4>& tx) constexpr noexcept
Transforms the plane from one coordinate space to another (in-place).
Parameters | |
---|---|
tx | The transform to apply. |
Returns | A reference to the plane. |
Variable documentation
template <typename Scalar>
vector_ type muu::plane::normal
The plane's normal direction.