star Class Reference

#include <star.hpp>

Inheritance diagram for star:

Inheritance graph
[legend]
Collaboration diagram for star:

Collaboration graph
[legend]
List of all members.

Detailed Description

A star can be alone, have one or more companions, be a primary star or be a companion itself. I suppose I could have implemented this as two classes (and probably should have) but I didn't. In fact I may in the not too distant future.

As such a star can be part of an orbit plane and also contain it's own orbit plane.

The "Scouts" volume of Traveller was used as a baseline guide for the methodology used generate star information. This will be revisited over time and is subject to change.

See also:
orbitPlace
Todo:
split star into three classes, star, primaryStar, and companionStar

Definition at line 66 of file star.hpp.

Public Member Functions

 star ()
 star (star *s)
void setOrbit (int ix)
int getOrbit ()
void generateStarInfo ()
void generateStarInfo (star *)
char * toXML ()
void setSize (int s)
int getSize ()
void setType (int t)
int getType ()
void setSpectralClass (int c)
int getSpectralClass ()
void setMinOrbitNumber (int m)
int getMinOrbitNumber ()
void setHabitableOrbit (int h)
int getHabitableorbit ()
void setMaxOrbits (int m)
int getMaxOrbits ()
void setGasGiants (int g)
int getGasGiants ()
void setPlanetoid (int p)
int getPlanetoid ()
void placeCompanion (star *s, int x)
int hasCloseCompanion ()
void setOrbits (orbitPlane *)
orbitPlanegetOrbits ()
char * nodeSignature ()


Constructor & Destructor Documentation

star::star (  ) 

If no parameters are passed, then this is likely supposed to be the primary star....

Definition at line 55 of file star.cpp.

References generateStarInfo().

00055           :orbitPlace(){
00056         orbits= new orbitPlane();
00057         this->generateStarInfo();
00058         closeCompanionPresent=0;
00059 }

Here is the call graph for this function:

star::star ( star s  ) 

For a subordinate star, we pass the parent star to the constructor to allow the appropriate dms to be calculated from the attributes of the parent star

Parameters:
s is of type star and is the star the object is subordinate to

Definition at line 61 of file star.cpp.

References generateStarInfo().

00061                   : orbitPlace() {
00062         orbits=new orbitPlane();
00063         this->generateStarInfo(s);
00064         closeCompanionPresent=0;
00065         
00066 }

Here is the call graph for this function:


Member Function Documentation

void star::generateStarInfo ( star  ) 

Generate a subordinate star's information.

Definition at line 605 of file star.cpp.

References size_roll, and type_roll.

00605                                   {
00606         size_roll = s->size_roll + d2d6();
00607         type_roll = s->type_roll + d2d6();
00608         int dm;
00609         
00610         size = primarySizeLookup(size_roll);
00611         type = primaryTypeLookup(type_roll);
00612         
00613         spectral = ( d1d6() > 3 ? 5 : 0 );
00614         min_orbit_number = this->calculateMinOrbit();
00615         habitable_orbit = this->calculateHabitableOrbit();
00616         
00617         // Calculate a DM based on star size. 
00618         dm = ( size == STAR_SIZE_III ? 4 : 
00619                    ( ((STAR_SIZE_Ia <= size ) && ( size <= STAR_SIZE_II)) ? 
00620                                 8:0 ) );
00621         // Add to or subtract from that DM based on type. 
00622         dm = dm + ( type == STAR_TYPE_M ? -4 : 
00623                             ( type == STAR_TYPE_K ? -2 : 0 ) );
00624         max_orbits = d2d6() + dm;
00625         // Eliminate negative values if present. 
00626         max_orbits = ( max_orbits >= 0 ? max_orbits : 0 ); 
00627         
00628         // Determine if gas giants are present and how many
00629         if ( d2d6() < 10 ) {
00630                 int roll = d2d6();
00631                 gas_giants = 
00632                         ( roll < 4 ? 1 : 
00633                           ( (( roll == 4) || (roll == 5 )) ? 2 :
00634                             ( ( roll == 6) || (roll == 7) ? 3 : 4 ) ) );
00635                 
00636                 
00637         } else {
00638                 gas_giants=0;
00639         }
00640         
00641         gas_giants = ( gas_giants > max_orbits ? max_orbits : gas_giants);
00642         
00643         // Determine if planetoid belts are present and how many
00644         
00645         dm = gas_giants;
00646         
00647         if ( (d2d6() + dm ) > 6 ) {
00648                 planetoid = 0;
00649         } else { 
00650                 int roll= d2d6() + roll; 
00651                 planetoid = ( roll > 6 ? 1 : 2 ) ;
00652         }
00653         
00654         planetoid = ( (gas_giants + planetoid) > max_orbits? (max_orbits-gas_giants) : 
00655                                  planetoid);
00656         
00657         
00658         
00659 }

