GKTransformNode.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00042
00043
00044
00045 #include "../tool/disable4786.h"
00046
00047 #include "GKTransformNode.h"
00048 #include <math.h>
00049
00050
00051 #ifndef OT_NO_GK_SUPPORT
00052
00053
00054 namespace ot {
00055
00056 GKTransformNode::GKTransformNode( double a_ , double b_, double m_,
00057 double alpha_, double beta_, double gamma_, double delta_,
00058 Mode mode_ ) :
00059 a( a_ ),
00060 b( b_ ),
00061 meridian( m_ * MathUtils::GradToRad ),
00062 alpha( alpha_ ),
00063 beta( beta_ ),
00064 gamma( gamma_ ),
00065 delta( delta_ ),
00066 mode( mode_ )
00067 {}
00068
00069 Event* GKTransformNode::transformEvent( Event* event)
00070 {
00071
00072
00073 const double ferro = (17.0 + 40.0 / 60.0) * MathUtils::GradToRad;
00074
00075
00076 const double falseNorthing = 5000000.0;
00077
00078 if( to == mode )
00079 {
00080 double B = event->getPosition()[0];
00081 double sinB = sin(B);
00082 double cosB = cos(B);
00083 double L = event->getPosition()[1];
00084 double dL = ( L + ferro - meridian );
00085
00086 double Sm = alpha * B / MathUtils::GradToRad - beta * sin(2.0 * B) + gamma * sin(4.0 * B) - delta * sin(6.0 * B);
00087
00088 double e2 = 1.0 - (b*b) / (a*a);
00089 double N = a / (sqrt( 1.0 - e2 * sinB * sinB ));
00090 double eta2 = ((a*a) / (b*b) - 1)*cosB*cosB;
00091 double t = tan( B );
00092 double corr_x = 1.0 + (dL*dL)*(cosB*cosB)*(5.0 - t*t + 9.0*eta2 + 4.0*eta2*eta2) / 12.0 +
00093 pow(dL,4.0)*pow(cosB,4.0)*(61.0-58.0*t*t+pow(t,4.0)+270.0*eta2 - 330.0*t*t*eta2) / 360.0;
00094 double corr_y = 1.0 + (dL*dL)*(cosB*cosB)*(1.0 - t*t + eta2) / 6.0 +
00095 pow(dL,4.0)*pow(cosB,4.0)*(5.0 - 18.0*t*t + pow(t,4.0) + 14.0*eta2 - 58.0*t*t*eta2) / 120.0;
00096 double x = Sm + N * dL * dL * sinB * cosB * corr_x / 2.0 - falseNorthing;
00097 double y = N * dL * cosB * corr_y;
00098
00099
00100 localEvent.getPosition()[0] = (float)x;
00101 localEvent.getPosition()[1] = (float)y;
00102 }
00103 else
00104 {
00105 double x = event->getPosition()[0];
00106 double y = event->getPosition()[1];
00107 double xa = x * MathUtils::GradToRad / alpha;
00108 double Bf = (xa + beta*sin(2*xa) + gamma*sin(4*xa) + delta*sin(6*xa)) * MathUtils::GradToRad;
00109 double t = tan(Bf);
00110 double t2 = t*t;
00111 double e2 = 1 - (b*b) / (a*a);
00112 double eta2 = ((a*a) / (b*b) - 1)*cos(Bf)*cos(Bf);
00113 double W = sqrt(1 - e2 *sin(Bf)*sin(Bf));
00114 double N = a / W;
00115 double M = b*b / (a*W*W*W);
00116 double corr_b = 1 - (y*y)*(5 + 3*t2 + eta2 - 9*t2*eta2)/(12*N*N) +
00117 (y*y*y*y)*(61+90*t2+45*t2*t2)/(360*N*N*N*N);
00118 double corr_l = 1 - (y*y)*(1 + 2*t2 + eta2)/(6*N*N) +
00119 (y*y*y*y)*(5 + 28*t2 + 24*t2*t2)/(120*N*N*N*N);
00120 double B = Bf - (y*y*t)*corr_b/(2*M*N);
00121 double L = y*corr_l/(N*cos(Bf)) + meridian - ferro;
00122
00123 localEvent.getPosition()[0] = (float)B;
00124 localEvent.getPosition()[1] = (float)L;
00125 }
00126
00127
00128 localEvent.getPosition()[2] = event->getPosition()[2];
00129
00130
00131
00132 localEvent.copyAllButStdAttr(*event);
00133 localEvent.getOrientation() = event->getOrientation();
00134
00135 localEvent.getConfidence() = event->getConfidence();
00136 localEvent.getButton() = event->getButton();
00137 localEvent.time = event->time;
00138 return & localEvent;
00139 }
00140
00141 }
00142
00143
00144 #else
00145 #pragma message(">>> OT_NO_GK_SUPPORT")
00146 #endif //OT_NO_GK_SUPPORT
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162