proj home

Files   Classes   Functions   Hierarchy  

pointsurfaceSphere Class Reference

Generate points of the surface of a sphere. This uses Monte-Carlo style point rejection. More...

#include <pointsurface.h>

List of all members.

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.


Detailed Description

Generate points of the surface of a sphere. This uses Monte-Carlo style point rejection.

Definition at line 120 of file pointsurface.h.


Member Function Documentation

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 }  


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

Generated on Fri Mar 4 00:50:10 2011 for Chelton Evans Source by  doxygen 1.5.8