Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Scenery.cpp File Reference

Implements scenery and terrain related utility functions. More...

#include <math.h>
#include "../Include/Utility.h"
#include "../Include/Globals.h"

Go to the source code of this file.

Defines

#define ARCSEC2RAD   ((2.0 * PI) / 3600.0)
#define QGT_FLAT_CARTESIAN_BOUND_FT   (2.5633E+5)

Functions

void init_globe_tile_table ()
 Initialize globe tile latitude lookup table.
static double globe_tile_lon (int x)
 Find the eastern longitude boundary for a given GT x-index.
void qgt_position (SPosition pos, int &qx, int &qz, double &x, double &z)
 Calculate distance between a position and the center of a given QGT, in QGT units.
void delta_qgt (SPosition pos, int rx, int rz, double &x, double &z)
void lat_lon_to_qgt (double latArg, double lonArg, int &x, int &z)
 Convert lat/lon into quarter globe tile indices.
void lat_lon_to_globe_tile (double latArg, double lonArg, int &x, int &z)
 Convert lat/lon into globe tile indices.
void globe_tile_lon_bounds (int x, double &w, double &e)
 Find longitude bounds for a given GT x-index.
void globe_tile_lat_bounds (int z, double &s, double &n)
 Find latitude bounds for a given GT x-index.
void qgt_lon_bounds (int x, double &w, double &e)
 Find longitude bounds for a given QGT x-index.
void qgt_lat_bounds (int z, double &s, double &n)
 Find latitude bounds for a given QGT z-index.
void FormatPosition (SPosition pos, char *s)
void FormatRADec (double ra, double dec, char *s)
void FormatSiderealTime (double st, char *s)
void CIE_Yxy_to_XYZ (const SCIE in, SCIE &out)
void CIE_XYZ_to_RGB_D65 (const SCIE XYZ, sgdVec3 &RGB)
float TerrainScale (SPosition pos)
float GlobeTileDistance (void)
SVector PosToFlatCartesian (SPosition pos, int x, int z)
SVector PosToFlatCartesian (SPosition pos)
SVector PosToScaledFlatCartesian (SPosition pos)
SVector PosToFlatCartesianQgt (SPosition pos, int x, int z)
 Find unscaled cartesian coordinate of world position relative to the given QGT.
SVector PosToFlatCartesianQgt (SPosition pos)
 Find cartesian coordinate of world position relative to the QGT it is in.
SVector PosToScaledFlatCartesianQgt (SPosition pos)
 Find scaled cartesian coordinate of world position relative to the QGT it is in.

Variables

static double globe_tile_lat_table [129]


Detailed Description

Thanks to Michael Jastrzebski, Ken Salter, Frank Racis for their previous work with with latitude/longitude to globe tile conversion!

Definition in file Scenery.cpp.


Define Documentation

#define ARCSEC2RAD   ((2.0 * PI) / 3600.0)
 

Definition at line 394 of file Scenery.cpp.

#define QGT_FLAT_CARTESIAN_BOUND_FT   (2.5633E+5)
 

Definition at line 612 of file Scenery.cpp.


Function Documentation

void CIE_XYZ_to_RGB_D65 const SCIE  XYZ,
sgdVec3 &  RGB
 

Definition at line 498 of file Scenery.cpp.

References SCIE::XYZ.

void CIE_Yxy_to_XYZ const SCIE  in,
SCIE out
 

Definition at line 487 of file Scenery.cpp.

References SCIE::XYZ, and SCIE::Yxy.

void delta_qgt SPosition  pos,
int  rx,
int  rz,
double &  x,
double &  z
 

Definition at line 191 of file Scenery.cpp.

References qgt_position().

Referenced by CQuarterGlobeTile::UpdatePosition().

void FormatPosition SPosition  pos,
char *  s
 

Definition at line 399 of file Scenery.cpp.

References SPosition::lat, and SPosition::lon.

Referenced by CTerrainTile::FormatBounds(), init_globe_tile_table(), CCameraManager::Print(), and test_geodesy().

void FormatRADec double  ra,
double  dec,
char *  s
 

Definition at line 437 of file Scenery.cpp.

References RadToDeg(), and WrapTwoPi().

