65 Jupiter, Io, Europa, Ganymede, Callisto,
90 #define AMAP_NAME Planet 91 #define AMAP_XTYPE BodyId_T
92 #define AMAP_YTYPE Factoids_T*
93 #include "rnr/assoc.h"
100 {
"unknown", unknown},
102 {
"Mercury", Mercury},
109 {
"Jupiter", Jupiter},
112 {
"Ganymede", Ganymede},
113 {
"Callisto", Callisto},
116 {
"Neptune", Neptune},
141 double diam,
char *units_diam,
142 double dist,
char *units_dist,
143 double period,
char *units_period,
155 fprintf(stderr,
"Error: %d: unknown body type", eThisBodyId);
160 if( !strcmp(units_diam,
"miles") )
166 if( !strcmp(units_dist,
"miles") )
172 if( !strcmp(units_period,
"years") )
198 printf(
"name: %s\n", pOid->
m_sName);
199 printf(
"diameter: %e km\n", pOid->
m_fDiam);
218 return (
int)(x1 - x2);
244 int main(
int argc,
char *argv[])
246 AssocMapPlanetMapper_T map;
247 AssocMapPlanetPoint_T dft = {unknown,
NULL};
252 AddNewBody(Mercury, 4878.0,
"km", 46.0E6,
"km", 0.24,
"years", Sun);
253 AddNewBody(Moon, 3476.0,
"km", 384400.0,
"km", 27.322,
"days", Earth);
254 AddNewBody(Deimos, 8.0,
"km", 23460.0,
"km", 1.263,
"days", Mars);
255 AddNewBody(Phobos, 28.0,
"km", 9270.0,
"km", 0.319,
"days", Mars);
256 AddNewBody(Callisto, 4800.0,
"km", 1883000.0,
"km", 16.689,
"days", Jupiter);
257 AddNewBody(Europa, 3126.0,
"km", 670900.0,
"km", 3.551,
"days", Jupiter);
258 AddNewBody(Jupiter, 88736.0,
"miles", 817.0E6,
"km", 12.0,
"years", Sun);
259 AddNewBody(Earth, 7926.0,
"miles", 91.0E6,
"miles", 1.0,
"years", Sun);
266 map.m_pMapDft = &dft;
272 if( (pOid = AssocMapPlanetXtoY(&map, Moon)) != NULL )
277 if( (pOid = AssocMapPlanetXtoY(&map, Mercury)) != NULL )
282 if( (pOid = AssocMapPlanetXtoY(&map, Earth)) != NULL )
287 if( (pOid = AssocMapPlanetXtoY(&map, Callisto)) != NULL )
292 if( (pOid = AssocMapPlanetXtoY(&map, Eris)) != NULL )
300 printf(
"ceres id: %u\n", AssocMapPlanetYtoX(&map, &findoid));
304 printf(
"jupiter id: %u\n", AssocMapPlanetYtoX(&map, &findoid));
const char * NvpVal2Name(Nvp_T tbl[], size_t nTblEntries, int iVal)
Get the name associated with the value.
Nvp_T SolarBodyNames[]
Solar body name-id pairs (partial).
double m_fDiam
diameter of body (km)
BodyId_T m_eOrbits
body this body orbits around
Memory allocation and deallocation declarations.
#define arraysize(array)
array size, i.e. number of array entries
int CmpIds(const BodyId_T x1, const BodyId_T x2)
X comparator callback.
int main(int argc, char *argv[])
Example main.
#define NEW(T)
Allocate new type.
size_t BodyCount
number of bodies in facts table above.
void PrintBody(Factoids_T *pOid)
Print solar body facts.
RoadNarrows Robotics common configuration file.
int CmpOids(const Factoids_T *y1, const Factoids_T *y2)
Y comparator callback.
const char * m_sName
name of body
AssocMapPlanetPoint_T SolarBodyFacts[NumBodies]
the solar body factoids
double m_fOrbitalAvgDist
average orbital distance (km)
static void AddNewBody(BodyId_T eThisBodyId, double diam, char *units_diam, double dist, char *units_dist, double period, char *units_period, BodyId_T eOrbitsId)
Add a new body to our db, normalizing units.
double m_fOribtalPeriod
orbital revolution period (days)
BodyId_T
Major and minor solar body ids (partial, of course).