Cinder  0.9.1
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cinder::Sphere Class Reference

#include <Sphere.h>

Public Member Functions

 Sphere ()
 
 Sphere (const vec3 &center, float radius)
 
float getRadius () const
 
void setRadius (float radius)
 
vec3 getCenter () const
 
void setCenter (const vec3 &center)
 
bool intersects (const AxisAlignedBox &box) const
 
bool intersects (const Ray &ray) const
 
int intersect (const Ray &ray, float *intersection) const
 
int intersect (const Ray &ray, float *min, float *max) const
 
vec3 closestPoint (const Ray &ray) const
 
Sphere transformed (const mat4 &transform)
 
void calcProjection (float focalLength, vec2 *outCenter, vec2 *outAxisA, vec2 *outAxisB) const
 
void calcProjection (float focalLength, vec2 screenSizePixels, vec2 *outCenter, vec2 *outAxisA, vec2 *outAxisB) const
 
float calcProjectedArea (float focalLength, vec2 screenSizePixels) const
 

Static Public Member Functions

static Sphere calculateBoundingSphere (const std::vector< vec3 > &points)
 
static Sphere calculateBoundingSphere (const vec3 *points, size_t numPoints)
 

Protected Attributes

vec3 mCenter
 
float mRadius
 

Constructor & Destructor Documentation

cinder::Sphere::Sphere ( )
cinder::Sphere::Sphere ( const vec3 &  center,
float  radius 
)

Member Function Documentation

float cinder::Sphere::getRadius ( ) const
void cinder::Sphere::setRadius ( float  radius)
vec3 cinder::Sphere::getCenter ( ) const
void cinder::Sphere::setCenter ( const vec3 &  center)
bool cinder::Sphere::intersects ( const AxisAlignedBox box) const
bool cinder::Sphere::intersects ( const Ray ray) const
int cinder::Sphere::intersect ( const Ray ray,
float *  intersection 
) const
int cinder::Sphere::intersect ( const Ray ray,
float *  min,
float *  max 
) const
vec3 cinder::Sphere::closestPoint ( const Ray ray) const

Returns the closest point on ray to the Sphere. If ray intersects then returns the point of nearest intersection.

Sphere cinder::Sphere::calculateBoundingSphere ( const std::vector< vec3 > &  points)
static
Sphere cinder::Sphere::calculateBoundingSphere ( const vec3 *  points,
size_t  numPoints 
)
static
Sphere cinder::Sphere::transformed ( const mat4 &  transform)

Converts sphere to another coordinate system. Note that it will not return correct results if there are non-uniform scaling, shears, or other unusual transforms in transform.

void cinder::Sphere::calcProjection ( float  focalLength,
vec2 *  outCenter,
vec2 *  outAxisA,
vec2 *  outAxisB 
) const

Calculates the projection of the Sphere (an oriented ellipse) given focalLength. Returns false if calculation failed, rendering only outCenter correct. Algorithm due to Iñigo Quilez.

void cinder::Sphere::calcProjection ( float  focalLength,
vec2  screenSizePixels,
vec2 *  outCenter,
vec2 *  outAxisA,
vec2 *  outAxisB 
) const

Calculates the projection of the Sphere (an oriented ellipse) given focalLength. Algorithm due to Iñigo Quilez.

float cinder::Sphere::calcProjectedArea ( float  focalLength,
vec2  screenSizePixels 
) const

Calculates the projected area of the Sphere given focalLength and screen size in pixels. Algorithm due to Iñigo Quilez.

Member Data Documentation

vec3 cinder::Sphere::mCenter
protected
float cinder::Sphere::mRadius
protected

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