PDSphere Class Reference

#include <pDomain.h>

Inheritance diagram for PDSphere:

Inheritance graph
[legend]
Collaboration diagram for PDSphere:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 PDSphere (const pVec &ctr0, const float radOut0, const float radIn0=0.0f)
 ~PDSphere ()
bool Within (const pVec &pos) const
pVec Generate () const
pDomain * copy () const

Public Attributes

pVec ctr
float radOut
float radIn
float radOutSqr
float radInSqr
float radDif
bool ThinShell


Detailed Description

Definition at line 468 of file pDomain.h.


Constructor & Destructor Documentation

PDSphere::PDSphere ( const pVec &  ctr0,
const float  radOut0,
const float  radIn0 = 0.0f 
) [inline]

Definition at line 476 of file pDomain.h.

References ctr, fsqr(), radDif, radIn, radInSqr, radOut, radOutSqr, and ThinShell.

Referenced by copy().

00477     {
00478         ctr = ctr0;
00479         if(radOut0 < radIn0) {
00480             radOut = radIn0; radIn = radOut0;
00481         } else {
00482             radOut = radOut0; radIn = radIn0;
00483         }
00484         if(radIn < 0.0f) radIn = 0.0f;
00485 
00486         radOutSqr = fsqr(radOut);
00487         radInSqr = fsqr(radIn);
00488 
00489         ThinShell = (radIn == radOut);
00490         radDif = radOut - radIn;
00491     }

Here is the call graph for this function:

Here is the caller graph for this function:

PDSphere::~PDSphere (  )  [inline]

Definition at line 493 of file pDomain.h.

00494     {
00495     }


Member Function Documentation

bool PDSphere::Within ( const pVec &  pos  )  const [inline, virtual]

Implements pDomain.

Definition at line 497 of file pDomain.h.

References ctr, pVec::length2(), and radInSqr.

Referenced by PABounce::Exec().

00498     {
00499         pVec rvec(pos - ctr);
00500         float rSqr = rvec.length2();
00501         return rSqr <= radOutSqr && rSqr >= radInSqr;
00502     }

Here is the call graph for this function:

Here is the caller graph for this function:

pVec PDSphere::Generate (  )  const [inline, virtual]

Implements pDomain.

Definition at line 504 of file pDomain.h.

References ctr, fsqr(), pVec::length2(), pVec::normalize(), pos, pRandf, pRandVec(), radDif, radIn, radOut, ThinShell, and vHalf.

00505     {
00506         pVec pos;
00507 
00508         do {
00509             pos = pRandVec() - vHalf; // Point on [-0.5,0.5] box
00510         } while (pos.length2() > fsqr(0.5)); // Make sure it's also on r=0.5 sphere.
00511         pos.normalize(); // Now it's on r=1 spherical shell
00512 
00513         // Scale unit sphere pos by [0..r] and translate
00514         if(ThinShell)
00515             pos = ctr + pos * radOut;
00516         else
00517             pos = ctr + pos * (radIn + pRandf() * radDif);
00518 
00519         return pos;
00520     }

Here is the call graph for this function:

pDomain* PDSphere::copy (  )  const [inline, virtual]

Implements pDomain.

Definition at line 522 of file pDomain.h.

References PDSphere().

00523     {
00524         PDSphere *P = new PDSphere(*this);
00525         return P;
00526     }

Here is the call graph for this function:


Member Data Documentation

pVec PDSphere::ctr

Definition at line 471 of file pDomain.h.

Referenced by PABounce::Exec(), PAAvoid::Exec(), Generate(), PDSphere(), and Within().

float PDSphere::radOut

Definition at line 472 of file pDomain.h.

Referenced by PABounce::Exec(), Generate(), and PDSphere().

float PDSphere::radIn

Definition at line 472 of file pDomain.h.

Referenced by PABounce::Exec(), Generate(), and PDSphere().

float PDSphere::radOutSqr

Definition at line 472 of file pDomain.h.

Referenced by PAAvoid::Exec(), and PDSphere().

float PDSphere::radInSqr

Definition at line 472 of file pDomain.h.

Referenced by PDSphere(), and Within().

float PDSphere::radDif

Definition at line 472 of file pDomain.h.

Referenced by Generate(), and PDSphere().

bool PDSphere::ThinShell

Definition at line 473 of file pDomain.h.

Referenced by Generate(), and PDSphere().


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:52:00 2008 for Armagetron Advanced by  doxygen 1.5.4