Referenced by CSkyManager::Print().

void FormatSiderealTime double  st,
char *  s
 

Definition at line 466 of file Scenery.cpp.

Referenced by CTimeManager::Print().

void globe_tile_lat_bounds int  z,
double &  s,
double &  n
 

Parameters:
z GT z-index in range [0,255]
&w Updated with western longitude boundary in degrees E of prime meridian
&e Updated with eastern longitude boundary in degrees E of prime meridian

Definition at line 336 of file Scenery.cpp.

References globe_tile_lat_table, and gtfo.

Referenced by CDetailTile::CDetailTile(), CSuperTile::CSuperTile(), init_globe_tile_table(), lat_lon_to_qgt(), PosToFlatCartesian(), and qgt_lat_bounds().

static double globe_tile_lon int  x  )  [static]
 

Parameters:
x GT x-index in range [0,255]
Returns:
Longitude of eastern boundary in degrees E of prime meridian

Definition at line 156 of file Scenery.cpp.

Referenced by globe_tile_lon_bounds().

void globe_tile_lon_bounds int  x,
double &  w,
double &  e
 

Parameters:
x GT x-index in range [0,255]
&w Updated with western longitude boundary in degrees E of prime meridian
&e Updated with eastern longitude boundary in degrees E of prime meridian

Definition at line 317 of file Scenery.cpp.

References globe_tile_lon(), and gtfo.

Referenced by CDetailTile::CDetailTile(), CSuperTile::CSuperTile(), lat_lon_to_qgt(), PosToFlatCartesian(), and qgt_lon_bounds().

float GlobeTileDistance void   ) 
 

Definition at line 532 of file Scenery.cpp.

References NmToFeet().

void init_globe_tile_table  ) 
 

The globe tile latitude lookup table allows determination of N and S latitude boundaries for all 256 possible globe tile z-indices. Entry zero is latitude 0 (the equator) and successive entries are the latitudes of each globe tile boundary approaching the poles.

The formula for globe tile latitude boundaries is: k = (360 / 256) L(0) = 0 L(n) = L(n-1) + k * cos[L(n-1)]

Definition at line 61 of file Scenery.cpp.

References SPosition::alt, DegToRad(), FormatPosition(), globe_tile_lat_bounds(), globe_tile_lat_table, SPosition::lat, SPosition::lon, and qgt_lat_bounds().

Referenced by Initialize().

void lat_lon_to_globe_tile double  latArg,
double  lonArg,
int &  x,
int &  z
 

Parameters:
latArg Latitude is specified as decimal value in the range [-90.0, +90.0] \ as degrees North (+) or South (-) of the Equator. The Fly! scenery \ system does not model extreme latitudes north or south of approx. \ 85 degrees.
lonArg Longitude is specified as decimal value in the range [-180.0, 180.0] \ as degrees East (+) or West (-) of the Prime Meridian.
iLatGlobe Globe tile z-index (latitude)
iLonGlobe Globe tile x-index (longitude)

Definition at line 264 of file Scenery.cpp.

References globe_tile_lat_table, and gtfo.

Referenced by GetLocalNavaids(), lat_lon_to_qgt(), PosToFlatCartesian(), and PosToScaledFlatCartesian().

void lat_lon_to_qgt double  latArg,
double  lonArg,
int &  x,
int &  z
 

Parameters:
latArg Latitude is specified as arcseconds north (+) or south (-) of the equator
lonArg Longitude is specified as arcseconds east of the Prime Meridian
x Quarter globe tile x-index (longitude), range [0,511]
z Quarter globe tile z-index (latitude), range [0,511]
Returns:
bool Indicates success or failure of the conversion. If the function \ returns false then the values of the tile indices are undefined.

Definition at line 213 of file Scenery.cpp.

References globe_tile_lat_bounds(), globe_tile_lon_bounds(), and lat_lon_to_globe_tile().

Referenced by PosToFlatCartesianQgt(), qgt_position(), and CTerrainManager::SetPosition().

SVector PosToFlatCartesian SPosition  pos  ) 
 

Definition at line 584 of file Scenery.cpp.

References SPosition::lat, lat_lon_to_globe_tile(), SPosition::lon, and PosToFlatCartesian().

