char* getAltazFromName(char* objStr) { char* auxStr = malloc(sizeof(char) * 10); struct ln_equ_posn equ; int encontrado = 0; double ra, dec; // Extraigo la fecha en formato JD double JD = ln_get_julian_from_sys(); // Probamos con el sol sprintf(auxStr, "sol"); if (strcmp(objStr, auxStr) == 0) { ln_get_solar_equ_coords(JD, &equ); fprintf(stdout, "sol RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Probamos con la luna sprintf(auxStr, "luna"); if (strcmp(objStr, auxStr) == 0) { ln_get_lunar_equ_coords(JD, &equ); fprintf(stdout, "luna RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Probamos con mercurio sprintf(auxStr, "mercurio"); if (strcmp(objStr, auxStr) == 0) { ln_get_mercury_equ_coords(JD, &equ); fprintf(stdout, "mercurio RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Probamos con venus sprintf(auxStr, "venus"); if (strcmp(objStr, auxStr) == 0) { ln_get_venus_equ_coords(JD, &equ); fprintf(stdout, "venus RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Probamos con marte sprintf(auxStr, "marte"); if (strcmp(objStr, auxStr) == 0) { ln_get_mars_equ_coords(JD, &equ); fprintf(stdout, "marte RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Probamos con jupiter sprintf(auxStr, "jupiter"); if (strcmp(objStr, auxStr) == 0) { ln_get_jupiter_equ_coords(JD, &equ); fprintf(stdout, "jupiter RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Probamos con saturno sprintf(auxStr, "saturno"); if (strcmp(objStr, auxStr) == 0) { ln_get_saturn_equ_coords(JD, &equ); fprintf(stdout, "saturno RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Probamos con urano sprintf(auxStr, "urano"); if (strcmp(objStr, auxStr) == 0) { ln_get_uranus_equ_coords(JD, &equ); fprintf(stdout, "urano RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Probamos con neptuno sprintf(auxStr, "neptuno"); if (strcmp(objStr, auxStr) == 0) { ln_get_neptune_equ_coords(JD, &equ); fprintf(stdout, "neptuno RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Probamos con pluton sprintf(auxStr, "pluton"); if (strcmp(objStr, auxStr) == 0) { ln_get_pluto_equ_coords(JD, &equ); fprintf(stdout, "pluton RA %f Dec %f\n", equ.ra, equ.dec); encontrado = 1; } // Si encontré algo if (encontrado == 1) { // Creo la cadena y la devuelvo struct ln_hrz_posn objAltAz = getAltazFromRadecInDate(equ, JD); char* strResp = traduceCoordenadasString(objAltAz); return strResp; }else{ char* strResp = malloc(sizeof(char) * 40); sprintf(strResp, "{\"resp\":\"ko','msg':'Objeto desconocido'}"); return strResp; } }
void writePlanets (double jd, struct ln_lnlat_posn obs) { struct ln_equ_posn equ; // equatorial moon position struct ln_hrz_posn hrz; // horiz alt/az float pos[3],col[3],mars_col[3],jup_col[3]; double lum; // luminance, best guess double discSize; // white col[0] = 1.0; col[1] = 1.0; col[2] = 1.0; // martian red mars_col[0] = 1.2; mars_col[1] = 0.8; mars_col[2] = 0.4; // jupiter brown jup_col[0] = 1.1; jup_col[1] = 0.8; jup_col[2] = 0.5; // Venus ln_get_venus_equ_coords (jd, &equ); ln_get_hrz_from_equ (&equ, &obs, jd, &hrz); pos[0] = -sin(hrz.az*DEGTORAD)*cos(hrz.alt*DEGTORAD); pos[1] = -cos(hrz.az*DEGTORAD)*cos(hrz.alt*DEGTORAD); pos[2] = sin(hrz.alt*DEGTORAD); // disc size should be 10-66 arcseconds discSize = 2.*ln_get_venus_sdiam(jd)/3600.0; // apparent magnitude lum = ln_get_venus_magnitude(jd); fprintf(stdout,"\n# Venus at alt %7.3f deg, az %7.3f deg, magnitude %7.3f, disc %6.2f asec\n",hrz.alt,hrz.az,lum,3600*discSize); if (hrz.alt > -5.0) { // convert to luminance lum = 0.000142*exp(-0.921*lum); fprintf(stdout,"void light venusian\n"); fprintf(stdout,"0\n0\n3 %g %g %g\n",lum*col[0],lum*col[1],lum*col[2]); fprintf(stdout,"venusian source venus\n"); fprintf(stdout,"0\n0\n4 %g %g %g %.3f\n",pos[0],pos[1],pos[2],discSize); } // Jupiter ln_get_jupiter_equ_coords (jd, &equ); ln_get_hrz_from_equ (&equ, &obs, jd, &hrz); pos[0] = -sin(hrz.az*DEGTORAD)*cos(hrz.alt*DEGTORAD); pos[1] = -cos(hrz.az*DEGTORAD)*cos(hrz.alt*DEGTORAD); pos[2] = sin(hrz.alt*DEGTORAD); // disc size 30-49 arcseconds discSize = sqrt(ln_get_jupiter_equ_sdiam(jd)*ln_get_jupiter_pol_sdiam(jd)); discSize = 2.*discSize/3600.0; // apparent magnitude lum = ln_get_jupiter_magnitude(jd); fprintf(stdout,"\n# Jupiter at alt %7.3f deg, az %7.3f deg, magnitude %7.3f, disc %6.2f asec\n",hrz.alt,hrz.az,lum,3600*discSize); if (hrz.alt > -5.0) { // convert to luminance lum = 0.000142*exp(-0.921*lum); fprintf(stdout,"void light jovian\n"); fprintf(stdout,"0\n0\n3 %g %g %g\n",lum*jup_col[0],lum*jup_col[1],lum*jup_col[2]); fprintf(stdout,"jovian source jupiter\n"); fprintf(stdout,"0\n0\n4 %g %g %g %.3f\n",pos[0],pos[1],pos[2],discSize); } // Mars ln_get_mars_equ_coords (jd, &equ); ln_get_hrz_from_equ (&equ, &obs, jd, &hrz); pos[0] = -sin(hrz.az*DEGTORAD)*cos(hrz.alt*DEGTORAD); pos[1] = -cos(hrz.az*DEGTORAD)*cos(hrz.alt*DEGTORAD); pos[2] = sin(hrz.alt*DEGTORAD); // disc size 30-49 arcseconds discSize = 2.*ln_get_mars_sdiam(jd)/3600.0; // apparent magnitude lum = ln_get_mars_magnitude(jd); fprintf(stdout,"\n# Mars at alt %7.3f deg, az %7.3f deg, magnitude %7.3f, disc %6.2f asec\n",hrz.alt,hrz.az,lum,3600*discSize); if (hrz.alt > -5.0) { // convert to luminance lum = 0.000142*exp(-0.921*lum); fprintf(stdout,"void light martian\n"); fprintf(stdout,"0\n0\n3 %g %g %g\n",lum*mars_col[0],lum*mars_col[1],lum*mars_col[2]); fprintf(stdout,"martian source mars\n"); fprintf(stdout,"0\n0\n4 %g %g %g %.3f\n",pos[0],pos[1],pos[2],discSize); } // no other plants are ever brighter than Mars (really?) }