//--------------------------------------------------------------------------- #include #include "global.h" #include "calstars.h" #include "cnstl.h" //--------------------------------------------------------------------------- int constellation::init() { int a; for (a=0;a=MAX_LINES) return(0); lines[a]=new const_line; strcpy(lines[a]->from,from); strcpy(lines[a]->to,to); return(1); } cat_entry *constellation::find_star(char *starname) { int star_index=0; while (stars[star_index].starname[0]!='\0' && strcmp(stars[star_index].starname,starname)!=0) star_index++; if (stars[star_index].starname[0]=='\0') return(NULL); /* star was not found */ return(&stars[star_index]); } star_point constellation::find_closest_star(long x,long y,star_point *star_points) { int star_index=0; double dist,min_dist=100000; star_point closest_point; while (star_points[star_index].x>=0) { dist=sqrt(pow(star_points[star_index].x-x,2)+pow(star_points[star_index].y-y,2)); if (distfrom); to_star=find_star(lines[line_index]->to); if (from_star && to_star) { /* from_star */ topo_star(current_date,&earth,DELTA_T,from_star,¤t_location,&ra,&dec); equ2hor(current_date,DELTA_T,0,0,¤t_location,ra,dec,0,&zd,&az,&rar,&decr); res=altaz2xy(90-zd,az,&X1,&Y1); if (res==0 || X1<=0 || Y1<=0) return(0);/* only if the star is not beyond the horizon */ closest_star=find_closest_star(X1,Y1,star_points); dist=sqrt(pow(closest_star.x-X1,2)+pow(closest_star.y-Y1,2)); if (first_star && dist>30) return(0); /* this constellation can not be seen */ first_star=0; #ifdef FITS if (dist<8 || (dist<12 && from_star->magnitude<2.5)) #else if (dist<4 || (dist<6 && from_star->magnitude<2.5)) #endif { X1=closest_star.x; Y1=closest_star.y; } /* to_star */ topo_star(current_date,&earth,DELTA_T,to_star,¤t_location,&ra,&dec); equ2hor(current_date,DELTA_T,0,0,¤t_location,ra,dec,0,&zd,&az,&rar,&decr); res=altaz2xy(90-zd,az,&X2,&Y2); if (res==0 || X2<=0 || Y2<=0) return(0); /* only if the star is not beyond the horizon */ closest_star=find_closest_star(X2,Y2,star_points); dist=sqrt(pow(closest_star.x-X2,2)+pow(closest_star.y-Y2,2)); #ifdef FITS if (dist<8 || (dist<12 && to_star->magnitude<2.5)) #else if (dist<4 || (dist<6 && to_star->magnitude<2.5)) #endif { X2=closest_star.x; Y2=closest_star.y; } cd_line(image,X1,Y1,X2,Y2,style); } line_index++; } return(1); } int constellations::init() { int const_counter; FILE *cnst_file; char *line,buffer[100]; for (const_counter=0;const_counter2) { if (line[0]=='/') { const_counter++; consts[const_counter]=new constellation; consts[const_counter]->init(); } else { line=strtok(line,",\n"); line=strtok(NULL,",\n"); consts[const_counter]->add_line(buffer,line); } } line=fgets(buffer,100,cnst_file); } fclose(cnst_file); return(1); } int constellations::free_consts() { int const_counter; for (const_counter=0;const_counterdraw(image,star_points,const_line_style); return(1); }