VRUT::BSphere Class Reference

Bounding sphere class. More...

#include <bvolumes.h>

List of all members.

Public Member Functions

 BSphere ()
 Class constructor.
 BSphere (const BSphere &s)
 Copy constructor.
 ~BSphere ()
 Class destructor.
bool Intersects (const BSphere *s) const
 BSphere-sphere intersection test.
bool Intersects (const BCone *K) const
 BSphere-cone intersection test.
BSphereoperator= (const BSphere &s)
 Prevent copying NULL pointers - when debugging.
wxString ToString () const
 Get string with bounds.

Public Attributes

VECTOR3 Center
 BSphere center.
float Radius
 BSphere radius.


Detailed Description

Bounding sphere class.

Definition at line 286 of file bvolumes.h.


Constructor & Destructor Documentation

VRUT::BSphere::BSphere (  )  [inline]

Class constructor.

Definition at line 296 of file bvolumes.h.

00296 : Center(0, 0, 0), Radius(0.0f)  {}

VRUT::BSphere::BSphere ( const BSphere s  )  [inline]

Copy constructor.

Definition at line 298 of file bvolumes.h.

00298 : Center(s.Center), Radius(s.Radius)  {}

VRUT::BSphere::~BSphere (  )  [inline]

Class destructor.

Definition at line 300 of file bvolumes.h.

00300 {}


Member Function Documentation

bool VRUT::BSphere::Intersects ( const BSphere s  )  const [inline]

BSphere-sphere intersection test.

Definition at line 303 of file bvolumes.h.

00304               {
00305                      float r = Radius + s->Radius;
00306                      VECTOR3 d = Center - s->Center;
00307                      return d.LengthSq() < r * r;
00308               }

bool VRUT::BSphere::Intersects ( const BCone K  )  const [inline]

BSphere-cone intersection test.

Definition at line 311 of file bvolumes.h.

00312               {
00313                      VECTOR3 U = K->Center - (Radius / sinf(K->Angle)) * K->Axis;
00314                      VECTOR3 D = Center - U;
00315                      float dsqr = D.Dot(D);
00316                      float e = K->Axis.Dot(D);
00317                      float cs = cosf(K->Angle);
00318                      if ( e > 0
00319                             && e * e >= dsqr * cs * cs )
00320                      {
00321                             D = Center - K->Center;
00322                             dsqr = D.Dot(D);
00323                             e = -K->Axis.Dot(D);
00324                             float sn = sinf(K->Angle);
00325                             if ( e > 0 && e * e >= dsqr * sn * sn )
00326                                    return dsqr <= Radius * Radius;
00327                             else
00328                                    return true;
00329                      }
00330                      return false;
00331               }

BSphere& VRUT::BSphere::operator= ( const BSphere s  )  [inline]

Prevent copying NULL pointers - when debugging.

Definition at line 334 of file bvolumes.h.

00335               {
00336                      Center = s.Center;
00337                      Radius = s.Radius;
00338                      return *this;
00339               }

wxString VRUT::BSphere::ToString (  )  const [inline]

Get string with bounds.

Definition at line 342 of file bvolumes.h.

00343               {
00344                      return wxString::Format(wxT("Center: %s\nRadius: %f\n"), Center.ToString().c_str(), Radius);
00345               }


Member Data Documentation

BSphere center.

Definition at line 291 of file bvolumes.h.

BSphere radius.

Definition at line 293 of file bvolumes.h.


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

Generated on Tue Mar 10 14:41:41 2009 for VRUT by  doxygen 1.5.5