View Single Post
Re: POD-bot back into shape.
Old
  (#332)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: POD-bot back into shape. - 02-04-2004

Anyway I have tested it with this little program and it's all ok:
Code:
  #include <stdio.h>
  
  float AngleNormalize(float angle)
  {
     if (angle >= 180)
  	  angle -= 360 * (int)(angle / 360 + 0.5);
     if (angle < -180)
  	  angle += 360 * (int)(-angle / 360 + 0.5);
     return angle;
  }
  
  
  main()
  {
     float a;
     float b;
     for (a = -2532.3; a < 3602.3; a += 0.1235)
     {
  	  b = AngleNormalize(a);
  	  if (b >= 180 || b < -180)
  	  {
  	 printf("your code is wrong !\n");
  	 return;
  	  }
     }
     printf("your code is right !\n");
  }
Also the asserts are never failed in YaPB. You can try playing YaPB for a few round and I'm pretty sure you'll find no angles are mess up.

Last edited by Whistler; 03-04-2004 at 02:21..