UTIL.CPP

/*========================================================================== 
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: util.cpp
*
*@@BEGIN_MSINTERNAL
* History:
* Date By Reason
* ==== == ======
* 15-sep-97 t-craigs Created
*@@END_MSINTERNAL
*
***************************************************************************/

#include "util.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

// global declaration
double Dirx[40] =
{
0.000000,
0.156434,
0.309017,
0.453991,
0.587785,
0.707107,
0.809017,
0.891007,
0.951057,
0.987688,
1.000000,
0.987688,
0.951057,
0.891007,
0.809017,
0.707107,
0.587785,
0.453990,
0.309017,
0.156434,
0.000000,
-0.156435,
-0.309017,
-0.453991,
-0.587785,
-0.707107,
-0.809017,
-0.891007,
-0.951057,
-0.987688,
-1.000000,
-0.987688,
-0.951056,
-0.891006,
-0.809017,
-0.707107,
-0.587785,
-0.453990,
-0.309017,
-0.156434
};

double Diry[40] =
{
-1.000000,
-0.987688,
-0.951057,
-0.891007,
-0.809017,
-0.707107,
-0.587785,
-0.453990,
-0.309017,
-0.156434,
0.000000,
0.156434,
0.309017,
0.453991,
0.587785,
0.707107,
0.809017,
0.891007,
0.951057,
0.987688,
1.000000,
0.987688,
0.951057,
0.891006,
0.809017,
0.707107,
0.587785,
0.453990,
0.309017,
0.156434,
0.000000,
-0.156435,
-0.309017,
-0.453991,
-0.587785,
-0.707107,
-0.809017,
-0.891007,
-0.951057,
-0.987688
};



int randInt( int low, int high )
{
int range = high - low;
int num = rand() % range;
return( num + low );
}

double randDouble( double low, double high )
{
double range = high - low;
double num = range * (double)rand()/(double)RAND_MAX;
return( num + low );
}


int getint(char**p, int def)
{
int i=0;


while (IS_SPACE(**p))
(*p)++;

if (!IS_NUM(**p))
return def;

while (IS_NUM(**p))
i = i*10 + *(*p)++ - '0';

while (IS_SPACE(**p))
(*p)++;

return i;
}