//stars.inc //fills the sky with stars, based on data from the Yale Bright Star Catalog, J2000.0 equator and epoch //The north pole is in the direction of <0,1,0> //The vernal equinox (0h00m RA) is in the direction <1,0,0> //Orion is at about 6h RA and therefore in the direction of <0,0,1> //Optionally rotate to J2000.0 ecliptic and epoch by setting J2000Ecl #include "KwanMath.inc" #ifndef(CelestialSphereRad) #declare CelestialSphereRad=1e6; #end #ifdef(J2000Ecl) #if(J2000Ecl) #declare Epsilon=23+26/60+21.40880/3600; #else #declare J2000Ecl=0; #declare Epsilon=0; #end #else #declare J2000Ecl=0; #declare Epsilon=0; #end #ifndef(StarRatio) #declare StarRatio=1500; #end #ifndef(StarRad) #declare StarRad=CelestialSphereRad/StarRatio; #end #ifndef(LimitMag) #declare LimitMag=5; #end #ifndef(BrightMax) #declare BrightMax=1; #end #ifndef(ColorSat) #declare ColorSat=0.5; #end #ifndef(Gamma) #declare Gamma=0.4; #end #local ParseStar=true; #if(file_exists("StarsCache.inc")) #include "StarsCache.inc" #if(CelestialSphereRad=CacheCelestialSphereRad) #if(floor(StarRad)=floor(CacheStarRad)) #if(LimitMag=CacheLimitMag) #if(BrightMax=CacheBrightMax) #if(ColorSat=CacheColorSat) #if(Gamma=CacheGamma) #if(J2000Ecl=CacheJ2000Ecl) #local ParseStar=false; #debug "Using Cache\n" #else #debug "Not using cache: J2000Ecl\n" #end #else #debug "Not using cache: Gamma\n" #end #else #debug "Not using cache: ColorSat\n" #end #else #debug "Not using cache: BrightMax\n" #end #else #debug "Not using cache: LimitMag\n" #end #else #debug concat("Not using cache: StarRad=",str(StarRad,0,15)," CacheStarRad=",str(CacheStarRad,0,15),"\n") #end #else #debug "Not using cache: CelSphRad\n" #end #else #debug "Not using cache: No Cache\n" #end #if(ParseStar) #ifndef(BrightStarCatalog) #include "Catalog.inc" #end #fopen ouf "StarsCache.inc" write #write(ouf, "#declare CacheCelestialSphereRad=",CelestialSphereRad,";\n") #write(ouf, "#declare CacheStarRad= ",StarRad,";\n") #write(ouf, "#declare CacheLimitMag= ",LimitMag,";\n") #write(ouf, "#declare CacheBrightMax= ",BrightMax,";\n") #write(ouf, "#declare CacheColorSat= ",ColorSat,";\n") #write(ouf, "#declare CacheGamma= ",Gamma,";\n") #write(ouf, "#declare CacheJ2000Ecl= ",J2000Ecl,";\n") #declare Colors=array[8] { <0.5,0.5,1>, //O,W <0.75,0.75,1>, //B <1,1,1>, //A <1,1,0.5>, //F <1,1,0>, //G <1,0.5,0>, //K,R,S <1,0,0> //M,N <0.5,0,0> //(M10) } #macro GetRA(N) //returns RA in degrees #local S=BrightStarCatalog[N] #local Hours=val(substr(S,76,2)); #local Minutes=val(substr(S,78,2)); #local Seconds=val(substr(S,80,4)); ((Hours+Minutes/60+Seconds/3600)*15) #end #macro GetDec(N) //returns Dec in degrees #local S=BrightStarCatalog[N] #local Sign = substr(S,84,1) #local Degrees=val(substr(S,85,2)); #local Minutes=val(substr(S,87,2)); #local Seconds=val(substr(S,89,2)); ((Degrees+Minutes/60+Seconds/3600)*(strcmp(Sign,"-")=0?-1:1)) #end #macro GetMag(N) //returns Magnitude, lower number is brighter #local S=BrightStarCatalog[N] //#warning concat("MagStr: ",substr(S,103,5)) (val(substr(S,103,5))) #end #macro GetName(N) #local S=BrightStarCatalog[N] //#warning concat("MagStr: ",substr(S,103,5)) concat(substr(S,5,10)," BSC",substr(S,1,4)) #end #local MaxMag=GetMag(0); #macro GetSpectralLetter(N) #local S=BrightStarCatalog[N] substr(S,130,1) #end #macro GetSpectralSubtype(N) #local S=BrightStarCatalog[N] val(substr(S,131,1)) #end #macro GetSpectralType(N) //Returns number corresponding to spectral type, O=zero, M=6 #local SpectralLetter=asc(GetSpectralLetter(N)); //#warning chr(SpectralLetter) #switch(SpectralLetter) #case (asc("D")) #case (asc("O")) #case (asc("W")) (0) #break #case (asc("B")) (1) #break #case (asc("A")) (2) #break #case (asc("F")) (3) #break #case (asc("G")) (4) #break #case (asc("K")) #case (asc("R")) #case (asc("S")) (5) #break #case (asc("M")) #case (asc("N")) #case (asc("C")) #else (6) #break #end #end #macro GetColor(N) //returns a 3vector for color #local S=BrightStarCatalog[N] #local Mag=GetMag(N); //PrintNumber("Mag: ",Mag) #if(Mag>LimitMag) (<0,0,0>) #else #local Bright=Linterp(MaxMag,BrightMax,LimitMag,0,Mag); #local Type=(GetSpectralType(N)); #local Subtype=GetSpectralSubtype(N); //PrintNumber("Subtype: ",Subtype) //PrintVector("0 color: ",Colors[Type]) //PrintVector("10 color: ",Colors[Type+1]) #local Color=Linterp(0,Colors[Type],10,Colors[Type+1],Subtype)*ColorSat; #local Color=((<1,1,1>*(1-ColorSat)+Color)*Bright); () #end #end #macro Star(N) #local V=; #local V=vrotate(V,z*(GetDec(N))); #local V=vrotate(V,-y*(GetRA(N))); #local V=vrotate(V,x*Epsilon); #write(ouf," sphere{<",str(V.x,0,16),",",str(V.y,0,16),",",str(V.z,0,16),">,",StarRad," no_shadow finish {StarFin} pigment {color rgb ",(GetColor(N)),"}}") #write(ouf," //",GetName(N),", VMag=",GetMag(N)," Type=",GetSpectralLetter(N),GetSpectralSubtype(N),"\n") sphere { V,StarRad no_shadow texture { finish {ambient 1 diffuse 0 specular 0} pigment {color rgb (GetColor(N))} } } #end #write(ouf "#local StarFin=finish{ambient 1 diffuse 0 specular 0}\n") #write(ouf "#declare Stars=union {\n") #declare Stars=union { #local I=0; #while((I ] Rotational velocity limit characters 177-179 I3 km/s RotVel ? Rotational velocity, v sin i 180 A1 --- u_RotVel [ :v] uncertainty and variability flag on RotVel 181-184 F4.1 mag Dmag ? Magnitude difference of double, or brightest multiple 185-190 F6.1 arcsec Sep ? Separation of components in Dmag if occultation binary. 191-194 A4 --- MultID Identifications of components in Dmag 195-196 I2 --- MultCnt ? Number of components assigned to a multiple 197 A1 --- NoteFlag [*] a star indicates that there is a note (file notes.dat) -------------------------------------------------------------------------------- */