c - flmoon function in numerical recipies -


i have problem understanding implementation of following function in c:

#include <math.h> #define rad (3.14159265/180.0) #include "fulmoon.h"   void flmoon(int n, int nph, long *jd, float *frac) { /*this programs begin introductory comment summarizing purpose , explaining calling sequence. routine calculates phases of moon. given integer n , code nph phase desired (nph = 0 new moon, 1 first quarter, 2 full, 3 last quarter), routine returns julian day number jd, , fractional part of day frac added it, of nth such phase since january, 1900. greenwich mean time assumed.*/  int i; float am,as,c,t,t2,xtra; c=n+nph/4.0; t=c/1236.85; t2=t*t; printf("jdhdhdhd"); as=359.2242+29.105356*c; am=306.0253+385.816918*c+0.010730*t2; *jd=2415020+28l*n+7l*nph; xtra=0.75933+1.53058868*c+((1.178e-4)-(1.55e-7)*t)*t2; if (nph == 0 || nph == 2){     xtra += (0.1734-3.93e-4*t)*sin(rad*as)-0.4068*sin(rad*am);     } else (nph == 1 || nph == 3){     xtra += (0.1721-4.0e-4*t)*sin(rad*as)-0.6280*sin(rad*am);     } i=(int)(xtra >= 0.0 ? floor(xtra) : ceil(xtra-1.0)); *jd += i; *frac=xtra-i;  } 

what tried
made header file called fulmoon.h follow:

#ifndef header_h #define header_h  #define myname "amrit"  void flmoon(int n, int nph, long *jd, float *frac);   #endif 

then called function flmoon in main file. did't understand arguments *jd , *frac. how input arguments while trying calculate them.?
example taken book called numerical recipes page 1.

the arguments pointers, before calling function, need create 2 local variables hold result. input function pointers, , function produce output in variables being pointed to. common way allow function return more 1 value. call function this:

long jdresult; float fracresult; flmoon(42, 2, &jdresult, &fracresult); // & creates pointer variable printf("results: %l , %f\n", jdresult, fracresult); 

the variable names have been jd , frac, chose different names avoid common misconception names of variables pass function must same function's parameter names.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -