Nebula
Loading...
Searching...
No Matches
Math::sphere Class Reference

#include <sphere.h>

Detailed Description

A 3-dimensional sphere.

Public Member Functions

 sphere ()
 default constructor
 
 sphere (const point &_p, scalar _r)
 pos/radius constructor
 
 sphere (scalar _x, scalar _y, scalar _z, scalar _r)
 x,y,z,r constructor
 
 sphere (const sphere &rhs)
 copy constructor
 
void set (const point &_p, scalar _r)
 set position and radius
 
void set (scalar _x, scalar _y, scalar _z, scalar _r)
 set x,y,z, radius
 
bool inside (const bbox &box) const
 return true if box is completely inside sphere
 
bool intersects (const sphere &s) const
 check if 2 spheres overlap
 
bool intersects (const bbox &box) const
 check if sphere intersects box
 
bool intersects_ray (const line &l) const
 check if sphere intersects ray
 
bool intersect_sweep (const vector &va, const sphere &sb, const vector &vb, scalar &u0, scalar &u1) const
 check if 2 moving sphere have contact
 
rectangle< scalarproject_screen_rh (const mat4 &modelView, const mat4 &projection, scalar nearZ) const
 project sphere to screen rectangle (right handed coordinate system)
 
ClipStatus::Type clipstatus (const bbox &box) const
 get clip status of box against sphere
 

Static Public Member Functions

static vec3 random_point_on_unit_sphere ()
 generate a random point on a unit sphere
 

Public Attributes

point p
 
scalar r
 

Constructor & Destructor Documentation

◆ sphere() [1/4]

Math::sphere::sphere ( )
inline

default constructor

◆ sphere() [2/4]

Math::sphere::sphere ( const point & _p,
scalar _r )
inline

pos/radius constructor

◆ sphere() [3/4]

Math::sphere::sphere ( scalar _x,
scalar _y,
scalar _z,
scalar _r )
inline

x,y,z,r constructor

◆ sphere() [4/4]

Math::sphere::sphere ( const sphere & rhs)
inline

copy constructor

Member Function Documentation

◆ clipstatus()

ClipStatus::Type Math::sphere::clipstatus ( const bbox & box) const
inline

get clip status of box against sphere

Get the clip status of a box against this sphere.

Inside means: the box is completely inside the sphere.

◆ inside()

bool Math::sphere::inside ( const bbox & box) const
inline

return true if box is completely inside sphere

Return true if the bounding box is inside the sphere.

◆ intersect_sweep()

bool Math::sphere::intersect_sweep ( const vector & va,
const sphere & sb,
const vector & vb,
scalar & u0,
scalar & u1 ) const

check if 2 moving sphere have contact

Check if 2 moving spheres have contact.

Taken from "Simple Intersection Tests For Games" article in Gamasutra, Oct 18 1999

Parameters
va[in] distance travelled by 'this'
sb[in] the other sphere
vb[in] distance travelled by sb
u0[out] normalized intro contact
u1[out] normalized outro contact

◆ intersects() [1/2]

bool Math::sphere::intersects ( const bbox & box) const

check if sphere intersects box

Check if sphere intersects with box.

Taken from "Simple Intersection Tests For Games", Gamasutra, Oct 18 1999

◆ intersects() [2/2]

bool Math::sphere::intersects ( const sphere & s) const
inline

check if 2 spheres overlap

◆ intersects_ray()

bool Math::sphere::intersects_ray ( const line & l) const

check if sphere intersects ray

◆ project_screen_rh()

rectangle< scalar > Math::sphere::project_screen_rh ( const mat4 & view,
const mat4 & projection,
scalar nearZ ) const

project sphere to screen rectangle (right handed coordinate system)

Project the sphere (defined in global space) to a screen space rectangle, given the current View and Projection matrices.

The method assumes that the sphere is at least partially visible.

◆ random_point_on_unit_sphere()

vec3 Math::sphere::random_point_on_unit_sphere ( )
static

generate a random point on a unit sphere

◆ set() [1/2]

void Math::sphere::set ( const point & _p,
scalar _r )
inline

set position and radius

◆ set() [2/2]

void Math::sphere::set ( scalar _x,
scalar _y,
scalar _z,
scalar _r )
inline

set x,y,z, radius

Member Data Documentation

◆ p

point Math::sphere::p

◆ r

scalar Math::sphere::r

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