1 #ifndef _SPECCLASS_H_
2 #define _SPECCLASS_H_
3 
4 #include <string>
5 #include "mathdefs.h"
6 #include "colors.h"
7 
8 using std::string;
9 
10 class SpecClass {
11  private:
12   string	sSpecstring;	// e.g. "M3.5 V"
13   char		sMajor;		// the 'M'
14   double	sMinor;		// the 3.5
15   double	sMKtype;	// the V
16   string	sSpecial;	// extra data, e.g. type of non-stellar objects
17 
18   double	lookup(const double table[3][7][2]) const;
19 
20  public:
21   static int class_to_int(char major);	 // maps "OBAFGKM" -> 0,1,...,6
int_to_class(int classno)22   static char int_to_class(int classno)  // the reverse
23     { static const char classes[] = "OBAFGKM" ; return classes[classno]; }
24 
25   SpecClass(const string & = "");
26   SpecClass(char major, double minor, double MK, string special = "");
27   SpecClass(const SpecClass &);
28   SpecClass & operator = (const SpecClass &);
~SpecClass()29   ~SpecClass() { }
30 
31   color_t color() const;		// color of a spectral class
32 					// (may be reset in color.h)
33   void initialize();			// set minor type and MK type
34   double absmag() const;		// expected absolute magnitude
35 
36   // The following two functions are not actually correct as they do
37   // not take into account interstellar dust extinction.
appmag(double distance)38   double appmag(double distance) const	// expected apparent mag at given dist.
39     { return starmath::get_appmag(absmag(), distance); }
distance(double appmag)40   double distance(double appmag) const	// expected distance given apparent mag
41     { return starmath::get_distance(appmag, absmag()); }
42 
43   double temperature() const;		// expected temperature in K
44 
45   // expected diameter in LY for a given absolute magnitude
46   double diameter(double absmag, bool bolometric = false) const;
diameter()47   double diameter() const { return diameter(absmag()); }
48 
classmajor()49   char	 classmajor() const { return sMajor; }
classminor()50   double classminor() const { return sMinor; }
MKtype()51   double MKtype() const { return sMKtype; }
special()52   string special() const { return sSpecial; }
print()53   string print() const { return sSpecstring; }
54 };
55 
56 #endif
57