ScallopedSector.h

00001 // $Id: ScallopedSector.h,v 1.3 2006/07/06 23:30:24 zr Exp $
00002 
00003 #include <vector>
00004 
00005 typedef struct {
00006         Vec2 P;
00007         float r, sign, d, theta, integralAtStart;
00008         float rSqrd, dSqrd;
00009 } ArcData;
00010 
00011 class ScallopedSector
00012 {
00013 public:
00014         Vec2 P;
00015         float a1, a2, area;
00016         
00017         ArcData arcs[2];
00018 
00019 public:
00020         ScallopedSector(Vec2 &_Pt, float _a1, float _a2, Vec2 &P1, float r1, float sign1, Vec2 &P2, float r2, float sign2);
00021 
00022         float calcAreaToAngle(float angle);
00023         float calcAngleForArea(float area, RNG &rng);
00024         Vec2 sample(RNG &rng);
00025 
00026         float distToCurve(float angle, int index);
00027 
00028         void subtractDisk(Vec2 &C, float r, std::vector<ScallopedSector> *regions);
00029 
00030 private:
00031         float canonizeAngle(float angle);
00032 
00033         void distToCircle(float angle, Vec2 &C, float r, float *d1_out, float *d2_out);
00034 };
00035 
00036 class ScallopedRegion
00037 {
00038 public:
00039         std::vector<ScallopedSector> *regions;
00040         float minArea;
00041         float area;
00042 
00043 public:
00044         ScallopedRegion(Vec2 &P, float r1, float r2, float minArea=.00000001);
00045         ~ScallopedRegion();
00046 
00047         bool isEmpty() { return regions->size()==0; }
00048         void subtractDisk(Vec2 C, float r);
00049 
00050         Vec2 sample(RNG &rng);
00051 };

Generated on Wed Oct 25 03:19:42 2006 for Lumos by  doxygen 1.4.6