Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

# openvrml::bounding_sphere Class Reference

A bounding sphere. More...

Inheritance diagram for openvrml::bounding_sphere:
[legend]

List of all members.

## Public Member Functions
| bounding_sphere ()
| Construct.
virtual | ~bounding_sphere () throw ()
| Destroy.
void | center (const vec3f &c)
| Set the center coordinates.
const vec3f & | center () const
| Get the center coordinates.
void | radius (float r)
| Set the radius.
float | radius () const
| Get the radius.
## Private Member Functions
virtual void | do_maximize ()
| Extend the bounding sphere to infinity.
virtual bool | do_maximized () const
| Whether the bounding_sphere is maximized.
virtual intersection | do_intersect_frustum (const openvrml::frustum &frustum) const
| Intersect this bvolume with a frustum.
virtual void | do_extend (const vec3f &p)
| Extend to enclose `p`.
virtual void | do_extend (const axis_aligned_bounding_box &bbox)
| Extend the bounding volume to enclose `bbox`.
virtual void | do_extend (const bounding_sphere &b)
| Extend this bvolume to enclose the given sphere.
virtual void | do_enclose (const std::vector< vec3f > &points)
| Enclose the given set of points.
virtual void | do_ortho_transform (const mat4f &t)
| Orthographically transform the bounding_sphere by `t`.
virtual void | do_transform (const mat4f &t)
| Transform the bounding_sphere by `t`.
## Private Attributes
vec3f | center_
| The center of the sphere.
float | radius_
| The radius of the sphere.

## Detailed Description

A bounding sphere.

Bounding spheres are very fast to intersect test, but they are fairly loose. If asked to choose just one bounding volume, four out of five graphics professionals surveyed chose the bounding sphere for their patients who chewed bounding volumes.

## Constructor & Destructor Documentation

openvrml::bounding_sphere::bounding_sphere | ( |  | ) |

Construct.

openvrml::bounding_sphere::~bounding_sphere | ( |  | ) | throw ()`[virtual]`

Destroy.

## Member Function Documentation

void openvrml::bounding_sphere::center | ( | const vec3f & | c | ) |

Set the center coordinates.

Parameters:

  `[in]` | c | new center coordinates.

const openvrml::vec3f & openvrml::bounding_sphere::center | ( |  | ) | const

Get the center coordinates.

Returns:
  the center coordinates.

void openvrml::bounding_sphere::radius | ( | float | r | ) |

Set the radius.

Parameters:

  `[in]` | r | new radius value.

float openvrml::bounding_sphere::radius | ( |  | ) | const

Get the radius.

Returns:
  the radius.

void openvrml::bounding_sphere::do_maximize | ( |  | ) | `[private, virtual]`

Extend the bounding sphere to infinity.

Implements openvrml::bounding_volume.

bool openvrml::bounding_sphere::do_maximized | ( |  | ) | const`[private, virtual]`

Whether the bounding_sphere is maximized.

Returns:
  `true` if the bounding_sphere has been maximized; `false` otherwise.

Implements openvrml::bounding_volume.

openvrml::bounding_volume::intersection openvrml::bounding_sphere::do_intersect_frustum | ( | const openvrml::frustum & | frustum | ) | const`[private, virtual]`

Intersect this bvolume with a frustum.

The test assumes that the frustum is in the canonical looking-down-negative-z orientation, so the bounding volume is going to have to be transformed into the frustum's space. (Alternatives include transforming the frustum into the bounding volume's space, or transforming both of them into the projection space. Lots of tradeoffs involved, but transforming the bounding volume is probably the simplest approach overall.)

Parameters:

  `[in]` | frustum | the frustum.

Returns:
  inside, outside, or partial.

See also:
  bounding_volume::transform
  bounding_volume::ortho_transform

Implements openvrml::bounding_volume.

void openvrml::bounding_sphere::do_extend | ( | const vec3f & | p | ) | `[private, virtual]`

Extend to enclose `p`.

Parameters:

  `[in]` | p | a point.

Implements openvrml::bounding_volume.

void openvrml::bounding_sphere::do_extend | ( | const axis_aligned_bounding_box & | bbox | ) | `[private, virtual]`

Extend the bounding volume to enclose `bbox`.

Parameters:

  `[in]` | bbox | an axis-aligned bounding box

Implements openvrml::bounding_volume.

void openvrml::bounding_sphere::do_extend | ( | const bounding_sphere & | b | ) | `[private, virtual]`

Extend this bvolume to enclose the given sphere.

Parameters:

  `[in]` | b | a bounding sphere

void openvrml::bounding_sphere::do_enclose | ( | const std::vector< vec3f > & | points | ) | `[private, virtual]`

Enclose the given set of points.

This resets the volume from any previous values.

Parameters:

  `[in]` | points | points.

Implements openvrml::bounding_volume.

void openvrml::bounding_sphere::do_ortho_transform | ( | const mat4f & | t | ) | `[private, virtual]`

Orthographically transform the bounding_sphere by `t`.

Parameters:

  `[in]` | t | transformation matrix.

Implements openvrml::bounding_volume.

void openvrml::bounding_sphere::do_transform | ( | const mat4f & | t | ) | `[private, virtual]`

Transform the bounding_sphere by `t`.

Parameters:

  `[in]` | t | transformation matrix.

Implements openvrml::bounding_volume.

## Member Data Documentation

openvrml::bounding_sphere::center_`[private]`

The center of the sphere.

openvrml::bounding_sphere::radius_`[private]`

The radius of the sphere.