#include <pDomain.h>
Public Member Functions | |
PDDisc (const pVec &ctr0, const pVec nrm0, const float radOut0, const float radIn0=0.0f) | |
~PDDisc () | |
bool | Within (const pVec &pos) const |
pVec | Generate () const |
pDomain * | copy () const |
Public Attributes | |
pVec | p |
pVec | nrm |
pVec | u |
pVec | v |
float | radIn |
float | radOut |
float | radInSqr |
float | radOutSqr |
float | dif |
float | D |
Definition at line 571 of file pDomain.h.
PDDisc::PDDisc | ( | const pVec & | ctr0, | |
const pVec | nrm0, | |||
const float | radOut0, | |||
const float | radIn0 = 0.0f | |||
) | [inline] |
Definition at line 578 of file pDomain.h.
References D, dif, fabsf(), fsqr(), pVec::normalize(), nrm, p, radIn, radInSqr, radOut, radOutSqr, u, and v.
Referenced by copy().
00579 { 00580 p = ctr0; 00581 nrm = nrm0; 00582 nrm.normalize(); 00583 00584 if(radOut0 > radIn0) { 00585 radOut = radOut0; radIn = radIn0; 00586 } else { 00587 radOut = radIn0; radIn = radOut0; 00588 } 00589 dif = radOut - radIn; 00590 radInSqr = fsqr(radIn); 00591 radOutSqr = fsqr(radOut); 00592 00593 // Find a vector orthogonal to n. 00594 pVec basis(1.0f, 0.0f, 0.0f); 00595 if (fabsf(basis * nrm) > 0.999f) 00596 basis = pVec(0.0f, 1.0f, 0.0f); 00597 00598 // Project away N component, normalize and cross to get 00599 // second orthonormal vector. 00600 u = basis - nrm * (basis * nrm); 00601 u.normalize(); 00602 v = Cross(nrm, u); 00603 D = -(p * nrm); 00604 }
bool PDDisc::Within | ( | const pVec & | pos | ) | const [inline, virtual] |
pVec PDDisc::Generate | ( | ) | const [inline, virtual] |
Implements pDomain.
Definition at line 615 of file pDomain.h.
References cosf(), dif, M_PI, p, pos, pRandf, radIn, sinf(), u, v, and x.
00616 { 00617 // Might be faster to generate a point in a square and reject if outside the circle 00618 float theta = pRandf() * 2.0f * float(M_PI); // Angle around normal 00619 // Distance from center 00620 float r = radIn + pRandf() * dif; 00621 00622 float x = r * cosf(theta); // Weighting of each frame vector 00623 float y = r * sinf(theta); 00624 00625 pVec pos = p + u * x + v * y; 00626 return pos; 00627 }
pDomain* PDDisc::copy | ( | ) | const [inline, virtual] |
Definition at line 574 of file pDomain.h.
Referenced by PABounce::Exec(), PAAvoid::Exec(), Generate(), and PDDisc().
Definition at line 574 of file pDomain.h.
Referenced by PABounce::Exec(), PAAvoid::Exec(), and PDDisc().
float PDDisc::radIn |
float PDDisc::radOut |
float PDDisc::radInSqr |
float PDDisc::radOutSqr |
Definition at line 575 of file pDomain.h.
Referenced by PABounce::Exec(), PAAvoid::Exec(), and PDDisc().
float PDDisc::dif |
float PDDisc::D |
Definition at line 575 of file pDomain.h.
Referenced by PABounce::Exec(), PAAvoid::Exec(), and PDDisc().