Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

StarPicker Class Reference

Inheritance diagram for StarPicker:

Inheritance graph
Collaboration diagram for StarPicker:

Collaboration graph
List of all members.

Public Member Functions

void process (const Star &, float, float)
 StarPicker (const Point3f &, const Vec3f &, double, float)
 ~StarPicker ()

Public Attributes

const StarpickedStar
Point3f pickOrigin
Vec3f pickRay
double sinAngle2Closest
double when

Constructor & Destructor Documentation

StarPicker::StarPicker const Point3f ,
const Vec3f ,
double  ,
float 
 

Definition at line 518 of file universe.cpp.

References ANGULAR_RES, and sin().

00521                                     :
00522     pickedStar(NULL),
00523     pickOrigin(_pickOrigin),
00524     pickRay(_pickRay),
00525     sinAngle2Closest(sin(angle/2.0) > ANGULAR_RES ? sin(angle/2.0) : 
00526                                                     ANGULAR_RES ),
00527     when(_when)
00528 {
00529 }

StarPicker::~StarPicker  )  [inline]
 

Definition at line 506 of file universe.cpp.

00506 {};


Member Function Documentation

void StarPicker::process const Star ,
float  ,
float 
 

Definition at line 531 of file universe.cpp.

References ANGULAR_RES, distance(), Vector3< T >::normalize(), pickedStar, pickOrigin, pickRay, sinAngle2Closest, sqrt(), testIntersection(), when, Vector3< T >::x, Point3< T >::x, Vector3< T >::y, Point3< T >::y, Vector3< T >::z, and Point3< T >::z.

00532 {
00533     Vec3f relativeStarPos = star.getPosition() - pickOrigin;
00534     Vec3f starDir = relativeStarPos;
00535     starDir.normalize();
00536 
00537     double sinAngle2 = 0.0;
00538 
00539     // Stars with orbits need special handling
00540     float orbitalRadius = star.getOrbitalRadius();
00541     if (orbitalRadius != 0.0f)
00542     {
00543         float distance;
00544 
00545         // Check for an intersection with orbital bounding sphere; if there's
00546         // no intersection, then just use normal calculation.  We actually test
00547         // intersection with a larger sphere to make sure we don't miss a star
00548         // right on the edge of the sphere.
00549         if (testIntersection(Ray3f(Point3f(0.0f, 0.0f, 0.0f), pickRay),
00550                              Spheref(Point3f(0.0f, 0.0f, 0.0f) + relativeStarPos,
00551                                      orbitalRadius * 2.0f),
00552                              distance))
00553         {
00554             Point3d starPos = star.getPosition(when);
00555             starDir = Vec3f((float) (starPos.x * 1.0e-6 - pickOrigin.x),
00556                             (float) (starPos.y * 1.0e-6 - pickOrigin.y),
00557                             (float) (starPos.z * 1.0e-6 - pickOrigin.z));
00558             starDir.normalize();
00559         }
00560     }
00561 
00562     Vec3f starMiss = starDir - pickRay;
00563     Vec3d sMd = Vec3d(starMiss.x, starMiss.y, starMiss.z); 
00564     sinAngle2 = sqrt(sMd * sMd)/2.0;
00565 
00566     if (sinAngle2 <= sinAngle2Closest)
00567     {
00568         sinAngle2Closest = sinAngle2 > ANGULAR_RES ? sinAngle2 : ANGULAR_RES;
00569         pickedStar = &star;
00570     }
00571 }


Member Data Documentation

const Star* StarPicker::pickedStar
 

Definition at line 511 of file universe.cpp.

Referenced by Universe::pickStar(), and process().

Point3f StarPicker::pickOrigin
 

Definition at line 512 of file universe.cpp.

Referenced by process().

Vec3f StarPicker::pickRay
 

Definition at line 513 of file universe.cpp.

Referenced by process().

double StarPicker::sinAngle2Closest
 

Definition at line 514 of file universe.cpp.

Referenced by process().

double StarPicker::when
 

Definition at line 515 of file universe.cpp.

Referenced by process().


The documentation for this class was generated from the following file:
Generated on Sat Jan 14 22:33:38 2006 for Celestia by  doxygen 1.4.1