Terrain Analyzer
A Program to Analyze Gradient Statistics
|
Main. More...
Functions | |
bool | ReadHeightData () |
Read height data. | |
void | RecordGradient (double g, int k) |
Record statistics for a gradient. | |
double | ht (int x, int y) |
Get the height. | |
void | ProcessSlopeData (int k) |
Process the slope data. | |
void | SaveSlopeStats () |
Save slope statistics. | |
int | main (int argc, char *argv[]) |
Main. | |
Variables | |
const int | GRIDSIZE = 20 |
Number of DEM files on one side of square grid. | |
const int | CELLSIZE = 4000 |
Number of points on one side of a DEM file. | |
const unsigned int | ARRAYSIZE = CELLSIZE*GRIDSIZE |
Number of points on one side of the whole array of heights. | |
const int | NUMOCTAVES = 16 |
Number of octaves. | |
const int | MIDOCTAVE = 9 |
First octave at which width is greater than height. | |
const int | GRANULARITY = 50 |
Granularity of distribution. | |
const double | MAXGRADIENT = 1.0 |
Maximum gradient sampled. | |
const double | GRADIENT_DELTA = (double)MAXGRADIENT/GRANULARITY |
Small change in gradient. | |
const double | GRADIENT_DELTA_INV = 1.0/GRADIENT_DELTA |
Inverse of GRADIENT_DELTA. | |
double | g_dMaxSlope [NUMOCTAVES] |
Maximum slope in each octave. | |
double | g_dSumSlope [NUMOCTAVES] |
Sum of slopes in each octave, for computing averages. | |
long long | g_nPointCount [NUMOCTAVES] |
Number of samples. | |
long long | g_nDistribution [NUMOCTAVES][GRANULARITY] |
Gradient distribution for each octave. | |
unsigned char * | g_pHeightBuffer = NULL |
Buffer for packed height data. | |
unsigned short * | g_nHeight |
Swizzle to access height data by word instead of by byte. | |
const long long | g_nBufSize |
Size of height buffer. | |
int | g_nStartTime |
Time that computation began. | |
double ht | ( | int | x, |
int | y | ||
) |
Get the elevation at a given point.
x | X coordinate of point. |
y | Y coordinate of point. |
int main | ( | int | argc, |
char * | argv[] | ||
) |
Does initialization, allocates a honking big block of memory (so you'd better compile this in 64 bit mode, and hopefully you have at least 16GB RAM onboard), reads the data, performs the analysis, saves the results, deallocates the memory and shuts down.
argc | Argument count |
argv | Arguments. |
void ProcessSlopeData | ( | int | k | ) |
Process all of the slopes for a given octave.
k | The octave number. |
bool ReadHeightData | ( | ) |
Read the height data from a packed file UtahDEMData.bin into g_pHeightBuffer, which it assumes points to a buffer of the right size. This data will be accessed automagically through g_nHeight.
void RecordGradient | ( | double | g, |
int | k | ||
) |
Add the new gradient to the octave statistics we are gathering.
g | A new gradient. |
k | The octave from which the gradient was recorded. |
void SaveSlopeStats | ( | ) |
Save the gradient statistics to a tab-separated text file output.txt.