Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::Sphere Class Reference

The Sphere class defines a sphere using a center and a radius using vl::real precision. More...

#include <Sphere.hpp>

Public Member Functions

 Sphere ()
 Constructor: creates a null sphere. More...
 
 Sphere (const vec3 &center, real radius)
 Constructor: creates a sphere with the given center and radius. More...
 
 Sphere (const AABB &aabb)
 Copy-constructor. More...
 
void setNull ()
 Sets the sphere as null. More...
 
bool isNull () const
 Returns true if the sphere is null, ie, if radius is < 0. More...
 
bool isPoint () const
 Returns true if the sphere as radius == 0. More...
 
void setCenter (const vec3 &center)
 Sets the center of the sphere. More...
 
const vec3center () const
 Returns the center of the sphere. More...
 
void setRadius (real radius)
 Sets the radius of the sphere. More...
 
real radius () const
 Returns the radius of the sphere. More...
 
bool includes (const Sphere &other) const
 Returns true if a sphere contains the specified sphere. More...
 
bool operator== (const Sphere &other) const
 Returns true if two spheres are identical. More...
 
bool operator!= (const Sphere &other) const
 Returns true if two spheres are not identical. More...
 
Sphereoperator= (const AABB &aabb)
 Constructs a sphere that contains the specified AABB. More...
 
Sphere operator+ (const Sphere &other)
 Returns a sphere that contains the two specified spheres. More...
 
const Sphereoperator+= (const Sphere &other)
 Enlarges the sphere to contain the specified sphere. More...
 
void transformed (Sphere &out, const mat4 &mat) const
 Returns a sphere that contains the original sphere transformed by the given matrix. More...
 
Sphere transformed (const mat4 &mat) const
 Returns a sphere that contains the original sphere transformed by the given matrix. More...
 

Protected Attributes

vec3 mCenter
 
real mRadius
 

Detailed Description

The Sphere class defines a sphere using a center and a radius using vl::real precision.

Definition at line 43 of file Sphere.hpp.

Constructor & Destructor Documentation

◆ Sphere() [1/3]

vl::Sphere::Sphere ( )
inline

Constructor: creates a null sphere.

Definition at line 47 of file Sphere.hpp.

◆ Sphere() [2/3]

vl::Sphere::Sphere ( const vec3 center,
real  radius 
)
inline

Constructor: creates a sphere with the given center and radius.

Definition at line 50 of file Sphere.hpp.

◆ Sphere() [3/3]

vl::Sphere::Sphere ( const AABB aabb)
inline

Copy-constructor.

Definition at line 53 of file Sphere.hpp.

Member Function Documentation

◆ center()

const vec3& vl::Sphere::center ( ) const
inline

◆ includes()

bool vl::Sphere::includes ( const Sphere other) const
inline

Returns true if a sphere contains the specified sphere.

Definition at line 77 of file Sphere.hpp.

References center(), vl::distance(), isNull(), vl::length(), and radius().

Referenced by operator+=().

◆ isNull()

bool vl::Sphere::isNull ( ) const
inline

Returns true if the sphere is null, ie, if radius is < 0.

Definition at line 59 of file Sphere.hpp.

Referenced by vl::SceneManager::computeBounds(), vl::Camera::computeNearFarOptimizedProjMatrix(), vl::Frustum::cull(), includes(), and operator+=().

◆ isPoint()

bool vl::Sphere::isPoint ( ) const
inline

Returns true if the sphere as radius == 0.

Definition at line 62 of file Sphere.hpp.

◆ operator!=()

bool vl::Sphere::operator!= ( const Sphere other) const
inline

Returns true if two spheres are not identical.

Definition at line 98 of file Sphere.hpp.

References vl::operator==().

◆ operator+()

Sphere vl::Sphere::operator+ ( const Sphere other)
inline

Returns a sphere that contains the two specified spheres.

Definition at line 117 of file Sphere.hpp.

◆ operator+=()

const Sphere& vl::Sphere::operator+= ( const Sphere other)
inline

Enlarges the sphere to contain the specified sphere.

Definition at line 124 of file Sphere.hpp.

References center(), includes(), isNull(), vl::Vector3< T_Scalar >::isNull(), vl::length(), vl::Vector3< T_Scalar >::normalize(), and radius().

◆ operator=()

Sphere& vl::Sphere::operator= ( const AABB aabb)
inline

Constructs a sphere that contains the specified AABB.

Definition at line 104 of file Sphere.hpp.

References vl::AABB::center(), vl::AABB::isNull(), vl::length(), vl::AABB::maxCorner(), and vl::AABB::minCorner().

◆ operator==()

bool vl::Sphere::operator== ( const Sphere other) const
inline

Returns true if two spheres are identical.

Definition at line 92 of file Sphere.hpp.

References mCenter, and mRadius.

◆ radius()

real vl::Sphere::radius ( ) const
inline

◆ setCenter()

void vl::Sphere::setCenter ( const vec3 center)
inline

Sets the center of the sphere.

Definition at line 65 of file Sphere.hpp.

Referenced by vl::SceneManager::computeBounds(), and vlX::import_Sphere().

◆ setNull()

void vl::Sphere::setNull ( )
inline

Sets the sphere as null.

Definition at line 56 of file Sphere.hpp.

Referenced by transformed().

◆ setRadius()

void vl::Sphere::setRadius ( real  radius)
inline

Sets the radius of the sphere.

Definition at line 71 of file Sphere.hpp.

Referenced by vl::SceneManager::computeBounds(), and vlX::import_Sphere().

◆ transformed() [1/2]

void vl::Sphere::transformed ( Sphere out,
const mat4 mat 
) const
inline

Returns a sphere that contains the original sphere transformed by the given matrix.

Definition at line 157 of file Sphere.hpp.

References mCenter, mRadius, setNull(), and vl::sqrt().

Referenced by vl::Camera::computeNearFarOptimizedProjMatrix().

◆ transformed() [2/2]

Sphere vl::Sphere::transformed ( const mat4 mat) const
inline

Returns a sphere that contains the original sphere transformed by the given matrix.

Definition at line 181 of file Sphere.hpp.

Member Data Documentation

◆ mCenter

vec3 vl::Sphere::mCenter
protected

Definition at line 189 of file Sphere.hpp.

Referenced by operator==(), and transformed().

◆ mRadius

real vl::Sphere::mRadius
protected

Definition at line 190 of file Sphere.hpp.

Referenced by operator==(), and transformed().


The documentation for this class was generated from the following file: