⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alqrah.cpp

📁 VC+6.0 编写的关于计算穆斯林祷告的程序. 比较使用的应用小程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:

   /* Noon */
   K=Transit;

    /* Compute the height correction  */
    HightCorWest=0;HightCorEast=0;
   if(flagrs==0 && fabs(param[2])<0.79 && (param[4]!=0 || param[3]!=0))
   {   /* height correction not used for problematic places above 45deg*/
    H0=H=0;
    angl=-0.83333*DToR;  /* standard value  angl=50min=0.8333deg
				    for sunset and sunrise */
    cH=(sin(angl)-SINd)/(COSd);
    H0=acos(cH);

    X=EarthRadius*1000.0;  /* meters  */
    angl=-0.83333*DToR+(0.5*pi-asin(X/(X+param[3])));  /*  */
    cH=(sin(angl)-SINd)/(COSd);
    HightCorWest=acos(cH);
    HightCorWest=(H0-HightCorWest)*(RToH);

    angl=-0.83333*DToR+(0.5*pi-asin(X/(X+param[4])));
    cH=(sin(angl)-SINd)/(COSd);

    HightCorEast=acos(cH);
    HightCorEast=(H0-HightCorEast)*(RToH);
   }


      /* Modify Sunrise,Sunset and Transit for problematic places*/
  if(!(flagrs==0 && fabs(Setting-Rise)>1 && fabs(Setting-Rise)<23))
   {  /* There are problems in computing sun(rise,set)  */
     /* This is because of places above -+65.5 at some days of the year */
     /* Note param[9] should be  45deg as suggested by Rabita  */
     problm=1;
     if(param[2]<0) MaxLat= -fabs(param[9]); else MaxLat= fabs(param[9]);
      /* Recompute the Sun various Parameters using the reference param[9] */
     SunParamr(yg,mg,dg,-param[1],MaxLat,-param[5],
		&Rise,&Transit,&Setting,&RA,&Decl,&flagrs);
     K=Transit;  /* exact noon time */

      /* ReCompute General Values for the new reference param[9]*/
     SINd=sin(Decl)*sin(MaxLat);
     COSd=cos(Decl)*cos(MaxLat);
   }
   /*-------------------------------------------------------------*/
   if(K<0) K=K+24;

   lst[2]=Rise-HightCorEast;   /* Sunrise - Height correction */
   lst[3]=K+param[0];   /* Zohar time+extra time to make sure that the sun has moved from zaowal */
   lst[5]=Setting+HightCorWest+param[0]; /* Magrib= SunSet + Height correction + Safety Time */


    /*-------------------------------------------------------------*/
      /* Asr time: Henfy param[8]=2, Shafi param[8]=1, OmAlqrah asr=1  */
   if(problm) /* For places above 65deg */
       act=param[8]+tan(fabs(Decl-MaxLat));
     else /* no problem */
       act=param[8]+tan(fabs(Decl-param[2]));  /*In the standard
					    equations abs() is not used,
					    but it is required for -ve latitude  */
   angl=atan(1.0/act);
   cH=(sin(angl)-SINd)/(COSd);
   if(fabs(cH)>1.0)
   {
    H=3.5;
    flag=0; /* problem in compuing Asr */
   }
  else
   {
    H=acos(cH);
    H=H*RToH;
   }
   lst[4]=K+H+param[0];  /*  Asr Time */

    /*-------------------------------------------------------------*/
   /* Fajr Time  */
   angl=-param[6]; /* The value -19deg is used by OmAlqrah for Fajr,
			   but it is not correct,
			   Astronomical twilight and Rabita use -18deg */
  cH=(sin(angl)-SINd)/(COSd);
  if(fabs(param[2])<0.83776)    /*If latitude<48deg   */
  {     /* no problem */
     H=acos(cH);
     H=H*RToH;  /* convert radians to hours  */
     lst[1]=K-(H+HightCorEast)+param[0];    /* Fajr time  */
     lst[7]=lst[1];
  }
 else
  {  /* Get fixed ratio, data depends on latitutde sign*/
      if(param[2]<0)
	    GetRatior(yg,12,21,param,&IshFix,&FajrFix);
	 else
	   GetRatior(yg,6,21,param,&IshFix,&FajrFix);

   if(fabs(cH)>(0.45+1.3369*param[6]))   /* A linear equation I have interoduced  */
   {   /* The problem occurs for places above -+48 in the summer */
     Night=24-(Setting-Rise); /* Night Length  */
     lst[1]=Rise-Night*FajrFix;  /* According to the general ratio rule*/
   }
  else
   {  /* no problem */
     H=acos(cH);
     H=H*RToH;  /* convert radians to hours  */
     lst[1]=K-(H+HightCorEast)+param[0];    /* Fajr time  */
    }
   lst[7]=lst[1];
   if(fabs(cH)>1)
   {   /* The problem occurs for places above -+48 in the summer */
     GetRatior(yg,mg,dg,param,&IshRt,&FajrRt);
     Night=24-(Setting-Rise); /* Night Length  */
     lst[7]=Rise-Night*FajrRt; /*  Accoording to Rabita Method*/
   }
  else
   {  /* no problem */
     H=acos(cH);
     H=H*RToH;  /* convert radians to hours  */
     lst[7]=K-(H+HightCorEast)+param[0];    /* Fajr time  */
   }

  }

   /*-------------------------------------------------------------*/
    /*   Isha prayer time   */
   if(param[7]!=0)  /* if Ish angle  not equal zero*/
    {
       angl=-param[7];
       cH=(sin(angl)-SINd)/(COSd);
      if(fabs(param[2])<0.83776)    /*If latitude<48deg   */
      {     /* no problem */
	H=acos(cH);
	H=H*RToH;  /* convert radians to hours  */
	lst[6]=K+(H+HightCorWest+param[0]);    /* Isha time, instead of  Sunset+1.5h */
	lst[8]=lst[6];
      }
    else
     {
     if(fabs(cH)>(0.45+1.3369*param[6]))   /* A linear equation I have interoduced  */
	{   /* The problem occurs for places above -+48 in the summer */
	  Night=24-(Setting-Rise); /* Night Length  */
	  lst[6]=Setting+Night*IshFix; /*  Accoording to Rabita Method*/
	}
       else
       { /* no problem */
	H=acos(cH);
	H=H*RToH;  /* convert radians to hours  */
	lst[6]=K+(H+HightCorWest+param[0]);    /* Isha time, instead of  Sunset+1.5h */
       }

      if(fabs(cH)>1.0)
	{   /* The problem occurs for places above -+48 in the summer */
	  GetRatior(yg,mg,dg,param,&IshRt,&FajrRt);
	  Night=24-(Setting-Rise); /* Night Length  */
	  lst[8]=Setting+Night*IshRt;  /* According to the general ratio rule*/
	}
       else
       {
	H=acos(cH);
	H=H*RToH;  /* convert radians to hours  */
	lst[8]=K+(H+HightCorWest+param[0]);    /* Isha time, instead of  Sunset+1.5h */
       }

      }
     }
   else
    {
      lst[6]=lst[5]+param[10];  /* Isha time OmAlqrah standard Sunset+fixed time (1.5h or 2h in Romadan) */
      lst[8]=lst[6];
    }
 /*-------------------------------------------------------------*/
    /*   Eid prayer time   */
   angl=param[11]; /*  Eid Prayer time Angle is 4.2  */
  cH=(sin(angl)-SINd)/(COSd);
  if((fabs(param[2])<1.134 || flagrs==0) && fabs(cH)<=1.0)    /*If latitude<65deg   */
  {     /* no problem */
     H=acos(cH);
     H=H*RToH;  /* convert radians to hours  */
     lst[9]=K-(H+HightCorEast)+param[0];    /* Eid time  */
  }
 else
  {
    lst[9]=lst[2]+0.25;  /* If no Sunrise add 15 minutes */
  }
    return flag;

}

