diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/genrandomvectors/genrandomvectors.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'utils/genrandomvectors/genrandomvectors.cpp')
| -rw-r--r-- | utils/genrandomvectors/genrandomvectors.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/utils/genrandomvectors/genrandomvectors.cpp b/utils/genrandomvectors/genrandomvectors.cpp new file mode 100644 index 0000000..6e53059 --- /dev/null +++ b/utils/genrandomvectors/genrandomvectors.cpp @@ -0,0 +1,33 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +#include <stdlib.h> +#include <stdio.h> +#include "vstdlib/random.h" +#include "math.h" + +void main( int argc, char **argv ) +{ + if( argc != 2 ) + { + fprintf( stderr, "Usage: genrandomvectors <numvects>\n" ); + exit( -1 ); + } + + int nVectors = atoi( argv[1] ); + int i; + RandomSeed( 0 ); + for( i = 0; i < nVectors; i++ ) + { + float z = RandomFloat( -1.0f, 1.0f ); + float t = RandomFloat( 0, 2 * M_PI ); + float r = sqrt( 1.0f - z * z ); + float x = r * cos( t ); + float y = r * sin( t ); + printf( "Vector( %f, %f, %f ),\n", x, y, z ); + } +} |