Ogre::Sphere Class Reference
Core » Math

A sphere primitive, mostly used for bounds checking. More...

`#include <OgreSphere.h>`

## Public Member Functions

| Sphere ()
| Standard constructor - creates a unit sphere around the origin. More...
| Sphere (const Vector3 &center, Real radius)
| Constructor allowing arbitrary spheres. More...
const Vector3 & | getCenter (void) const
| Returns the center point of the sphere. More...
Real | getRadius (void) const
| Returns the radius of the sphere. More...
bool | intersects (const Sphere &s) const
| Returns whether or not this sphere intersects another sphere. More...
bool | intersects (const AxisAlignedBox &box) const
| Returns whether or not this sphere intersects a box. More...
bool | intersects (const Plane &plane) const
| Returns whether or not this sphere intersects a plane. More...
bool | intersects (const Vector3 &v) const
| Returns whether or not this sphere intersects a point. More...
void | merge (const Sphere &oth)
| Merges another Sphere into the current sphere. More...
void | setCenter (const Vector3 &center)
| Sets the center point of the sphere. More...
void | setRadius (Real radius)
| Sets the radius of the sphere. More...

## Protected Attributes

Vector3 | mCenter
Real | mRadius

## Detailed Description

A sphere primitive, mostly used for bounds checking.

Remarks
  A sphere in math texts is normally represented by the function x^2 + y^2 + z^2 = r^2 (for sphere's centered on the origin). Ogre stores spheres simply as a center point and a radius.

Definition at line 51 of file OgreSphere.h.

## Constructor & Destructor Documentation

## Sphere() [1/2]

Ogre::Sphere::Sphere | ( |  | ) |

Standard constructor - creates a unit sphere around the origin.

Definition at line 58 of file OgreSphere.h.

## Sphere() [2/2]

Ogre::Sphere::Sphere | ( | const Vector3 & | center,
|  | Real | radius
| ) |  |

Constructor allowing arbitrary spheres.

Parameters

  center | The center point of the sphere.
  radius | The radius of the sphere.

Definition at line 63 of file OgreSphere.h.

## Member Function Documentation

## getCenter()

const Vector3& Ogre::Sphere::getCenter | ( | void |  | ) | const

Returns the center point of the sphere.

Definition at line 73 of file OgreSphere.h.

Referenced by Ogre::PlaneBoundedVolume::intersects(), and merge().

## getRadius()

Real Ogre::Sphere::getRadius | ( | void |  | ) | const

Returns the radius of the sphere.

Definition at line 67 of file OgreSphere.h.

Referenced by Ogre::PlaneBoundedVolume::intersects(), and merge().

## intersects() [1/4]

bool Ogre::Sphere::intersects | ( | const Sphere & | s | ) | const

Returns whether or not this sphere intersects another sphere.

Definition at line 79 of file OgreSphere.h.

References mCenter, mRadius, and Ogre::Math::Sqr().

## intersects() [2/4]

bool Ogre::Sphere::intersects | ( | const AxisAlignedBox & | box | ) | const

Returns whether or not this sphere intersects a box.

Definition at line 85 of file OgreSphere.h.

References Ogre::Math::intersects().

## intersects() [3/4]

bool Ogre::Sphere::intersects | ( | const Plane & | plane | ) | const

Returns whether or not this sphere intersects a plane.

Definition at line 90 of file OgreSphere.h.

References Ogre::Math::intersects().

## intersects() [4/4]

bool Ogre::Sphere::intersects | ( | const Vector3 & | v | ) | const

Returns whether or not this sphere intersects a point.

Definition at line 95 of file OgreSphere.h.

References Ogre::Math::Sqr().

## merge()

void Ogre::Sphere::merge | ( | const Sphere & | oth | ) |

Merges another Sphere into the current sphere.

Definition at line 100 of file OgreSphere.h.

References getCenter(), getRadius(), Ogre::Math::Sqr(), Ogre::Math::Sqrt(), and Ogre::Vector3::squaredLength().

## setCenter()

void Ogre::Sphere::setCenter | ( | const Vector3 & | center | ) |

Sets the center point of the sphere.

Definition at line 76 of file OgreSphere.h.

## setRadius()

void Ogre::Sphere::setRadius | ( | Real | radius | ) |

Sets the radius of the sphere.

Definition at line 70 of file OgreSphere.h.

## Member Data Documentation

## mCenter

Vector3 Ogre::Sphere::mCenter

protected

Definition at line 55 of file OgreSphere.h.

Referenced by intersects().

## mRadius

Real Ogre::Sphere::mRadius

protected

Definition at line 54 of file OgreSphere.h.

Referenced by intersects().

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

- OgreSphere.h

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.