NO

Author Topic: Very strange  (Read 1277 times)

Grincheux

  • Guest
Very strange
« on: August 25, 2020, 06:56:13 PM »
Could you tell me what is wrong?
The function always returns 0!
I don't understand.
Thanks

These are Julian Dates from 2000 to 2050

Code: [Select]
#define   HELL_PERIHELION      1
#define   HELL_EQU_SPRING      2
#define   HELL_SOL_SUMMER      3
#define   HELL_EQU_AUTOMN      4
#define   HELL_SOL_WINTER      5
#define   HELL_APELION      6

typedef struct tagEVENTDATE
{
   double      dPeriapsis ;   // Date of Perihelion
   double      dApoapsis ;      // Date of Apelion
   
   double      dSpring ;      // Spring Equinox
   double      dSummer;      // Summer Solstice
   double      dAutumn ;      // Autumn Equinox
   double      dWinter ;      // Winter Solstice

} EVENTDATE, *LPEVENTDATE ;

EVENTDATE   DateOfEvents[]   =   {
                           {2451546.729167,2451729.5,2451701.677083,2451794.75,2451886.083333,2451610.385417},
                           {2451913.875,2452095.072917,2452066.9375,2452160.020833,2452251.34375,2451975.666667},
                           {2452277.09375,2452461.666667,2452432.197917,2452525.270833,2452616.59375,2452340.927083},
                           {2452643.71875,2452824.739583,2452797.447917,2452890.510417,2452981.854167,2452706.166667},
                           {2453009.239583,2453191.958333,2453162.708333,2453255.791667,2453347.104167,2453071.416667},
                           {2453372.53125,2453556.708333,2453527.958333,2453621.041667,2453712.354167,2453436.697917},
                           {2453740.15625,2453920.46875,2453893.208333,2453986.270833,2454077.614583,2453801.916667},
                           {2454104.322917,2454288.5,2454258.46875,2454351.572917,2454442.875,2454167.197917},
                           {2454468.5,2454651.822917,2454623.71875,2454716.770833,2454808.125,2454532.46875},
                           {2454836.15625,2455016.572917,2454988.979167,2455082.0625,2455173.385417,2454897.666667},
                           {2455199.510417,2455383.989583,2455354.239583,2455447.322917,2455538.635417,2455262.989583},
                           {2455565.28125,2455747.125,2455719.479167,2455812.53125,2455903.895833,2455628.197917},
                           {2455931.53125,2456113.65625,2456084.75,2456177.864583,2456269.145833,2455993.458333},
                           {2456294.697917,2456479.125,2456450.010417,2456543.052083,2456634.40625,2456358.760417},
                           {2456662,2456842.510417,2456815.25,2456908.333333,2456999.666667,2456723.947917},
                           {2457026.78125,2457210.322917,2457180.520833,2457273.604167,2457364.916667,2457089.260417},
                           {2457390.458333,2457574.1875,2457545.770833,2457638.822917,2457730.166667,2457454.489583},
                           {2457758.104167,2457938.34375,2457911.020833,2458004.125,2458095.427083,2457819.729167},
                           {2458121.739583,2458306.208333,2458276.28125,2458369.354167,2458460.677083,2458185.020833},
                           {2458486.729167,2458669.427083,2458641.53125,2458734.604167,2458825.9375,2458550.239583},
                           {2458853.833333,2459034.989583,2459006.78125,2459099.875,2459191.197917,2458915.510417},
                           {2459217.083333,2459401.4375,2459372.041667,2459465.125,2459556.447917,2459280.770833},
                           {2459583.791667,2459764.802083,2459737.291667,2459830.364583,2459921.708333,2459646.020833},
                           {2459949.1875,2460132.34375,2460102.552083,2460195.645833,2460286.958333,2460011.270833},
                           {2460312.53125,2460496.71875,2460467.8125,2460560.885417,2460652.21875,2460376.552083},
                           {2460680.0625,2460860.333333,2460833.0625,2460926.125,2461017.46875,2460741.770833},
                           {2461044.229167,2461228.239583,2461198.322917,2461291.427083,2461382.729167,2461107.052083},
                           {2461408.614583,2461591.71875,2461563.572917,2461656.614583,2461747.979167,2461472.3125},
                           {2461776.020833,2461956.4375,2461928.833333,2462021.927083,2462113.239583,2461837.520833},
                           {2462139.260417,2462323.71875,2462294.09375,2462387.177083,2462478.489583,2462202.84375},
                           {2462504.927083,2462687.041667,2462659.333333,2462752.385417,2462843.75,2462568.041667},
                           {2462871.375,2463053.802083,2463024.59375,2463117.708333,2463209.010417,2462933.3125},
                           {2463234.71875,2463419,2463389.854167,2463482.90625,2463574.260417,2463298.604167},
                           {2463602,2463782.375,2463755.104167,2463848.1875,2463939.520833,2463663.791667},
                           {2463966.708333,2464150.291667,2464120.364583,2464213.458333,2464304.770833,2464029.114583},
                           {2464330.541667,2464514.270833,2464485.604167,2464578.666667,2464670.020833,2464394.333333},
                           {2464698.104167,2464878.395833,2464850.875,2464943.96875,2465035.28125,2464759.583333},
                           {2465061.677083,2465246.010417,2465216.135417,2465309.197917,2465400.53125,2465124.875},
                           {2465426.71875,2465609.333333,2465581.385417,2465674.458333,2465765.791667,2465490.104167},
                           {2465793.78125,2465975.0625,2465946.635417,2466039.71875,2466131.041667,2465855.364583},
                           {2466156.989583,2466341.302083,2466311.895833,2466404.979167,2466496.302083,2466220.625},
                           {2466523.416667,2466704.572917,2466677.145833,2466770.208333,2466861.552083,2466585.875},
                           {2466888.885417,2467072.052083,2467042.40625,2467135.5,2467226.8125,2466951.114583},
                           {2467252.4375,2467436.604167,2467407.65625,2467500.729167,2467592.072917,2467316.40625},
                           {2467620.041667,2467800.145833,2467772.90625,2467865.979167,2467957.322917,2467681.614583},
                           {2467984.125,2468168.041667,2468138.177083,2468231.28125,2468322.583333,2468046.90625},
                           {2468348.541667,2468531.760417,2468503.416667,2468596.46875,2468687.833333,2468412.166667},
                           {2468716,2468896.78125,2468868.677083,2468961.78125,2469053.09375,2468777.375},
                           {2469079.260417,2469263.71875,2469233.9375,2469327.020833,2469418.34375,2469142.708333},
                           {2469444.9375,2469626.885417,2469599.1875,2469692.239583,2469783.604167,2469507.895833},
                           {0.0,0.0,0.0,0.0,0.0,0.0}
                        } ;

static int FindPerihelionDate(double __dJulianDate)
{
   register int _i ;

   _i = 0 ;

   while(DateOfEvents[_i].dPeriapsis != 0.00)
   {
      if((__dJulianDate >= DateOfEvents[_i].dPeriapsis) && (__dJulianDate < DateOfEvents[_i].dApoapsis))
         return (HELL_PERIHELION) ;

      _i++ ;
   }

   return (0) ;
}

« Last Edit: August 25, 2020, 07:35:01 PM by Grincheux »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Very strange
« Reply #1 on: August 25, 2020, 07:51:48 PM »
This return 1, which is HELL_PERIHELION, as expected.
The problem is elsewhere in your code...
Code: [Select]
#include <stdio.h>

#define   HELL_PERIHELION      1
#define   HELL_EQU_SPRING      2
#define   HELL_SOL_SUMMER      3
#define   HELL_EQU_AUTOMN      4
#define   HELL_SOL_WINTER      5
#define   HELL_APELION      6

typedef struct tagEVENTDATE
{
   double      dPeriapsis ;   // Date of Perihelion
   double      dApoapsis ;      // Date of Apelion
   
   double      dSpring ;      // Spring Equinox
   double      dSummer;      // Summer Solstice
   double      dAutumn ;      // Autumn Equinox
   double      dWinter ;      // Winter Solstice

} EVENTDATE, *LPEVENTDATE ;

