1
0
Fork 0

Convert helipad routine to Vec3

This commit is contained in:
Christian Schmitt 2012-10-06 12:54:14 +02:00
parent 4d3f1efd30
commit bda3ee3a91
4 changed files with 11 additions and 17 deletions

View file

@ -566,8 +566,8 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
} }
for (unsigned int i=0; i<helipads.size(); i++) for (unsigned int i=0; i<helipads.size(); i++)
{ {
apt_lon += helipads[i]->GetLoc().x(); apt_lon += helipads[i]->GetLoc().getLongitudeDeg();
apt_lat += helipads[i]->GetLoc().y(); apt_lat += helipads[i]->GetLoc().getLatitudeDeg();
num_samples++; num_samples++;
} }
apt_lon = apt_lon / (double)num_samples; apt_lon = apt_lon / (double)num_samples;

View file

@ -46,9 +46,7 @@ superpoly_list Helipad::gen_helipad_lights(double maxsize){
point_list y_normals; y_normals.clear(); point_list y_normals; y_normals.clear();
// Vector calculation // Vector calculation
Point3D vec = sgGeodToCart( GetLoc() * SG_DEGREES_TO_RADIANS ); SGVec3d vec = normalize(SGVec3d::fromGeod(GetLoc()));
double length = vec.distance3D( Point3D(0.0) );
vec = vec / length;
// Create yellow edge lights, 5m spacing // Create yellow edge lights, 5m spacing
int divs = (int)(maxsize / 5.0); int divs = (int)(maxsize / 5.0);
@ -60,19 +58,15 @@ superpoly_list Helipad::gen_helipad_lights(double maxsize){
inc = (area.get_pt(0, i==3 ? 0 : i+1) - area.get_pt(0,i)) / divs; inc = (area.get_pt(0, i==3 ? 0 : i+1) - area.get_pt(0,i)) / divs;
for ( int j = 0; j < divs; ++j) { for ( int j = 0; j < divs; ++j) {
y_lights.push_back( pt); y_lights.push_back( pt);
y_normals.push_back( vec ); y_normals.push_back(Point3D::fromSGVec3(vec));
pt += inc; pt += inc;
} }
} }
// Create a circle of yellow lights where the white texture circle is // Create a circle of yellow lights where the white texture circle is
double lat = 0, lon = 0, az;
for (int deg = 0; deg < 360; deg += 45){ for (int deg = 0; deg < 360; deg += 45){
geo_direct_wgs_84(0, heli.lat, heli.lon, deg , y_lights.push_back( Point3D::fromSGGeod( SGGeodesy::direct(GetLoc(), deg, maxsize * 0.46)) );
maxsize * 0.46 , &lat, &lon, &az ); y_normals.push_back( Point3D::fromSGVec3(vec) );
y_lights.push_back( Point3D( lon, lat, 0.0 ) );
y_normals.push_back( vec );
} }
TGPolygon lights_poly; lights_poly.erase(); TGPolygon lights_poly; lights_poly.erase();
@ -141,7 +135,7 @@ void Helipad::BuildBtg( superpoly_list *rwy_polys,
area_side = true; area_side = true;
} }
TGPolygon helipad = gen_wgs84_area( GetLoc(), maxsize, 0, 0, maxsize, heli.heading, false); TGPolygon helipad = gen_wgs84_area( Point3D::fromSGGeod(GetLoc()), maxsize, 0, 0, maxsize, heli.heading, false);
helipad = snap( helipad, gSnap ); helipad = snap( helipad, gSnap );
string material, shoulder_mat; string material, shoulder_mat;
if (heli.surface == 1) if (heli.surface == 1)

View file

@ -26,9 +26,9 @@ public:
Helipad(char* def); Helipad(char* def);
void BuildBtg( superpoly_list* heli_polys, texparams_list* texparams, superpoly_list* heli_lights, ClipPolyType* accum, poly_list& slivers, TGPolygon* apt_base, TGPolygon* apt_clearing ); void BuildBtg( superpoly_list* heli_polys, texparams_list* texparams, superpoly_list* heli_lights, ClipPolyType* accum, poly_list& slivers, TGPolygon* apt_base, TGPolygon* apt_clearing );
Point3D GetLoc() SGGeod GetLoc()
{ {
return Point3D( heli.lon, heli.lat, 0.0f ); return SGGeod::fromDeg(heli.lon, heli.lat);
} }
bool GetsShoulder() bool GetsShoulder()
@ -66,7 +66,7 @@ private:
// (return result points in degrees) // (return result points in degrees)
TGPolygon gen_runway_area_w_extend( double alt_m, double length_extend, double displ1, double displ2, double width_extend ) TGPolygon gen_runway_area_w_extend( double alt_m, double length_extend, double displ1, double displ2, double width_extend )
{ {
return ( gen_wgs84_area( GetLoc(), heli.length + 2.0*length_extend, displ1, displ2, heli.width + 2.0*width_extend, heli.heading, false) ); return ( gen_wgs84_area( Point3D::fromSGGeod(GetLoc()), heli.length + 2.0*length_extend, displ1, displ2, heli.width + 2.0*width_extend, heli.heading, false) );
} }
superpoly_list gen_helipad_lights(double maxsize); superpoly_list gen_helipad_lights(double maxsize);

View file

@ -722,7 +722,7 @@ bool Scheduler::AddAirports( long start_pos, float min_lat, float min_lon, float
// a winner // a winner
{ {
Helipad* helipad = new Helipad(def); Helipad* helipad = new Helipad(def);
Point3D loc = helipad->GetLoc(); Point3D loc = Point3D::fromSGGeod(helipad->GetLoc()) ;
if ( (loc.x() >= min_lon ) && if ( (loc.x() >= min_lon ) &&
(loc.y() >= min_lat ) && (loc.y() >= min_lat ) &&
(loc.x() <= max_lon ) && (loc.x() <= max_lon ) &&