Browse Source

doc: cross-link intersection and bounding volume calculation algos.

pull/559/head
Vladimír Vondruš 4 years ago
parent
commit
90b53798c2
  1. 12
      src/Magnum/Math/Intersection.h
  2. 9
      src/Magnum/MeshTools/BoundingVolume.h

12
src/Magnum/Math/Intersection.h

@ -82,7 +82,8 @@ point @f$ \boldsymbol{p} @f$ intersects with a sphere of a center
\end{array} \end{array}
@f] @f]
@see @ref Distance::pointPointSquared(), @ref Vector::dot(), @ref pow(T) @see @ref Distance::pointPointSquared(), @ref Vector::dot(), @ref pow(T),
@see @ref MeshTools::boundingSphereBouncingBubble()
*/ */
template<class T> inline bool pointSphere(const Vector3<T>& point, const Vector3<T>& sphereCenter, T sphereRadius) { template<class T> inline bool pointSphere(const Vector3<T>& point, const Vector3<T>& sphereCenter, T sphereRadius) {
return (sphereCenter - point).dot() <= sphereRadius*sphereRadius; return (sphereCenter - point).dot() <= sphereRadius*sphereRadius;
@ -215,7 +216,7 @@ condition for whether the plane is intersecting the box: @f[
for plane normal @f$ \boldsymbol n @f$ and determinant @f$ w @f$. for plane normal @f$ \boldsymbol n @f$ and determinant @f$ w @f$.
@see @ref aabbFrustum() @see @ref aabbFrustum(), @ref MeshTools::boundingRange()
*/ */
template<class T> bool rangeFrustum(const Range3D<T>& range, const Frustum<T>& frustum); template<class T> bool rangeFrustum(const Range3D<T>& range, const Frustum<T>& frustum);
@ -234,6 +235,7 @@ a ray inverse, when doing multiple ray / range intersections (for example
when traversing an AABB tree). The algorithm implemented is a version of the when traversing an AABB tree). The algorithm implemented is a version of the
classical slabs algorithm, see *Listing 1* in classical slabs algorithm, see *Listing 1* in
[Majercik et al.](http://jcgt.org/published/0007/03/04/). [Majercik et al.](http://jcgt.org/published/0007/03/04/).
@see @ref MeshTools::boundingRange()
*/ */
template<class T> bool rayRange(const Vector3<T>& rayOrigin, const Vector3<T>& inverseRayDirection, const Range3D<T>& range); template<class T> bool rayRange(const Vector3<T>& rayOrigin, const Vector3<T>& inverseRayDirection, const Range3D<T>& range);
@ -261,6 +263,7 @@ template<class T> bool aabbFrustum(const Vector3<T>& aabbCenter, const Vector3<T
Checks for each plane of the frustum whether the sphere is behind the plane Checks for each plane of the frustum whether the sphere is behind the plane
(the points distance larger than the sphere's radius) using (the points distance larger than the sphere's radius) using
@ref Distance::pointPlaneScaled(). @ref Distance::pointPlaneScaled().
@see @ref MeshTools::boundingSphereBouncingBubble()
*/ */
template<class T> bool sphereFrustum(const Vector3<T>& sphereCenter, T sphereRadius, const Frustum<T>& frustum); template<class T> bool sphereFrustum(const Vector3<T>& sphereCenter, T sphereRadius, const Frustum<T>& frustum);
@ -350,6 +353,8 @@ performs sphere-cone intersection with the zero-origin -Z axis-aligned cone.
The @p sinAngle and @p tanAngle can be precomputed like this: The @p sinAngle and @p tanAngle can be precomputed like this:
@snippet MagnumMath.cpp Intersection-sinAngle-tanAngle @snippet MagnumMath.cpp Intersection-sinAngle-tanAngle
@see @ref MeshTools::boundingSphereBouncingBubble()
*/ */
template<class T> bool sphereConeView(const Vector3<T>& sphereCenter, T sphereRadius, const Matrix4<T>& coneView, T sinAngle, T tanAngle); template<class T> bool sphereConeView(const Vector3<T>& sphereCenter, T sphereRadius, const Matrix4<T>& coneView, T sinAngle, T tanAngle);
@ -389,6 +394,8 @@ testing whether the origin of the original cone intersects the sphere. The
@p sinAngle and @p tanAngleSqPlusOne parameters can be precomputed like this: @p sinAngle and @p tanAngleSqPlusOne parameters can be precomputed like this:
@snippet MagnumMath.cpp Intersection-sinAngle-tanAngleSqPlusOne @snippet MagnumMath.cpp Intersection-sinAngle-tanAngleSqPlusOne
@see @ref MeshTools::boundingSphereBouncingBubble()
*/ */
template<class T> bool sphereCone(const Vector3<T>& sphereCenter, T sphereRadius, const Vector3<T>& coneOrigin, const Vector3<T>& coneNormal, T sinAngle, T tanAngleSqPlusOne); template<class T> bool sphereCone(const Vector3<T>& sphereCenter, T sphereRadius, const Vector3<T>& coneOrigin, const Vector3<T>& coneNormal, T sinAngle, T tanAngleSqPlusOne);
@ -447,6 +454,7 @@ template<class T> bool aabbCone(const Vector3<T>& aabbCenter, const Vector3<T>&
Precomputes a portion of the intersection equation from @p coneAngle and calls Precomputes a portion of the intersection equation from @p coneAngle and calls
@ref rangeCone(const Range3D<T>&, const Vector3<T>&, const Vector3<T>&, T). @ref rangeCone(const Range3D<T>&, const Vector3<T>&, const Vector3<T>&, T).
@see @ref MeshTools::boundingRange()
*/ */
template<class T> bool rangeCone(const Range3D<T>& range, const Vector3<T>& coneOrigin, const Vector3<T>& coneNormal, const Rad<T> coneAngle); template<class T> bool rangeCone(const Range3D<T>& range, const Vector3<T>& coneOrigin, const Vector3<T>& coneNormal, const Rad<T> coneAngle);

9
src/Magnum/MeshTools/BoundingVolume.h

@ -43,6 +43,9 @@ namespace Magnum { namespace MeshTools {
@m_since_latest @m_since_latest
Same as @ref Math::minmax(const Corrade::Containers::StridedArrayView1D<const T>&). Same as @ref Math::minmax(const Corrade::Containers::StridedArrayView1D<const T>&).
@see @ref Math::Intersection::rayRange(),
@ref Math::Intersection::rangeFrustum(),
@ref Math::Intersection::rangeCone()
*/ */
MAGNUM_MESHTOOLS_EXPORT Range3D boundingRange(const Containers::StridedArrayView1D<const Vector3>& positions); MAGNUM_MESHTOOLS_EXPORT Range3D boundingRange(const Containers::StridedArrayView1D<const Vector3>& positions);
@ -59,7 +62,11 @@ radius is never below @ref Math::TypeTraits::epsilon(), even for empty or
entirely overlapping lists of points. <em>NaN</em>s are ignored, unless the entirely overlapping lists of points. <em>NaN</em>s are ignored, unless the
first position is <em>NaN</em> in which case it is propagated. Algorithm used: first position is <em>NaN</em> in which case it is propagated. Algorithm used:
* *Bo Tian --- Bouncing Bubble: A fast algorithm for Minimal Enclosing Ball * *Bo Tian --- Bouncing Bubble: A fast algorithm for Minimal Enclosing Ball
problem, 2012, https://www.grin.com/document/204869* problem, 2012, https://www.grin.com/document/204869*.
@see @ref Math::Intersection::pointSphere(),
@ref Math::Intersection::sphereFrustum(),
@ref Math::Intersection::sphereCone(),
@ref Math::Intersection::sphereConeView()
*/ */
MAGNUM_MESHTOOLS_EXPORT Containers::Pair<Vector3, Float> boundingSphereBouncingBubble(const Containers::StridedArrayView1D<const Vector3>& positions); MAGNUM_MESHTOOLS_EXPORT Containers::Pair<Vector3, Float> boundingSphereBouncingBubble(const Containers::StridedArrayView1D<const Vector3>& positions);

Loading…
Cancel
Save