SVector PosToFlatCartesian SPosition  pos,
int  x,
int  z
 

Definition at line 544 of file Scenery.cpp.

References SPosition::alt, globe_tile_lat_bounds(), globe_tile_lon_bounds(), SPosition::lat, SPosition::lon, NmToFeet(), SVector::x, SVector::y, and SVector::z.

SVector PosToFlatCartesianQgt SPosition  pos  ) 
 

Parameters:
pos Position in Fly SPosition format (lat/lon double arcsecs, alt 'MSL)
Returns:
Cartesian coordinates relative to the QGT the position is in

Definition at line 673 of file Scenery.cpp.

References SPosition::lat, lat_lon_to_qgt(), SPosition::lon, and PosToFlatCartesianQgt().

SVector PosToFlatCartesianQgt SPosition  pos,
int  x,
int  z
 

Parameters:
pos World position in Fly SPosition format
x QGT x-index in range [0,511]
z QGT z-index in range [0,511]
Returns:
Unscaled Cartesian coordinates relative to the given QGT

Definition at line 623 of file Scenery.cpp.

References SPosition::alt, SPosition::lat, SPosition::lon, NmToFeet(), qgt_lat_bounds(), qgt_lon_bounds(), SVector::x, SVector::y, and SVector::z.

SVector PosToScaledFlatCartesian SPosition  pos  ) 
 

Definition at line 591 of file Scenery.cpp.

References SPosition::lat, lat_lon_to_globe_tile(), SPosition::lon, PosToFlatCartesian(), TerrainScale(), SVector::x, and SVector::y.

SVector PosToScaledFlatCartesianQgt SPosition  pos  ) 
 

Parameters:
pos Position in Fly SPosition format (lat/lon double arcsecs, alt 'MSL)
Returns:
Scaled Cartesian coordinates relative to the QGT the position is in

Definition at line 686 of file Scenery.cpp.

References PosToFlatCartesianQgt(), TerrainScale(), SVector::x, and SVector::y.

Referenced by CCameraManager::Print(), CTerrainManager::SetCamera(), and CModelObject::SetPosition().

void qgt_lat_bounds int  z,
double &  s,
double &  n
 

Parameters:
z QGT z-index in range [0,511]
&s Updated with southern latitude boundary in degrees N/S of equator
&n Updated with northern longitude boundary in degrees N/S of equator

Definition at line 380 of file Scenery.cpp.

References globe_tile_lat_bounds().

Referenced by init_globe_tile_table(), PosToFlatCartesianQgt(), and qgt_position().

void qgt_lon_bounds int  x,
double &  w,
double &  e
 

Parameters:
x QGT x-index in range [0,511]
&w Updated with western longitude boundary in degrees E of prime meridian
&e Updated with eastern longitude boundary in degrees E of prime meridian

Definition at line 359 of file Scenery.cpp.

References globe_tile_lon_bounds().

Referenced by PosToFlatCartesianQgt(), and qgt_position().

void qgt_position SPosition  pos,
int &  qx,
int &  qz,
double &  x,
double &  z
 

Parameters:
x Longitude delta in QGT units
z Latitude delta in QGT units
Returns:
bool Indicates success or failure of the conversion. If the function \ returns false then the values of the tile indices are undefined.

Definition at line 171 of file Scenery.cpp.

References SPosition::lat, lat_lon_to_qgt(), SPosition::lon, qgt_lat_bounds(), and qgt_lon_bounds().

Referenced by delta_qgt().

float TerrainScale SPosition  pos  ) 
 

Definition at line 524 of file Scenery.cpp.

References DegToRad(), and SPosition::lat.

Referenced by CTerrainManager::Draw(), PosToScaledFlatCartesian(), PosToScaledFlatCartesianQgt(), CTerrainManager::SetCamera(), and CTerrainManager::SetPosition().


Variable Documentation

double globe_tile_lat_table[129] [static]
 

Definition at line 46 of file Scenery.cpp.

Referenced by globe_tile_lat_bounds(), init_globe_tile_table(), and lat_lon_to_globe_tile().

SourceForge.net Logo Documentation generated by doxygen