Skip to content

Commit

Permalink
2.4: invert scale
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Sep 28, 2020
1 parent 0c0b05f commit 55a14d6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 46 deletions.
4 changes: 4 additions & 0 deletions doc/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Name: GeoFindKey
OldName: FindKey
URL: https://github.com/Geo-Linux-Calculations/geofindkey

2.4

invert scale

2.3

Gaussian normalization OLS
Expand Down
22 changes: 11 additions & 11 deletions src/geofindkey.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Name: geofindkey.c
OldName: findkey.c
Version: 2.3
Date: 2020-09-24
Version: 2.4
Date: 2020-09-28
Author: Игорь Белов (https://gis-lab.info/forum/memberlist.php?mode=viewprofile&u=10457)
Author: zvezdochiot (https://github.com/zvezdochiot)
Author: Zoltan Siki (https://github.com/zsiki)
Expand Down Expand Up @@ -52,7 +52,7 @@ key(normal):
#include <unistd.h>

#define PNAME "GeoFindKey"
#define PVERSION "2.3"
#define PVERSION "2.4"

void geofindkeytitle()
{
Expand Down Expand Up @@ -191,11 +191,11 @@ int main(int argc, char *argv[])
xc[3] -= (s[0] * s[0] + s[1] * s[1] )/ n;
xc[3] *= 2.0;
xc[3] /= n;
xc[3] = (xc[3] > 0.0) ? sqrt(xc[3]) : 1.0;
xc[3] = (xc[3] > 0.0) ? (1.0 / sqrt(xc[3])) : 1.0;
yc[3] -= (s[2] * s[2])/ n;
yc[3] *= 2.0;
yc[3] /= n;
yc[3] = (yc[3] > 0.0) ? sqrt(yc[3]) : 1.0;
yc[3] = (yc[3] > 0.0) ? (1.0 / sqrt(yc[3])) : 1.0;
} else {
xc[3] = 1.0;
yc[3] = 1.0;
Expand Down Expand Up @@ -228,9 +228,9 @@ int main(int argc, char *argv[])
dx[i] = x[i] - xc[i];
dy[i] = y[i] - yc[i];
}
dx[0] /= xc[3];
dx[1] /= xc[3];
dx[2] /= yc[3];
dx[0] *= xc[3];
dx[1] *= xc[3];
dx[2] *= yc[3];
/* суммировать */
s[0] += dx[0] * dy[0] * wgt;
s[1] += dx[1] * dy[1] * wgt;
Expand All @@ -244,8 +244,8 @@ int main(int argc, char *argv[])
rewind(fp0);

/* найти первичные параметры */
a[1][0] = (s[0] + s[1]) / xc[3];
a[1][1] = (s[3] - s[4]) / xc[3];
a[1][0] = (s[0] + s[1]) * xc[3];
a[1][1] = (s[3] - s[4]) * xc[3];
if (s[6] > 0.0)
{
a[1][0] /= s[6];
Expand All @@ -256,7 +256,7 @@ int main(int argc, char *argv[])
}
if (s[2] > 0.0)
{
a[1][2] = s[5] / s[2] / yc[3];
a[1][2] = s[5] / s[2] * yc[3];
} else {
a[1][2] = 1.0;
}
Expand Down
67 changes: 38 additions & 29 deletions src/geofindkey2p.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Name: geofindkey2p.c
Version: 2.3
Date: 2020-09-24
Version: 2.4
Date: 2020-09-28
Author: zvezdochiot (https://github.com/zvezdochiot)
*
build:
Expand Down Expand Up @@ -57,7 +57,7 @@ output file report.dat:
#include <unistd.h>

#define PNAME "GeoFindKey2Pow"
#define PVERSION "2.3"
#define PVERSION "2.4"

void geofindkey2ptitle()
{
Expand Down Expand Up @@ -183,27 +183,25 @@ int main(int argc, char *argv[])
s[5] += y[2] * wgt;
s[6] += wgt;
n++;
s[7] += (x[0] * x[0] + x[1] * x[1]) * wgt;
s[8] += (x[2] * x[2]) * wgt;
xc[3] += (x[0] * x[0] + x[1] * x[1]) * wgt;
yc[3] += (x[2] * x[2]) * wgt;
}
}
n = (s[6] > 0.0) ? s[6] : n;
if (n > 0.0)
{
s[7] -= (s[0] * s[0] + s[1] * s[1] )/ n;
s[7] *= 2.0;
s[7] /= n;
s[7] = (s[7] > 0.0) ? sqrt(s[7]) : 1.0;
s[8] -= (s[2] * s[2])/ n;
s[8] *= 2.0;
s[8] /= n;
s[8] = (s[8] > 0.0) ? sqrt(s[8]) : 1.0;
xc[3] -= (s[0] * s[0] + s[1] * s[1] )/ n;
xc[3] *= 2.0;
xc[3] /= n;
xc[3] = (xc[3] > 0.0) ? (1.0 / sqrt(xc[3])) : 1.0;
yc[3] -= (s[2] * s[2])/ n;
yc[3] *= 2.0;
yc[3] /= n;
yc[3] = (yc[3] > 0.0) ? (1.0 / sqrt(yc[3])) : 1.0;
} else {
s[7] = 1.0;
s[8] = 1.0;
xc[3] = 1.0;
yc[3] = 1.0;
}
xc[3] = s[7];
yc[3] = s[8];

rewind(fp0);

Expand All @@ -227,16 +225,18 @@ int main(int argc, char *argv[])
if (np >= 8)
{
/* вычислить разности */
dx[0] = (x[0] - xc[0]) / xc[3];
dx[1] = (x[1] - xc[1]) / xc[3];
dx[2] = (x[2] - xc[2]) / yc[3];
for (i = 0; i < 3; i++)
{
dx[i] = (x[i] - xc[i]);
dy[i] = (y[i] - yc[i]);
}
dx[0] *= xc[3];
dx[1] *= xc[3];
dx[2] *= yc[3];
tx = dx[0];
ty = dx[1];
tx2 = tx * tx;
ty2 = ty * ty;
dy[0] = (y[0] - yc[0]);
dy[1] = (y[1] - yc[1]);
dy[2] = (y[2] - yc[2]);
/* суммировать */
s[0] += (tx2 + ty2) * wgt;
s[1] += (tx2 * tx + tx * ty2) * wgt;
Expand All @@ -261,16 +261,25 @@ int main(int argc, char *argv[])
s[18] = s[13] * (s[9] * s[12] - s[10] * s[11]) + s[8] * s[8] * s[11];
s[19] = s[13] * (s[9] * s[11] - s[8] * s[12]);
s[20] = s[8] * s[8] * s[8] + s[13] * (s[9] * s[9] - s[8] * s[10]);
s[13] *= xc[3];
s[14] *= xc[3];
s[15] *= xc[3];
s[16] *= xc[3];
s[15] *= xc[3];
s[16] *= xc[3];
s[18] *= yc[3];
s[19] *= yc[3];
s[19] *= yc[3];

rewind(fp0);

/* найти первичные параметры */
if (s[17] < 0.0 || s[17] > 0.0)
{
a[1][0] = s[13] / s[17] / xc[3];
a[1][1] = s[14] / s[17] / xc[3];
a[2][0] = s[15] / s[17] / xc[3] / xc[3];
a[2][1] = s[16] / s[17] / xc[3] / xc[3];
a[1][0] = s[13] / s[17];
a[1][1] = s[14] / s[17];
a[2][0] = s[15] / s[17];
a[2][1] = s[16] / s[17];
} else {
a[1][0] = 1.0;
a[1][1] = 0.0;
Expand All @@ -279,8 +288,8 @@ int main(int argc, char *argv[])
}
if (s[20] < 0.0 || s[20] > 0.0)
{
a[2][2] = s[19] / s[20] / yc[3] / yc[3];
a[1][2] = s[18] / s[20] / yc[3];
a[2][2] = s[19] / s[20];
a[1][2] = s[18] / s[20];
a[1][2] -= (2.0 * a[2][2] * xc[2]);
} else {
a[1][2] = 1.0;
Expand Down
6 changes: 3 additions & 3 deletions src/geositer500.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Name: geositer500.c
Version: 2.3
Date: 2020-09-24
Version: 2.4
Date: 2020-09-28
Author: zvezdochiot (https://github.com/zvezdochiot)
Author: Zoltan Siki (https://github.com/zsiki)
*
Expand Down Expand Up @@ -54,7 +54,7 @@ OKD-12 3.8890 288.39138889 133.60805556
#include <string.h>

#define PNAME "GeoSIter500"
#define PVERSION "2.3"
#define PVERSION "2.4"

#define defUnits "DEG"

Expand Down
6 changes: 3 additions & 3 deletions src/geoszbtoyxh.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Name: geoszbtoyxh.c
Version: 2.3
Date: 2020-09-24
Version: 2.4
Date: 2020-09-28
Author: zvezdochiot (https://github.com/zvezdochiot)
Author: Zoltan Siki (https://github.com/zsiki)
*
Expand Down Expand Up @@ -55,7 +55,7 @@ OKD-12 -2.6721 2.5453 1.2270
#include <string.h>

#define PNAME "GeoSZBtoYXH"
#define PVERSION "2.3"
#define PVERSION "2.4"

#define defUnits "DEG"

Expand Down

0 comments on commit 55a14d6

Please sign in to comment.