Ug - must have been drunk when committing those two de-align lines! - this one works
This commit is contained in:
parent
093702d773
commit
cd08f83aa5
1 changed files with 9 additions and 10 deletions
|
@ -83,25 +83,24 @@ Point3D FGATCAlignedProjection::ConvertToLocal(Point3D pt) {
|
||||||
double delta_lon = pt.lon() - origin.lon();
|
double delta_lon = pt.lon() - origin.lon();
|
||||||
double y = sin(delta_lat * DCL_DEGREES_TO_RADIANS) * SG_EQUATORIAL_RADIUS_M;
|
double y = sin(delta_lat * DCL_DEGREES_TO_RADIANS) * SG_EQUATORIAL_RADIUS_M;
|
||||||
double x = sin(delta_lon * DCL_DEGREES_TO_RADIANS) * SG_EQUATORIAL_RADIUS_M * correction_factor;
|
double x = sin(delta_lon * DCL_DEGREES_TO_RADIANS) * SG_EQUATORIAL_RADIUS_M * correction_factor;
|
||||||
//cout << "Before alignment, x = " << x << " y = " << y << '\n';
|
|
||||||
|
|
||||||
// Align
|
// Align
|
||||||
double xbar = x;
|
double xbar = x;
|
||||||
x = x*cos(theta) - y*sin(theta);
|
x = x*cos(theta) - y*sin(theta);
|
||||||
y = (xbar*sin(theta)) + (y*cos(theta));
|
y = (xbar*sin(theta)) + (y*cos(theta));
|
||||||
//cout << "After alignment, x = " << x << " y = " << y << '\n';
|
|
||||||
|
|
||||||
return(Point3D(x,y,0.0));
|
return(Point3D(x,y,0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Point3D FGATCAlignedProjection::ConvertFromLocal(Point3D pt) {
|
Point3D FGATCAlignedProjection::ConvertFromLocal(Point3D pt) {
|
||||||
// de-align
|
// de-align
|
||||||
double x = (pt.x() + pt.y()*sin(theta)) / cos(theta);
|
double thi = theta * -1.0;
|
||||||
double y = (pt.y() - pt.x()*sin(theta)) / cos(theta);
|
double x = pt.x()*cos(thi) - pt.y()*sin(thi);
|
||||||
|
double y = (pt.x()*sin(thi)) + (pt.y()*cos(thi));
|
||||||
// convert from orthogonal to lat/lon
|
|
||||||
double delta_lat = asin(y / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES;
|
// convert from orthogonal to lat/lon
|
||||||
double delta_lon = (asin(x / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES) / correction_factor;
|
double delta_lat = asin(y / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES;
|
||||||
|
double delta_lon = (asin(x / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES) / correction_factor;
|
||||||
|
|
||||||
return(Point3D(origin.lon()+delta_lon, origin.lat()+delta_lat, 0.0));
|
return(Point3D(origin.lon()+delta_lon, origin.lat()+delta_lat, 0.0));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue