#include <pDomain.h>


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 |
Definition at line 468 of file pDomain.h.
| 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 }


| 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 }


| 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 }

| pDomain* PDSphere::copy | ( | ) | const [inline, virtual] |
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 |
| float PDSphere::radInSqr |
| float PDSphere::radDif |
| bool PDSphere::ThinShell |
1.5.4