plan9port

[fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port # fast
git clone https://src.adamsgaard.dk/plan9port.git # slow
Log | Files | Refs | README | LICENSE Back to index

output.c (990B)


      1 #include "astro.h"
      2 
      3 void
      4 output(char *s, Obj1 *p)
      5 {
      6 
      7 	if(s == 0)
      8 		print(" SAO %5ld", sao);
      9 	else
     10 		print("%10s", s);
     11 	print(" %R %D %9.4f %9.4f %9.4f",
     12 		p->ra, p->decl2, p->az, p->el, p->semi2);
     13 	if(s == osun.name || s == omoon.name)
     14 		print(" %7.4f", p->mag);
     15 	print("\n");
     16 }
     17 
     18 int
     19 Rconv(Fmt *f)
     20 {
     21 	double v;
     22 	int h, m, c;
     23 
     24 	v = va_arg(f->args, double);
     25 	v = fmod(v*12/pi, 24);		/* now hours */
     26 	h = floor(v);
     27 	v = fmod((v-h)*60, 60);		/* now leftover minutes */
     28 	m = floor(v);
     29 	v = fmod((v-m)*60, 60);		/* now leftover seconds */
     30 	c = floor(v);
     31 	return fmtprint(f, "%2dh%.2dm%.2ds", h, m, c);
     32 }
     33 
     34 int
     35 Dconv(Fmt *f1)
     36 {
     37 	double v;
     38 	int h, m, c, f;
     39 
     40 	v = va_arg(f1->args, double);
     41 	v = fmod(v/radian, 360);	/* now degrees */
     42 	f = 0;
     43 	if(v > 180) {
     44 		v = 360 - v;
     45 		f = 1;
     46 	}
     47 	h = floor(v);
     48 	v = fmod((v-h)*60, 60);		/* now leftover minutes */
     49 	m = floor(v);
     50 	v = fmod((v-m)*60, 60);		/* now leftover seconds */
     51 	c = floor(v);
     52 	return fmtprint(f1, "%c%.2d°%.2d'%.2d\"", "+-"[f], h, m, c);
     53 }