#include <muu/bounding_sphere.h>
template <typename Scalar>
bounding_sphere struct
A bounding sphere.
Template parameters | |
---|---|
Scalar | The bounding sphere's scalar component type. Must be a floating-point type. |
Public types
-
using constants = muu::
constants<bounding_ sphere> - Compile-time bounding sphere constants.
- using scalar_type = Scalar
- The bounding sphere's scalar type.
-
using vector_type = vector<scalar_
type, 3> - The three-dimensional muu::
vector with the same scalar_ type as the bounding sphere.
Constructors, destructors, conversion operators
- bounding_sphere() defaulted noexcept
- Default constructor. Values are not initialized.
-
bounding_sphere(const bounding_
sphere&) defaulted constexpr noexcept - Copy constructor.
-
bounding_sphere(const vector_
type& cen, scalar_ type rad) constexpr noexcept - Constructs a bounding sphere from center and radius values.
-
bounding_sphere(scalar_
type cen_x, scalar_ type cen_y, scalar_ type cen_z, scalar_ type rad) constexpr noexcept - Constructs a bounding sphere from center and radius values.
-
bounding_sphere(scalar_
type rad) explicit constexpr noexcept - Constructs a bounding sphere at the origin.
-
template <typename S>bounding_sphere(const bounding_
sphere<S>& bs) explicit constexpr noexcept - Converting constructor.
-
template <typename T>bounding_sphere(const T& obj) constexpr noexcept
- Constructs a bounding sphere from an implicitly bit-castable type.
Public functions
-
auto operator=(const bounding_
sphere&) -> bounding_ sphere& defaulted constexpr noexcept - Copy-assigment operator.
Public variables
-
vector_
type center - The center of the sphere.
-
scalar_
type radius - The radius of the sphere.
Collision detection
-
static auto contains(const bounding_
sphere& bs, const vector_ type& point) -> bool constexpr noexcept - Returns true if a bounding sphere contains a point.
-
static auto contains(const bounding_
sphere& bs, const vector_ type& start, const vector_ type& end) -> bool constexpr noexcept - Returns true if a bounding sphere contains a line segment.
-
static auto contains(const bounding_
sphere& bb, const line_ segment<scalar_ type>& seg) -> bool constexpr noexcept - Returns true if a bounding sphere contains a line segment.
-
static auto contains(const bounding_
sphere& bs, const vector_ type& p0, const vector_ type& p1, const vector_ type& p2) -> bool constexpr noexcept - Returns true if a bounding sphere contains a triangle.
-
static auto contains(const bounding_
sphere& bs, const triangle<scalar_ type>& tri) -> bool constexpr noexcept - Returns true if a bounding sphere contains a triangle.
-
static auto contains(const bounding_
sphere& outer, const bounding_ sphere& inner) -> bool constexpr noexcept - Returns true if a bounding sphere contains all the points of another bounding sphere.
-
static auto contains(const bounding_
sphere& outer, const bounding_ box<scalar_ type>& inner) -> bool constexpr noexcept - Returns true if a bounding sphere contains all the points of an axis-aligned bounding box.
-
static auto intersects(const bounding_
sphere& bs, const vector_ type& p0, const vector_ type& p1, const vector_ type& p2) -> bool constexpr noexcept - Returns true if a bounding sphere intersects a triangle.
-
static auto intersects(const bounding_
sphere& bs, const triangle<scalar_ type>& tri) -> bool constexpr noexcept - Returns true if a bounding sphere intersects a triangle.
-
static auto intersects(const bounding_
sphere& bs1, const bounding_ sphere& bs2) -> bool constexpr noexcept - Returns true if two bounding spheres intersect.
-
static auto intersects(const bounding_
sphere& bs, const bounding_ box<scalar_ type>& bb) -> bool constexpr noexcept - Returns true if a bounding sphere intersects a bounding box.
-
static auto intersects(const bounding_
sphere& bs, const oriented_ bounding_ box<scalar_ type>& bb) -> bool constexpr noexcept - Returns true if a bounding sphere intersects an oriented bounding box.
-
auto collision_tester() const -> muu::collision_tester<bounding_
sphere> constexpr noexcept - Creates an #muu::collision_tester for this bounding sphere.
-
auto contains(const vector_
type& point) const -> bool constexpr noexcept - Returns true if the bounding sphere contains a point.
-
auto contains(const vector_
type* begin, const vector_ type* end) -> bool constexpr noexcept - Returns true if the bounding sphere contains all the points in an arbitrary collection.
-
auto contains(const line_
segment<scalar_ type>& seg) const -> bool constexpr noexcept - Returns true if the bounding sphere contains a line segment.
-
auto contains(const triangle<scalar_
type>& tri) const -> bool constexpr noexcept - Returns true if the bounding sphere contains a triangle.
-
auto contains(const bounding_
sphere& bs) const -> bool constexpr noexcept - Returns true if the bounding sphere contains all the points of another bounding sphere.
-
auto contains(const bounding_
box<scalar_ type>& bb) const -> bool constexpr noexcept - Returns true if the bounding sphere contains all the points of an axis-aligned bounding box.
-
auto intersects(const triangle<scalar_
type>& tri) const -> bool constexpr noexcept - Returns true if the bounding sphere intersects a triangle.
-
auto intersects(const bounding_
sphere& bs) const -> bool constexpr noexcept - Returns true if two bounding spheres intersect.
-
auto intersects(const bounding_
box<scalar_ type>& bb) const -> bool constexpr noexcept - Returns true if the bounding sphere intersects a bounding box.
-
auto intersects(const oriented_
bounding_ box<scalar_ type>& bb) const -> bool constexpr noexcept - Returns true if the bounding sphere intersects an oriented bounding box.
Equality (approximate)
-
static auto approx_empty(const bounding_
sphere& bs, scalar_ type epsilon = default_ epsilon<scalar_ type>) -> bool constexpr noexcept - Returns true if a bounding sphere has approximately zero volume.
-
template <typename T>static auto approx_equal(const bounding_
sphere& bs1, const bounding_ sphere<T>& bs2, epsilon_ type<scalar_ type, T> epsilon = default_ epsilon<scalar_ type, T>) -> bool constexpr noexcept - Returns true if two bounding spheres are approximately equal.
-
static auto approx_zero(const bounding_
sphere& bs, scalar_ type epsilon = default_ epsilon<scalar_ type>) -> bool constexpr noexcept - Returns true if all the scalar components in a bounding sphere are approximately equal to zero.
-
auto approx_empty(scalar_
type epsilon = default_ epsilon<scalar_ type>) const -> bool constexpr noexcept - Returns true if the bounding sphere has approximately zero volume.
-
template <typename T>auto approx_equal(const bounding_
sphere<T>& bs, epsilon_ type<scalar_ type, T> epsilon = default_ epsilon<scalar_ type, T>) const -> bool constexpr noexcept - Returns true if the bounding sphere 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 bounding sphere are approximately equal to zero.
Equality (exact)
-
static auto degenerate(const bounding_
sphere& bs) -> bool constexpr noexcept - Returns true if a sphere is degenerate (i.e. its radius is less than or equal to zero).
-
static auto empty(const bounding_
sphere& bs) -> bool constexpr noexcept - Returns true if a bounding sphere has exactly zero volume.
-
static auto infinity_or_nan(const bounding_
sphere& bs) -> bool constexpr noexcept - Returns true if any of the scalar components of a bounding sphere are infinity or NaN.
-
static auto zero(const bounding_
sphere& bs) -> bool constexpr noexcept - Returns true if all the scalar components of a bounding sphere are exactly zero.
- auto degenerate() const -> bool constexpr noexcept
- Returns true if the sphere is degenerate (i.e. its radius is less than or equal to zero).
- auto empty() const -> bool constexpr noexcept
- Returns true if the bounding sphere has exactly zero volume.
- auto infinity_or_nan() const -> bool constexpr noexcept
- Returns true if any of the scalar components of the bounding sphere are infinity or NaN.
- auto zero() const -> bool constexpr noexcept
- Returns true if all the scalar components of the bounding sphere are exactly zero.
-
template <typename T>auto operator!=(const bounding_
sphere& lhs, const bounding_ sphere<T>& rhs) -> bool constexpr noexcept - Returns true if two bounding spheres are not exactly equal.
-
template <typename T>auto operator==(const bounding_
sphere& lhs, const bounding_ sphere<T>& rhs) -> bool constexpr noexcept - Returns true if two bounding spheres are exactly equal.
Geometric properties
-
auto density(scalar_
type mass) const -> scalar_ type constexpr noexcept - Calculates the density of this sphere if it had a given mass.
-
auto diameter() const -> scalar_
type constexpr noexcept - Calculates the diameter of the sphere.
-
auto mass(scalar_
type density) const -> scalar_ type constexpr noexcept - Calculates the mass of this sphere if it had a given density.
-
auto volume() const -> scalar_
type constexpr noexcept - Calculates the volume of the sphere.
Point queries
-
auto closest_point(const vector_
type& point) const -> vector_ type constexpr noexcept - Gets point contained by the bounding sphere closest to another arbitrary point.
Scalar accessors
-
auto data() -> scalar_
type* constexpr noexcept - Returns a pointer to the first scalar component in the bounding sphere.
-
auto data() const -> constscalar_
type* constexpr noexcept - Returns a pointer to the first scalar component in the bounding sphere.
Scaling
-
static auto scale(const bounding_
sphere& bs, scalar_ type scale_) -> bounding_ sphere constexpr noexcept - Scales a bounding sphere.
-
auto scale(scalar_
type scale_) -> bounding_ sphere& constexpr noexcept - Scales the bounding sphere (in-place).
Translation
-
static auto translate(const bounding_
sphere& bs, const vector_ type& offset) -> bounding_ sphere constexpr noexcept - Translates a bounding sphere.
-
auto translate(const vector_
type& offset) -> bounding_ sphere& constexpr noexcept - Translates the bounding sphere (in-place).
Friends
-
template <typename Char, typename Traits>auto operator<<(std::
basic_ostream<Char, Traits>& os, const bounding_ sphere& bs) -> std:: basic_ostream<Char, Traits>& - Writes a bounding_
sphere out to a text stream.
Function documentation
template <typename Scalar>
muu::bounding_sphere::bounding_sphere(const vector_ type& cen,
scalar_ type rad) constexpr noexcept
Constructs a bounding sphere from center and radius values.
Parameters | |
---|---|
cen | The center point. |
rad | The radius. |
template <typename Scalar>
muu::bounding_sphere::bounding_sphere(scalar_ type cen_x,
scalar_ type cen_y,
scalar_ type cen_z,
scalar_ type rad) constexpr noexcept
Constructs a bounding sphere from center and radius values.
Parameters | |
---|---|
cen_x | The X component of the center point. |
cen_y | The Y component of the center point. |
cen_z | The Z component of the center point. |
rad | The radius. |
template <typename Scalar>
muu::bounding_sphere::bounding_sphere(scalar_ type rad) explicit constexpr noexcept
Constructs a bounding sphere at the origin.
Parameters | |
---|---|
rad | The radius. |
template <typename Scalar>
template <typename T>
muu::bounding_sphere::bounding_sphere(const T& obj) constexpr noexcept
template <typename T>
Constructs a bounding sphere from an implicitly bit-castable type.
Template parameters | |
---|---|
T | A bit-castable type. |
template <typename Scalar>
static bool muu::bounding_sphere::empty(const bounding_ sphere& bs) constexpr noexcept
Returns true if a bounding sphere has exactly zero volume.
template <typename Scalar>
static bool muu::bounding_sphere::zero(const bounding_ sphere& bs) constexpr noexcept
Returns true if all the scalar components of a bounding sphere are exactly zero.
template <typename Scalar>
bool muu::bounding_sphere::empty() const constexpr noexcept
Returns true if the bounding sphere has exactly zero volume.
template <typename Scalar>
bool muu::bounding_sphere::zero() const constexpr noexcept
Returns true if all the scalar components of the bounding sphere are exactly zero.
template <typename Scalar>
template <typename T>
bool muu::bounding_sphere::operator!=(const bounding_ sphere& lhs,
const bounding_ sphere<T>& rhs) constexpr noexcept
template <typename T>
Returns true if two bounding spheres are not exactly equal.
template <typename Scalar>
template <typename T>
bool muu::bounding_sphere::operator==(const bounding_ sphere& lhs,
const bounding_ sphere<T>& rhs) constexpr noexcept
template <typename T>
Returns true if two bounding spheres are exactly equal.
template <typename Scalar>
static bounding_ sphere muu::bounding_sphere::scale(const bounding_ sphere& bs,
scalar_ type scale_) constexpr noexcept
Scales a bounding sphere.
Parameters | |
---|---|
bs | The bounding sphere to scale. |
scale_ | The amount to scale the sphere radius by. |
Returns | A copy of the input sphere scaled by the given amount. |
template <typename Scalar>
bounding_ sphere& muu::bounding_sphere::scale(scalar_ type scale_) constexpr noexcept
Scales the bounding sphere (in-place).
Parameters | |
---|---|
scale_ | The amount to scale the sphere radius by. |
Returns | A reference to the sphere. |
template <typename Scalar>
static bounding_ sphere muu::bounding_sphere::translate(const bounding_ sphere& bs,
const vector_ type& offset) constexpr noexcept
Translates a bounding sphere.
Parameters | |
---|---|
bs | The bounding sphere to translate. |
offset | An offset to add to the sphere's center position. |
Returns | A copy of the input sphere translated by the given offset. |
template <typename Scalar>
bounding_ sphere& muu::bounding_sphere::translate(const vector_ type& offset) constexpr noexcept
Translates the bounding sphere (in-place).
Parameters | |
---|---|
offset | An offset to add to the sphere's center position. |
Returns | A reference to the sphere. |