#include <muu/plane.h>
template <typename Scalar>
muu::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 and d 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

auto operator=(const plane&) -> plane& defaulted constexpr noexcept
Copy-assigment operator.

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

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

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

Returns true if all the given points lie on the same side of the plane.

template <typename Scalar>
static bool muu::plane::zero(const plane& p) constexpr noexcept

Returns true if all the scalar components of a plane are exactly zero.

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

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

Returns true if two planes are exactly equal.

template <typename Scalar>
static plane muu::plane::normalize(const plane& p) constexpr noexcept

Normalizes a plane.

Parameters
p The plane to normalize.
Returns A normalized copy of the input plane.

template <typename Scalar>
plane& muu::plane::normalize() constexpr noexcept

Normalizes the plane (in-place).

Returns A reference to the plane.

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.