/*
  Function to obtain the ratio of the start time of Isha and Fajr at
  a referenced latitude (45deg suggested by Rabita) to the night length
*/
void GetRatior(int yg,int mg,int dg,double param[],double *IshRt,double *FajrRt)
{
    int flagrs;
    double RA,Decl;
    double Rise,Transit,Setting;
    double SINd,COSd;
    double H,angl,cH;
    double MaxLat;
    double FjrRf,IshRf;
    double Night;

     if(param[2]<0) MaxLat= -fabs(param[9]); else MaxLat= fabs(param[9]);
     SunParamr(yg,mg,dg,-param[1],MaxLat,-param[5],
		&Rise,&Transit,&Setting,&RA,&Decl,&flagrs);
     SINd=sin(Decl)*sin(MaxLat);
     COSd=cos(Decl)*cos(MaxLat);
     Night=24-(Setting-Rise);  /* Night Length */
     /* Fajr */
     angl=-param[6];
     cH=(sin(angl)-SINd)/(COSd);
     H=acos(cH);
     H=H*RToH;  /* convert radians to hours  */
     FjrRf=Transit-H-param[0];    /* Fajr time  */
    /* Isha */
   if(param[7]!=0)  /* if Ish angle  not equal zero*/
    {
       angl=-param[7];
       cH=(sin(angl)-SINd)/(COSd);
       H=acos(cH);
       H=H*RToH;  /* convert radians to hours  */
       IshRf=Transit+H+param[0];    /* Isha time, instead of  Sunset+1.5h */
     }
   else
    {
      IshRf=Setting+param[10];  /* Isha time OmAlqrah standard Sunset+1.5h */
    }
   *IshRt=(IshRf-Setting)/Night;  /* Isha time ratio */
   *FajrRt=(Rise-FjrRf)/Night;  /* Fajr time ratio */

   return;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -