//
// Written by Curtis Olson, started March 1999.
//
-// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the
-// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
*/
+#ifdef HAVE_CONFIG_H
+# include <simgear_config.h>
+#endif
+
#include <simgear/compiler.h>
-// #include STL_IOSTREAM
+// #include <iostream>
#include "texcoord.hxx"
-// SG_USING_STD(cout);
-// SG_USING_STD(endl);
+// using std::cout;
+// using std::endl;
#define FG_STANDARD_TEXTURE_DIMENSION 1000.0 // meters
// calculate "none stretching" texture coordinates
point_list sgCalcTexCoords( const SGBucket& b, const point_list& geod_nodes,
const int_list& fan, double scale )
+{
+ return sgCalcTexCoords(b.get_center_lat(), geod_nodes, fan, scale);
+}
+
+point_list sgCalcTexCoords( double centerLat, const point_list& geod_nodes,
+ const int_list& fan, double scale )
{
// cout << "calculating texture coordinates for a specific fan of size = "
// << fan.size() << endl;
// calculate perimeter based on center of this degree (not center
// of bucket)
- double clat = (int)b.get_center_lat();
+ double clat = (int)centerLat;
if ( clat > 0 ) {
clat = (int)clat + 0.5;
} else {
double clat_rad = clat * SGD_DEGREES_TO_RADIANS;
double cos_lat = cos( clat_rad );
double local_radius = cos_lat * SG_EQUATORIAL_RADIUS_M;
- double local_perimeter = 2.0 * local_radius * SGD_PI;
+ double local_perimeter = local_radius * SGD_2PI;
double degree_width = local_perimeter / 360.0;
// cout << "clat = " << clat << endl;
// cout << "local_perimeter = " << local_perimeter << endl;
// cout << "degree_width = " << degree_width << endl;
- double perimeter = 2.0 * SG_EQUATORIAL_RADIUS_M * SGD_PI;
+ double perimeter = SG_EQUATORIAL_RADIUS_M * SGD_2PI;
double degree_height = perimeter / 360.0;
// cout << "degree_height = " << degree_height << endl;