Convert airport objects to SGGeod and SGVec3
This commit is contained in:
parent
440ef1cfbb
commit
b5c9eb5154
1 changed files with 27 additions and 54 deletions
|
@ -1,4 +1,4 @@
|
||||||
#include <simgear/math/sg_geodesy.hxx>
|
#include <simgear/math/SGMathFwd.hxx>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include "object.hxx"
|
#include "object.hxx"
|
||||||
|
|
||||||
|
@ -17,25 +17,18 @@ void LightingObj::BuildBtg( superpoly_list* lights )
|
||||||
double left_hdg = heading - 90.0;
|
double left_hdg = heading - 90.0;
|
||||||
if ( left_hdg < 0 ) { left_hdg += 360.0; }
|
if ( left_hdg < 0 ) { left_hdg += 360.0; }
|
||||||
|
|
||||||
Point3D ref(lon, lat, 0.0);
|
SGGeod ref = SGGeod::fromDeg(lon, lat);
|
||||||
|
|
||||||
// Calculate the normal direction once for all objects.
|
// Calculate the light normal with the help of a second point
|
||||||
|
// in the object heading direction.
|
||||||
// SimGear takes care of the glideslope angle calculation from the normal
|
// SimGear takes care of the glideslope angle calculation from the normal
|
||||||
|
SGVec3d cart1 = SGVec3d::fromGeod(SGGeodesy::direct( ref, heading, 10));
|
||||||
|
SGVec3d cart2 = SGVec3d::fromGeod(ref);
|
||||||
|
|
||||||
// calculate a second point in the object heading direction
|
Point3D normal = Point3D::fromSGVec3(normalize(cart2 - cart1));
|
||||||
double lon2 = 0, lat2 = 0, r;
|
|
||||||
geo_direct_wgs_84 ( lat, lon, heading,
|
|
||||||
10, &lat2, &lon2, &r);
|
|
||||||
|
|
||||||
Point3D cart1 = sgGeodToCart( Point3D(lon2, lat2, 0.0) * SG_DEGREES_TO_RADIANS );
|
|
||||||
Point3D cart2 = sgGeodToCart( ref * SG_DEGREES_TO_RADIANS );
|
|
||||||
|
|
||||||
Point3D normal = cart2 - cart1;
|
|
||||||
double length = normal.distance3D( Point3D(0.0) );
|
|
||||||
normal = normal / length;
|
|
||||||
|
|
||||||
// We know our normal, now create the lights
|
// We know our normal, now create the lights
|
||||||
Point3D pt1;
|
SGGeod pt1;
|
||||||
|
|
||||||
if (type == 1)
|
if (type == 1)
|
||||||
{
|
{
|
||||||
|
@ -45,46 +38,34 @@ void LightingObj::BuildBtg( superpoly_list* lights )
|
||||||
// Space between the bars is 200m
|
// Space between the bars is 200m
|
||||||
|
|
||||||
// Go to downwind bar
|
// Go to downwind bar
|
||||||
geo_direct_wgs_84 ( ref.lat(), ref.lon(), heading,
|
pt1 = SGGeodesy::direct( ref, heading, -100 );
|
||||||
-100, &lat2, &lon2, &r );
|
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
|
|
||||||
// unit1
|
// unit1
|
||||||
geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg,
|
pt1 = SGGeodesy::direct( pt1, left_hdg, -5 );
|
||||||
-5, &lat2, &lon2, &r );
|
lightobj.push_back( Point3D::fromSGGeod(pt1) );
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
lightobj.push_back( pt1 );
|
|
||||||
normals.push_back( normal );
|
normals.push_back( normal );
|
||||||
|
|
||||||
// unit2+3
|
// unit2+3
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg,
|
pt1 = SGGeodesy::direct( pt1, left_hdg, 5 );
|
||||||
5, &lat2, &lon2, &r );
|
lightobj.push_back( Point3D::fromSGGeod(pt1) );
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
lightobj.push_back( pt1 );
|
|
||||||
normals.push_back( normal );
|
normals.push_back( normal );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go to upwind bar
|
// Go to upwind bar
|
||||||
geo_direct_wgs_84 ( ref.lat(), ref.lon(), heading,
|
pt1 = SGGeodesy::direct( ref, heading, 100 );
|
||||||
100, &lat2, &lon2, &r );
|
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
|
|
||||||
// unit4
|
// unit4
|
||||||
geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg,
|
pt1 = SGGeodesy::direct( pt1, left_hdg, -5 );
|
||||||
-5, &lat2, &lon2, &r );
|
lightobj.push_back( Point3D::fromSGGeod(pt1) );
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
lightobj.push_back( pt1 );
|
|
||||||
normals.push_back( normal );
|
normals.push_back( normal );
|
||||||
|
|
||||||
// unit5+6
|
// unit5+6
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg,
|
pt1 = SGGeodesy::direct( pt1, left_hdg,5 );
|
||||||
5, &lat2, &lon2, &r );
|
lightobj.push_back( Point3D::fromSGGeod(pt1) );
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
lightobj.push_back( pt1 );
|
|
||||||
normals.push_back( normal );
|
normals.push_back( normal );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,19 +74,15 @@ void LightingObj::BuildBtg( superpoly_list* lights )
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Generating PAPI 4L = " << assoc_rw);
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Generating PAPI 4L = " << assoc_rw);
|
||||||
|
|
||||||
// unit1
|
// unit1
|
||||||
geo_direct_wgs_84 ( ref.lat(), ref.lon(), left_hdg,
|
pt1 = SGGeodesy::direct( ref, left_hdg, -12 );
|
||||||
-12, &lat2, &lon2, &r );
|
lightobj.push_back( Point3D::fromSGGeod(pt1) );
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
lightobj.push_back( pt1 );
|
|
||||||
normals.push_back( normal );
|
normals.push_back( normal );
|
||||||
|
|
||||||
// unit2-4
|
// unit2-4
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg,
|
pt1 = SGGeodesy::direct( pt1, left_hdg, 8 );
|
||||||
8, &lat2, &lon2, &r );
|
lightobj.push_back( Point3D::fromSGGeod(pt1) );
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
lightobj.push_back( pt1 );
|
|
||||||
normals.push_back( normal );
|
normals.push_back( normal );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,19 +91,15 @@ void LightingObj::BuildBtg( superpoly_list* lights )
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Generating PAPI 4R = " << assoc_rw);
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Generating PAPI 4R = " << assoc_rw);
|
||||||
|
|
||||||
// unit1
|
// unit1
|
||||||
geo_direct_wgs_84 ( ref.lat(), ref.lon(), left_hdg,
|
pt1 = SGGeodesy::direct( ref, left_hdg, 12 );
|
||||||
12, &lat2, &lon2, &r );
|
lightobj.push_back( Point3D::fromSGGeod(pt1) );
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
lightobj.push_back( pt1 );
|
|
||||||
normals.push_back( normal );
|
normals.push_back( normal );
|
||||||
|
|
||||||
// unit2-4
|
// unit2-4
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
geo_direct_wgs_84 ( pt1.lat(), pt1.lon(), left_hdg,
|
pt1 = SGGeodesy::direct( pt1, left_hdg, -8 );
|
||||||
-8, &lat2, &lon2, &r );
|
lightobj.push_back( Point3D::fromSGGeod(pt1) );
|
||||||
pt1 = Point3D( lon2, lat2, 0.0 );
|
|
||||||
lightobj.push_back( pt1 );
|
|
||||||
normals.push_back( normal );
|
normals.push_back( normal );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +112,7 @@ void LightingObj::BuildBtg( superpoly_list* lights )
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Generating tri-colour VASI = " << assoc_rw);
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Generating tri-colour VASI = " << assoc_rw);
|
||||||
|
|
||||||
// only one light here
|
// only one light here
|
||||||
lightobj.push_back( ref );
|
lightobj.push_back( Point3D::fromSGGeod(ref) );
|
||||||
normals.push_back( normal );
|
normals.push_back( normal );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue