Files Classes Functions Hierarchy
#include <pointsurface.h>
Public Member Functions | |
| void | operator() (bool &accept, double &x, double &y, double &z, doublec u, doublec v, doublec w) |
| Given a random point in a unit cube generate a random point on the sphere's surface. | |
Definition at line 120 of file pointsurface.h.
| void pointsurfaceSphere::operator() | ( | bool & | accept, | |
| double & | x, | |||
| double & | y, | |||
| double & | z, | |||
| doublec | u, | |||
| doublec | v, | |||
| doublec | w | |||
| ) |
Given a random point in a unit cube generate a random point on the sphere's surface.
Definition at line 6 of file pointsurface.cpp.
00015 { 00016 double u2(u*2.0-1.0); 00017 double v2(v*2.0-1.0); 00018 double w2(w*2.0-1.0); 00019 00020 // Poor zero test but its a quick function. 00021 double dotprod = u2*u2+v2*v2+w2*w2; 00022 if ( (dotprod>1.0) || (dotprod==0.0) ) 00023 { 00024 accept=false; 00025 return; 00026 } 00027 00028 // Assume non-zero u,v,w. 00029 double t = (double)1.0 / sqrt(dotprod); 00030 00031 x=u2*t; 00032 y=v2*t; 00033 z=w2*t; 00034 00035 accept=true; 00036 }
1.5.8