Re: [Therion] Wrong average calculation from compass/backcompass data

2018-05-16 Thread Olly Betts via Therion
On Wed, May 16, 2018 at 04:45:54PM +0200, Evaristo Quiroga via Therion wrote:
> I think the problem is the average calculation formula in "thdb1d.cxx"
> 
> >// check backwards compass reading
> >    if ((lei->data_type == TT_DATATYPE_NORMAL) ||
> >    (lei->data_type == TT_DATATYPE_DIVING) ||
> >    (lei->data_type == TT_DATATYPE_CYLPOLAR)) {
> >    if (!thisnan(lei->backbearing)) {
> >    if (thisnan(lei->bearing)) {
> >  lei->backbearing -= 180.0;
> >  if (lei->backbearing < 0)
> >    lei->backbearing += 360.0;
> >  lei->bearing = lei->backbearing;
> >    }
> >    else {
> >  lei->backbearing -= 180.0;
> >  if (lei->backbearing < 0)
> >    lei->backbearing += 360.0;
> >                                    // calculate average of two angles
> >  //lei->bearing += lei->backbearing;
> >  //lei->bearing = lei->bearing / 2.0;
> >                                    double sumx, sumy;
> >                                    sumx = cos((90.0 -
> >lei->bearing)/180.0*THPI) + cos((90.0 - lei->backbearing)/180.0*THPI);
> >                                    sumy = sin((90.0 -
> >lei->bearing)/180.0*THPI) + sin((90.0 - lei->backbearing)/180.0*THPI);
> >                                    lei->bearing = 90.0 - (atan2(sumy,
> >sumx) / THPI * 180.0);
> >  if (lei->bearing < 0.0)
> >    lei->bearing += 360.0;
> >    }
> >  }
> >    }
> 
> I think the formula is too complicated. I purpose a simpler formula, like:
>             If bearing <=180
>                       AverageBearing =  (bearing + (backbearing -180))/2
>                 else
>                       AverageBearing = (bearing + (backbearing +180))/2

Your proposed formula gives wrong answers in some cases - consider:

bearing = 80, backbearing = 0

These give AverageBearing = (80 + 0 - 180) / 2 = -50 (equivalent to
310), but this should be 130 (average of 80 and 180).

The therion formula is attempting to average the angles by trigonometry,
which seems a reasonable approach (though probably slower than trying to
average more directly like you're suggesting).  It looks essentially
correct to me, though it's a bit oddly written since cos(90 - x) is
sin(x), sin(90 - x) is -cos(x), 90 - atan2(y,x) is atan2(x,y) (possibly
+/- a multiple of 360).  But if I work it out with a calculator for
236.8 and 56.8 then I do get 236.8.

If it's still not working with the declination set to zero, perhaps
you should show us a complete small example we can process to see
what is going on?

Cheers,
Olly
___
Therion mailing list
Therion@speleo.sk
https://mailman.speleo.sk/listinfo/therion


Re: [Therion] Wrong average calculation from compass/backcompass data

2018-05-16 Thread Evaristo Quiroga via Therion
I think Therion subtract the magnetic declination before to transfer 
data Survex. Now to compare better I have put magnetic declination to 0.



declination 0.00 degrees




Data transferred to Survex by the "data.svx" file

*data    normal    from    to    tape  compass    clino
    1    2    0.00    269.423853    0.00
    1    3    2.33    236.223853    -11.40
    3    4    4.51    162.623853    -32.20
    4    5    12.41    0.923853    -77.70
    5    6    1.95    212.073853    -17.15





You can see Therion do a wrong fore/back sight compass average 
calculation. The good data average are:


1     3    236.8     -11.4

3    4    163.2    -32

4    5    1.5        -77.7

5    6    212.65    -17.15


I think the problem is the average calculation formula in "thdb1d.cxx"


// check backwards compass reading
    if ((lei->data_type == TT_DATATYPE_NORMAL) ||
    (lei->data_type == TT_DATATYPE_DIVING) ||
    (lei->data_type == TT_DATATYPE_CYLPOLAR)) {
    if (!thisnan(lei->backbearing)) {
    if (thisnan(lei->bearing)) {
  lei->backbearing -= 180.0;
  if (lei->backbearing < 0)
    lei->backbearing += 360.0;
  lei->bearing = lei->backbearing;
    }
    else {
  lei->backbearing -= 180.0;
  if (lei->backbearing < 0)
    lei->backbearing += 360.0;
                                    // calculate average of two angles
  //lei->bearing += lei->backbearing;
  //lei->bearing = lei->bearing / 2.0;
                                    double sumx, sumy;
                                    sumx = cos((90.0 - 
lei->bearing)/180.0*THPI) + cos((90.0 - lei->backbearing)/180.0*THPI);
                                    sumy = sin((90.0 - 
lei->bearing)/180.0*THPI) + sin((90.0 - lei->backbearing)/180.0*THPI);
                                    lei->bearing = 90.0 - (atan2(sumy, 
sumx) / THPI * 180.0);

  if (lei->bearing < 0.0)
    lei->bearing += 360.0;
    }
  }
    }


I think the formula is too complicated. I purpose a simpler formula, like:
            If bearing <=180
                      AverageBearing =  (bearing + (backbearing -180))/2
                else
                      AverageBearing = (bearing + (backbearing +180))/2

Regards,

Evaristo.
___
Therion mailing list
Therion@speleo.sk
https://mailman.speleo.sk/listinfo/therion


Re: [Therion] Wrong average calculation from compass/backcompass data

2018-05-16 Thread Evaristo Quiroga via Therion

Hi,

I found that the error had been fixed in version 5.4.1



  Therion 5.4 (5.4.1 now 2017-04-18)


 *
bugs and issues fixed:
27. invalid compass/backcompass averaging formula



But I am using the  "Therion 5.4.1+6884381 (2018-04-12)", were I have 
found the actual bug.


Evaristo.

El 16/05/2018 a las 14:17, Evaristo Quiroga via Therion escribió:

Hi,

I have data from a survey with fore/back sight compass and clino. I 
have detected a Therion bug calculating the average data, comparing 
with the error loops with Auriga, Visualtopo, Compass and Therion.


See the next compare.

Example from the data in .th file:

data normal from to length compass backcompass clino backclino left 
right up down
    279.0 -  0.00    0.00    0.00 0.00 0.00    
0.00    0.00    0.00    0.00
    279.0    279.0A  2.33   236.8    56.8 -11.4 11.4    
0.00    0.00    0.00    0.00 # .superficie
   279.0A 279.1  4.51   163.2   343.2 -32.2 32.2    
0.00    0.00    0.00    0.00 # .superficie hasta anclaje desviador
    279.1 279.2 12.41 1.5   181.5 -77.7 77.7    
0.00    0.00    0.00    0.00
    279.2 279.3  1.95   212.2    33.1 -17.7 16.6    
0.00    0.00    0.00    0.00 



Data transferred to Survex by the "data.svx" file


*data    normal    from    to    tape  compass    clino
    1    2    0.00    268.348831    0.00
    1    3    2.33    235.148831    -11.40
    3    4    4.51    161.548831    -32.20
    4    5    12.41    359.848831    -77.70
    5    6    1.95    210.998831    -17.15



You can see Therion do a wrong fore/back sight compass average 
calculation. The good data average are:


1     3    236.8     -11.4

3    4    163.2    -32

4    5    1.5        -77.7

5    6    212.65    -17.15

The clino average seems OK.

Searching in the mail-list I have found the bug was reported before. I 
think is not corrected since then.


https://www.mail-archive.com/therion@speleo.sk/msg04660.html

Regards,

Evaristo.

___
Therion mailing list
Therion@speleo.sk
https://mailman.speleo.sk/listinfo/therion



___
Therion mailing list
Therion@speleo.sk
https://mailman.speleo.sk/listinfo/therion


[Therion] Wrong average calculation from compass/backcompass data

2018-05-16 Thread Evaristo Quiroga via Therion

Hi,

I have data from a survey with fore/back sight compass and clino. I have 
detected a Therion bug calculating the average data, comparing with the 
error loops with Auriga, Visualtopo, Compass and Therion.


See the next compare.

Example from the data in .th file:

data normal from to length compass backcompass clino backclino left 
right up down
    279.0 -  0.00    0.00    0.00 0.00    0.00    
0.00    0.00    0.00    0.00
    279.0    279.0A  2.33   236.8    56.8 -11.4    11.4    
0.00    0.00    0.00    0.00 # .superficie
   279.0A 279.1  4.51   163.2   343.2 -32.2    32.2    
0.00    0.00    0.00    0.00 # .superficie hasta anclaje desviador
    279.1 279.2 12.41 1.5   181.5 -77.7    77.7    
0.00    0.00    0.00    0.00
    279.2 279.3  1.95   212.2    33.1 -17.7    16.6    
0.00    0.00    0.00    0.00 



Data transferred to Survex by the "data.svx" file


*data    normal    from    to    tape  compass    clino
    1    2    0.00    268.348831    0.00
    1    3    2.33    235.148831    -11.40
    3    4    4.51    161.548831    -32.20
    4    5    12.41    359.848831    -77.70
    5    6    1.95    210.998831    -17.15



You can see Therion do a wrong fore/back sight compass average 
calculation. The good data average are:


1     3    236.8     -11.4

3    4    163.2    -32

4    5    1.5        -77.7

5    6    212.65    -17.15

The clino average seems OK.

Searching in the mail-list I have found the bug was reported before. I 
think is not corrected since then.


https://www.mail-archive.com/therion@speleo.sk/msg04660.html

Regards,

Evaristo.

___
Therion mailing list
Therion@speleo.sk
https://mailman.speleo.sk/listinfo/therion