EVENTDATE   DateOfEvents[]   =   {
                           {2451546.729167,2451729.5,2451701.677083,2451794.75,2451886.083333,2451610.385417},
                           {2451913.875,2452095.072917,2452066.9375,2452160.020833,2452251.34375,2451975.666667},
                           {2452277.09375,2452461.666667,2452432.197917,2452525.270833,2452616.59375,2452340.927083},
                           {2452643.71875,2452824.739583,2452797.447917,2452890.510417,2452981.854167,2452706.166667},
                           {2453009.239583,2453191.958333,2453162.708333,2453255.791667,2453347.104167,2453071.416667},
                           {2453372.53125,2453556.708333,2453527.958333,2453621.041667,2453712.354167,2453436.697917},
                           {2453740.15625,2453920.46875,2453893.208333,2453986.270833,2454077.614583,2453801.916667},
                           {2454104.322917,2454288.5,2454258.46875,2454351.572917,2454442.875,2454167.197917},
                           {2454468.5,2454651.822917,2454623.71875,2454716.770833,2454808.125,2454532.46875},
                           {2454836.15625,2455016.572917,2454988.979167,2455082.0625,2455173.385417,2454897.666667},
                           {2455199.510417,2455383.989583,2455354.239583,2455447.322917,2455538.635417,2455262.989583},
                           {2455565.28125,2455747.125,2455719.479167,2455812.53125,2455903.895833,2455628.197917},
                           {2455931.53125,2456113.65625,2456084.75,2456177.864583,2456269.145833,2455993.458333},
                           {2456294.697917,2456479.125,2456450.010417,2456543.052083,2456634.40625,2456358.760417},
                           {2456662,2456842.510417,2456815.25,2456908.333333,2456999.666667,2456723.947917},
                           {2457026.78125,2457210.322917,2457180.520833,2457273.604167,2457364.916667,2457089.260417},
                           {2457390.458333,2457574.1875,2457545.770833,2457638.822917,2457730.166667,2457454.489583},
                           {2457758.104167,2457938.34375,2457911.020833,2458004.125,2458095.427083,2457819.729167},
                           {2458121.739583,2458306.208333,2458276.28125,2458369.354167,2458460.677083,2458185.020833},
                           {2458486.729167,2458669.427083,2458641.53125,2458734.604167,2458825.9375,2458550.239583},
                           {2458853.833333,2459034.989583,2459006.78125,2459099.875,2459191.197917,2458915.510417},
                           {2459217.083333,2459401.4375,2459372.041667,2459465.125,2459556.447917,2459280.770833},
                           {2459583.791667,2459764.802083,2459737.291667,2459830.364583,2459921.708333,2459646.020833},
                           {2459949.1875,2460132.34375,2460102.552083,2460195.645833,2460286.958333,2460011.270833},
                           {2460312.53125,2460496.71875,2460467.8125,2460560.885417,2460652.21875,2460376.552083},
                           {2460680.0625,2460860.333333,2460833.0625,2460926.125,2461017.46875,2460741.770833},
                           {2461044.229167,2461228.239583,2461198.322917,2461291.427083,2461382.729167,2461107.052083},
                           {2461408.614583,2461591.71875,2461563.572917,2461656.614583,2461747.979167,2461472.3125},
                           {2461776.020833,2461956.4375,2461928.833333,2462021.927083,2462113.239583,2461837.520833},
                           {2462139.260417,2462323.71875,2462294.09375,2462387.177083,2462478.489583,2462202.84375},
                           {2462504.927083,2462687.041667,2462659.333333,2462752.385417,2462843.75,2462568.041667},
                           {2462871.375,2463053.802083,2463024.59375,2463117.708333,2463209.010417,2462933.3125},
                           {2463234.71875,2463419,2463389.854167,2463482.90625,2463574.260417,2463298.604167},
                           {2463602,2463782.375,2463755.104167,2463848.1875,2463939.520833,2463663.791667},
                           {2463966.708333,2464150.291667,2464120.364583,2464213.458333,2464304.770833,2464029.114583},
                           {2464330.541667,2464514.270833,2464485.604167,2464578.666667,2464670.020833,2464394.333333},
                           {2464698.104167,2464878.395833,2464850.875,2464943.96875,2465035.28125,2464759.583333},
                           {2465061.677083,2465246.010417,2465216.135417,2465309.197917,2465400.53125,2465124.875},
                           {2465426.71875,2465609.333333,2465581.385417,2465674.458333,2465765.791667,2465490.104167},
                           {2465793.78125,2465975.0625,2465946.635417,2466039.71875,2466131.041667,2465855.364583},
                           {2466156.989583,2466341.302083,2466311.895833,2466404.979167,2466496.302083,2466220.625},
                           {2466523.416667,2466704.572917,2466677.145833,2466770.208333,2466861.552083,2466585.875},
                           {2466888.885417,2467072.052083,2467042.40625,2467135.5,2467226.8125,2466951.114583},
                           {2467252.4375,2467436.604167,2467407.65625,2467500.729167,2467592.072917,2467316.40625},
                           {2467620.041667,2467800.145833,2467772.90625,2467865.979167,2467957.322917,2467681.614583},
                           {2467984.125,2468168.041667,2468138.177083,2468231.28125,2468322.583333,2468046.90625},
                           {2468348.541667,2468531.760417,2468503.416667,2468596.46875,2468687.833333,2468412.166667},
                           {2468716,2468896.78125,2468868.677083,2468961.78125,2469053.09375,2468777.375},
                           {2469079.260417,2469263.71875,2469233.9375,2469327.020833,2469418.34375,2469142.708333},
                           {2469444.9375,2469626.885417,2469599.1875,2469692.239583,2469783.604167,2469507.895833},
                           {0.0,0.0,0.0,0.0,0.0,0.0}
                        } ;

static int FindPerihelionDate(double __dJulianDate)
{
   register int _i ;

   _i = 0 ;

   while(DateOfEvents[_i].dPeriapsis != 0.00)
   {
      if((__dJulianDate >= DateOfEvents[_i].dPeriapsis) && (__dJulianDate < DateOfEvents[_i].dApoapsis))
         return (HELL_PERIHELION) ;

      _i++ ;
   }

   return (0) ;
}

int main(int argc, char *argv[])
{
printf("%d\n", FindPerihelionDate(2462871.375));
return 0;
}
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Grincheux

  • Guest
Re: Very strange
« Reply #2 on: August 25, 2020, 07:56:46 PM »
Thanks I continue to search.
 ;D