Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
735 B

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include "vstdlib/random.h"
  11. #include "math.h"
  12. void main( int argc, char **argv )
  13. {
  14. if( argc != 2 )
  15. {
  16. fprintf( stderr, "Usage: genrandomvectors <numvects>\n" );
  17. exit( -1 );
  18. }
  19. int nVectors = atoi( argv[1] );
  20. int i;
  21. RandomSeed( 0 );
  22. for( i = 0; i < nVectors; i++ )
  23. {
  24. float z = RandomFloat( -1.0f, 1.0f );
  25. float t = RandomFloat( 0, 2 * M_PI );
  26. float r = sqrt( 1.0f - z * z );
  27. float x = r * cos( t );
  28. float y = r * sin( t );
  29. printf( "Vector( %f, %f, %f ),\n", x, y, z );
  30. }
  31. }