summaryrefslogtreecommitdiff
path: root/utils/genrandomvectors/genrandomvectors.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/genrandomvectors/genrandomvectors.cpp
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'utils/genrandomvectors/genrandomvectors.cpp')
-rw-r--r--utils/genrandomvectors/genrandomvectors.cpp33
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 );
+ }
+}