APSF //- Convert galactic latitude and longitude in user fields //- into B1950.0 RA and Dec. Only objects with correct lat/long //- values in the chosen user fields will be considered. //- Note: A forthcoming update for V1.6 will allow the coordinates //- to be converted to J2000.0. //- //- Paul Rodman, Dec 2007 //- //- Version 1.0 4 Dec 2007 //- Initial release // Set these up to the correct values for your application (1,2,3, or 4) const LatitudeField = 1 // latitude in User Field 1 const LongitudeField = 2 // longitude in User Field 2 function FromLatLong(lat as double, long as double, byref ra as double, byref dec as double) as boolean // Convert lat/long to RA/Dec. Return TRUE if lat/long are in correct range, FALSE otherwise. dim y as double const DegreesToRadians=0.017453292 const RadiansToDegrees=57.29577951 const DegreesToHours=0.06666666667 // Check lat/long if lat<-90.0 or lat>90.0 or long<0.0 or long>360.0 then return false // Convert to B1950.0 coordinates y = atan2(sin((long-123.0)*DegreesToRadians), _ cos((long-123.0)*DegreesToRadians)*sin(27.4*DegreesToRadians)- _ tan(lat*DegreesToRadians)*cos(27.4*DegreesToRadians)) ra = y*RadiansToDegrees+12.25 ra = ra*DegreesToHours if ra<0.0 then ra=ra+24.0 dec = asin(sin(lat*DegreesToRadians)*sin(27.4*DegreesToRadians)+ _ cos(lat*DegreesToRadians)*cos(27.4*DegreesToRadians)* _ cos((long-123.0)*DegreesToRadians))*RadiansToDegrees // Convert to epoch J2000.0 // Omitted, since this functionality isn't currently present return true end function // MAIN program dim i as integer, lat,long,ra,dec as double, slat,slong as string // For each object in the plan for i=1 to nObj // Get the user field values select case LatitudeField case 1 slat=Obj(i).User1 case 2 slat=Obj(i).User2 case 3 slat=Obj(i).User3 case 4 slat=Obj(i).User4 end select select case LongitudeField case 1 slong=Obj(i).User1 case 2 slong=Obj(i).User2 case 3 slong=Obj(i).User3 case 4 slong=Obj(i).User4 end select // Check to make sure both user fields contain numeric values if IsNumeric(slat) and IsNumeric(slong) then lat=CDbl(slat) long=CDbl(slong) if FromLatLong(lat,long,ra,dec) then Obj(i).RA=ra Obj(i).Dec=dec end if end if next