From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- utils/genrandomvectors/genrandomvectors.cpp | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 utils/genrandomvectors/genrandomvectors.cpp (limited to 'utils/genrandomvectors/genrandomvectors.cpp') 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 +#include +#include "vstdlib/random.h" +#include "math.h" + +void main( int argc, char **argv ) +{ + if( argc != 2 ) + { + fprintf( stderr, "Usage: genrandomvectors \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 ); + } +} -- cgit v1.2.3