static GLdouble recurse(const dvector &vec,GLdouble buff[]){ GLdouble a,b,c; c=boost::numeric::ublas::norm_2(vec); //Länge des Vektors if(vec.size()>2) { dvector vec2(2); vec2[0]=vec[0];vec2[1]=vec[2]; a=recurse(vec2,buff+1); //Länge des Vektors auf die size()-1-Ebene projeziert (und sein Winkel auf dieser Ebene) } else a=vec[0]; b=vec[1];//Höhe *buff= a ? ATAN(b/a):90; if(a<0)*buff+=180;//2. & 3. Quadranten gibts nur im 2dim Raum, bei höherdim. Räumen wird das auf eine 180°-Rotation auf der darunter-liegenden "Ebene" zur�ckgef�hrt else if(b<0)*buff+=360; return c; }
static void sunpos(int inYY, int inMM, int inDD, double UTCOFFSET, int inHOUR, int inMIN, int inSEC, double eastlongitude, double latitude, double *L, double *DEC) { int Y; double ZJ, D, T, M, epsilon, lambda, alpha, HA, UTHM; ZJ = ZJtable[inMM]; if (inMM <= 2 && isleap(inYY)) ZJ -= 1.0; UTHM = inHOUR + inMIN / FMINSPERHOUR + inSEC / FSECSPERHOUR - UTCOFFSET; Y = inYY - 1900; /* 1 */ D = floor(365.25 * Y) + ZJ + inDD + UTHM / FHOURSPERDAY; /* 3 */ T = D / 36525.0; /* 4 */ *L = 279.697 + 36000.769 * T; /* 5 */ fixup(L); M = 358.476 + 35999.050 * T; /* 6 */ fixup(&M); epsilon = 23.452 - 0.013 * T; /* 7 */ fixup(&epsilon); lambda = *L + (1.919 - 0.005 * T) * SIN(M) + 0.020 * SIN(2 * M);/* 8 */ fixup(&lambda); alpha = ATAN(TAN(lambda) * COS(epsilon)); /* 9 */ /* Alpha should be in the same quadrant as lamba */ { int lssign = sin(D2R(lambda)) < 0 ? -1 : 1; int lcsign = cos(D2R(lambda)) < 0 ? -1 : 1; while (((sin(D2R(alpha)) < 0) ? -1 : 1) != lssign || ((cos(D2R(alpha)) < 0) ? -1 : 1) != lcsign) alpha += 90.0; } fixup(&alpha); *DEC = ASIN(SIN(lambda) * SIN(epsilon)); /* 10 */ fixup(DEC); fixup(&eastlongitude); HA = *L - alpha + 180 + 15 * UTHM + eastlongitude; /* 12 */ fixup(&HA); fixup(&latitude); #ifdef NOTDEF printf("%02d/%02d %02d:%02d:%02d l:%g d:%g h:%g\n", inMM, inDD, inHOUR, inMIN, inSEC, latitude, *DEC, HA); #endif return; /* * The following calculations are not used, so to save time * they are not calculated. */ #ifdef NOTDEF *ALT = ASIN(SIN(latitude) * SIN(*DEC) + COS(latitude) * COS(*DEC) * COS(HA)); /* 13 */ fixup(ALT); *AZ = ATAN(SIN(HA) / (COS(HA) * SIN(latitude) - TAN(*DEC) * COS(latitude))); /* 14 */ if (*ALT > 180) *ALT -= 360; if (*ALT < -180) *ALT += 360; printf("a:%g a:%g\n", *ALT, *AZ); #endif #ifdef NOTDEF printf("Y:\t\t\t %d\t\t %d\t\t %d\n", Y, expY, Y - expY); comp("ZJ", ZJ, expZJ); comp("UTHM", UTHM, expUTHM); comp("D", D, expD); comp("T", T, expT); comp("L", L, fixup(&expL)); comp("M", M, fixup(&expM)); comp("epsilon", epsilon, fixup(&expepsilon)); comp("lambda", lambda, fixup(&explambda)); comp("alpha", alpha, fixup(&expalpha)); comp("DEC", DEC, fixup(&expDEC)); comp("eastlongitude", eastlongitude, fixup(&expeastlongitude)); comp("latitude", latitude, fixup(&explatitude)); comp("HA", HA, fixup(&expHA)); comp("ALT", ALT, fixup(&expALT)); comp("AZ", AZ, fixup(&expAZ)); #endif }
single XATAN( single *arg ) { //=========================== return( ATAN( *arg ) ); }
/* Sun rise-set calculation algorithm. * Algorithm description: http://williams.best.vwh.net/sunrise_sunset_algorithm.htm * * Almanac for Computers, 1990 * published by Nautical Almanac Office * United States Naval Observatory * Washington, DC 20392 * * Parameters: * yd - day of the year (1..365) * latitude, longitude - Sample: 32.27, 34.85 for Netania israel * riseset - ESUNRISE or ESUNSET * * Returns: UTC hour of the event (a real number). */ double sunriseset( int yd, double latitude, double longitude, ERiseSet riseset ) { // 96 degrees - Calculate Civil twilight time. Used as indication if // it is (usually) bright enough for outdoor activities without additional lighting. // 90 degrees 5' - Calculate true Sunrise/Sunset time. Used to check if // the Sun itself is visible above the horizont in ideal conditions. const double zenith = 96; double sinDec, cosDec, cosH; double H, T, UT; // Rise / Set int op = (riseset==ESUNRISE ? 1:-1); // Convert the longitude to hour value and calculate an approximate time double lngHour = longitude / 15; // if rising time is desired: double t = yd + ((12 - (6*op) - lngHour) / 24); // Calculate the Sun's mean anomaly double M = (0.9856 * t) - 3.289; // Calculate the Sun's true longitude double L = M + (1.916 * SIN(M)) + (0.020 * SIN(2 * M)) + 282.634; // Calculate the Sun's right ascension double RA = ATAN(0.91764 * TAN(L)); // Right ascension value needs to be in the same quadrant as L double Lquadrant = (floor( L/90)) * 90; double RAquadrant = (floor(RA/90)) * 90; RA = RA + (Lquadrant - RAquadrant); // Right ascension value needs to be converted into hours RA = RA / 15; // Calculate the Sun's declination sinDec = 0.39782 * SIN(L); cosDec = COS(ASIN(sinDec)); // Calculate the Sun's local hour angle cosH = (COS(zenith) - (sinDec * SIN(latitude))) / (cosDec * COS(latitude)); if( cosH < -1 || cosH > 1 ) // The sun never rises or sets on this location (on the specified date) return -1; // Finish calculating H and convert into hours H = 180 + (180 - ACOS(cosH))*op; H = H / 15; // Calculate local mean time of rising/setting T = H + RA - (0.06571 * t) - 6.622; // Adjust back to UTC UT = T - lngHour; // UT potentially needs to be adjusted into the range [0,24) by adding/subtracting 24 if (UT < 0) UT += 24; if (UT >= 24) UT -= 24; return UT; }
void KERNEL_NAME(VMLLONG n, VML_FLOAT * a, VML_FLOAT * b, VML_FLOAT * y, VML_FLOAT * z, VML_FLOAT * other_params) { VMLLONG i=0; for(i=0; i<n; i++) { y[i]=ATAN(a[i]); } }
double ASIN(double x) { return 2 * ATAN( x / (1 + std::sqrt(1.0 - x*x))); }