void star::generateStarInfo (  ) 

Generate a primary star's information.

Definition at line 551 of file star.cpp.

Referenced by star().

00551                            {
00552         int dm;
00553         size_roll = d2d6();
00554         type_roll = d2d6();
00555         size = primarySizeLookup(size_roll);
00556         type = primaryTypeLookup(type_roll);
00557         
00558         spectral = ( d1d6() > 3 ? 5 : 0 );
00559         min_orbit_number = this->calculateMinOrbit();
00560         habitable_orbit = this->calculateHabitableOrbit();
00561         
00562         // Calculate a DM based on star size. 
00563         dm = ( size == STAR_SIZE_III ? 4 : 
00564                    ( ((STAR_SIZE_Ia <= size ) && ( size <= STAR_SIZE_II)) ? 
00565                                 8:0 ) );
00566         // Add to or subtract from that DM based on type. 
00567         dm = dm + ( type == STAR_TYPE_M ? -4 : 
00568                             ( type == STAR_TYPE_K ? -2 : 0 ) );
00569         max_orbits = d2d6() + dm;
00570         // Eliminate negative values if present. 
00571         max_orbits = ( max_orbits >= 0 ? max_orbits : 0 ); 
00572         
00573         // Determine if gas giants are present and how many
00574         if ( d2d6() < 10 ) {
00575                 int roll = d2d6();
00576                 gas_giants = 
00577                         ( roll < 4 ? 1 : 
00578                           ( (( roll == 4) || (roll == 5 )) ? 2 :
00579                             ( ( roll == 6) || (roll == 7) ? 3 : 4 ) ) );
00580                 
00581                 
00582         } else {
00583                 gas_giants=0;
00584         }
00585         
00586         gas_giants = ( gas_giants > max_orbits ? max_orbits : gas_giants);
00587         
00588         // Determine if planetoid belts are present and how many
00589         
00590         dm = gas_giants;
00591         
00592         if ( (d2d6() + dm ) > 6 ) {
00593                 planetoid = 0;
00594         } else { 
00595                 int roll= d2d6() + roll; 
00596                 planetoid = ( roll > 6 ? 1 : 2 ) ;
00597         }
00598         
00599         planetoid = ( (gas_giants + planetoid) > max_orbits? (max_orbits-gas_giants) : 
00600                                  planetoid);
00601         
00602         
00603 }

Here is the caller graph for this function:

int star::getGasGiants (  )  [inline]

return the number of potential gas giants around this star.

Returns:
integer value for the number of gas giants around this star.
Todo:
remove inlining.

Definition at line 252 of file star.hpp.

00252 { return gas_giants; };

int star::getHabitableorbit (  )  [inline]

Get the habitable orbit value See caveats with respect to setHabitableOrbit().

Returns:
integer value for the habitable orbit.
Todo:
remove inlining.

Definition at line 220 of file star.hpp.

00220 { return habitable_orbit; };

int star::getMaxOrbits (  )  [inline]

How many orbits?

Returns:
integer value for the maximum number of orbits around this star.
Todo:
remove inlining

Definition at line 236 of file star.hpp.

00236 { return max_orbits; };

int star::getMinOrbitNumber (  )  [inline]

retrieve the minimum orbit number for this star

Returns:
integer value for the orbit number for this star.
Todo:
remove inlining

Definition at line 197 of file star.hpp.

00197 { return min_orbit_number; };

int star::getOrbit (  )  [inline]

Get the star's orbit. This is not valid for a primary star.

Returns:
(int) the orbit for this star.

Reimplemented from orbitPlace.

Definition at line 102 of file star.hpp.

References sparseVectorNode::getIndex().

00102                        {
00103                 return this->getIndex();
00104         };

Here is the call graph for this function:

orbitPlane * star::getOrbits (  ) 

Get the orbit plane.

Returns:
pointer to the orbitPlane member

Definition at line 763 of file star.cpp.

00763                            {
00764         return orbits;
00765 }

int star::getPlanetoid (  )  [inline]

Get the number potential planetoid belts orbiting this star.

Returns:
integer value of the number of planetoid belts around this star.
Todo:
remove inlining

Definition at line 268 of file star.hpp.

00268 { return planetoid; };

int star::getSize (  )  [inline]

Get the star's size.

Returns:
integer value represnting the star size.
Todo:
move getSize() into the implentation source file instead of inlining.

Definition at line 142 of file star.hpp.

00142 { return size; };

int star::getSpectralClass (  )  [inline]

Get the spectral class of this stars

Returns:
integer value of the spectral classification of this star.
Todo:
remove inlining.

Definition at line 179 of file star.hpp.

00179 { return spectral; }; 

int star::getType (  )  [inline]

Get the integer value of the star's type.

Returns:
integer value of the star type.
Todo:
remove inlining of getType()

Definition at line 160 of file star.hpp.

00160 { return type; };

int star::hasCloseCompanion (  ) 

This is a boolean flag essentially. If this star has a companion star that orbits inside the minimum orbit number rather than out on one of the orbits.

Returns:
1 if a close companion exists or 0 if not.

Definition at line 70 of file star.cpp.

00070                             {
00071         return closeCompanionPresent;
00072 }

char * star::nodeSignature (  ) 

Overloaded method to return the "signature" for this object. In this case the string "star"

Returns:
a pointer to the string "star."

Reimplemented from orbitPlace.

Definition at line 772 of file star.cpp.

00772                          {
00773         return "star";
00774 }

void star::placeCompanion ( star s,
int  x 
)

Place a companion star around this this star.

Parameters:
s Pointer to the companion star being placed.
x either a 2 or a 3 depending on which companion this is...

Definition at line 661 of file star.cpp.

References sparseVector::addAt(), gas_giants, habitable_orbit, max_orbits, and planetoid.

00661                                       {
00662         int dm = ( x == 3 ? 4:0);
00663         int dist;
00664         
00665         switch (d2d6()+dm){
00666                 case 0:
00667                 case 1:
00668                 case 2:
00669                 case 3:
00670                         closeCompanionPresent=1;
00671                         closeCompanion=s;
00672                         break;
00673                 case 4:
00674                         if ( min_orbit_number > 1 ) {
00675                                 closeCompanionPresent=1;
00676                                 closeCompanion=s;
00677                         } else { 
00678                                 orbits->addAt(1,s);
00679                                 min_orbit_number = 2;
00680                         }
00681                         break;
00682                 case 5:
00683                         if ( min_orbit_number > 2 ) {
00684                                 closeCompanionPresent=1;
00685                                 closeCompanion=s;
00686                         } else { 
00687                                 orbits->addAt(2,s);
00688                                 min_orbit_number=3;
00689                         }
00690                         break;
00691                 case 6:
00692                         if ( min_orbit_number > 3 ) {
00693                                 closeCompanionPresent=1;
00694                                 closeCompanion=s;
00695                         } else { 
00696                                 orbits->addAt(3,s);
00697                                 min_orbit_number=4;
00698                         }
00699                         break;
00700                 case 7:
00701                         dist = 4 + d1d6();
00702                         if ( min_orbit_number > dist ) {
00703                                 closeCompanionPresent=1;
00704                                 closeCompanion=s;
00705                         } else {
00706                                 orbits->addAt(dist,s);
00707                         }
00708                         break;
00709                 case 8:
00710                         dist= 5 + d1d6();
00711                         if ( min_orbit_number > dist ) {
00712                                 closeCompanionPresent=1;
00713                                 closeCompanion=s;
00714                         } else {
00715                                 orbits->addAt(dist,s);
00716                         }
00717                         break;
00718                 case 9:
00719                         dist = 6 + d1d6();
00720                         if ( min_orbit_number > dist ) {
00721                                 closeCompanionPresent=1;
00722                                 closeCompanion=s;
00723                         } else {
00724                                 orbits->addAt(dist,s);
00725                         }
00726                         break;
00727                 case 10:
00728                         dist = 7 + d1d6();
00729                         if ( min_orbit_number > dist ) {
00730                                 closeCompanionPresent=1;
00731                                 closeCompanion=s;
00732                         } else {
00733                                 orbits->addAt(dist,s);
00734                         }
00735                         break;
00736                 case 11:
00737                         dist = 8+ d1d6();
00738                         if ( min_orbit_number > dist ) {
00739                                 closeCompanionPresent=1;
00740                                 closeCompanion=s;
00741                         } else {
00742                                 orbits->addAt(dist,s);
00743                         }
00744                         break;
00745                 default:
00746                         dist = 20+d2d6();
00747                         orbits->addAt(dist,s);
00748                         break;
00749         };
00750         
00751         // Let's prevent some cosmological imposibilities...
00752         //
00753         if ( closeCompanionPresent == 1 ) {
00754                 closeCompanion->habitable_orbit=-1;  // Take away the habitable orbit if it existed.
00755                 closeCompanion->gas_giants=0;
00756                 closeCompanion->planetoid=0;
00757                 closeCompanion->max_orbits=0;
00758         }
00759         
00760                 
00761 }

Here is the call graph for this function:

void star::setGasGiants ( int  g  )  [inline]

Set the number of gas giants are potentially around this star

Parameters:
g integer value for how many potential gas giants are around this star.
Todo:
remove inlining.

Definition at line 244 of file star.hpp.

00244 { gas_giants=g;};

void star::setHabitableOrbit ( int  h  )  [inline]

Set what the habitiable orbit number is for this star. In reality this is actually a band of "orbits" that can be part of the habitable zone.

This will need to be revisited later.

Parameters:
h Integer value to set the habitable orbit to.
Todo:
revisit the entire idea of a habitable orbit "zone" rather than sticking with one possible orbit.

remove inlining

Definition at line 210 of file star.hpp.

00210 { habitable_orbit=h; };

void star::setMaxOrbits ( int  m  )  [inline]

How many orbits will the gravity well of this star sustain?

Parameters:
m integer value for the maximum number of orbits for this star.
Todo:
remove inlining

Definition at line 228 of file star.hpp.

00228 { max_orbits=m; } ;

void star::setMinOrbitNumber ( int  m  )  [inline]

Set the minimum orbit number for this star. This is important later on when populating the orbit plane because we don't want to place something in orbit inside the star itself.

Parameters:
m the integer value for the minimal orbit number
Todo:
remove inlining

Definition at line 189 of file star.hpp.

00189 { min_orbit_number  = m; };

void star::setOrbit ( int  ix  )  [inline]

Set this star's orbit. Note: this is invalid for a primary star.

Parameters:
ix integer value to set the orbit to.

Reimplemented from orbitPlace.

Definition at line 92 of file star.hpp.

References sparseVectorNode::setIndex().

00092                              {
00093                 this->setIndex(ix);
00094         }

Here is the call graph for this function:

void star::setOrbits ( orbitPlane  ) 

Set the orbit plane member

Parameters:
pointer to an orbitPlane

Definition at line 767 of file star.cpp.

00767                                   {
00768         orbits= op;
00769 }

void star::setPlanetoid ( int  p  )  [inline]

Set the number of potential planetoid belts orbiting this planet.

Parameters:
p integer value of the number of potential planetoids around this star.
Todo:
remove inlining

Definition at line 260 of file star.hpp.

00260 { planetoid=p; };

void star::setSize ( int  s  )  [inline]

Set the star's size

Parameters:
s integer value to set the star size to
TODO: Move this into the source file instead of inlining.

Definition at line 132 of file star.hpp.

00132 { size=s; };

void star::setSpectralClass ( int  c  )  [inline]

Set the spectral class for this star

Parameters:
c the integer value for the spectral class of this star
Todo:
remove the inlining of setSpectralClass

add support of spectral classifications of other than 0 and 5

change the spectral classifications from integer values to decimal values

remove inlining.

Definition at line 172 of file star.hpp.

00172 { spectral=c; };

void star::setType ( int  t  )  [inline]

Set the star's type.

Parameters:
t integer value of the type to be set to.
Todo:
remove inlining for setType()

Definition at line 151 of file star.hpp.

00151 { type=t; };

char * star::toXML (  ) 

Extract the star's information and output a very long XML file for it.

Definition at line 540 of file star.cpp.

00540                  {
00541         char *buffer;
00542         
00543         buffer=createStartElement("star");
00544         buffer=addXMLElement(buffer,"size",starSize(size));
00545         buffer=addXMLElement(buffer,"type",starType(type));
00546         
00547         return buffer;
00548         
00549 }


The documentation for this class was generated from the following files:
Generated on Fri Mar 7 16:43:16 2008 for frpuniverse by  doxygen 1.4.7