View Single Post
Re: POD-bot back into shape.
Old
  (#304)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: POD-bot back into shape. - 01-04-2004

HERE's the fix fix fix!
Code:
void UTIL_ClampAngle (float *fAngle)
{
   // Whistler, TEST your bugfixes before submitting them!!! :D
   if (*fAngle >= 180)
	  *fAngle -= 360 * ((int) (*fAngle / 360) + 1); // and not 0.5
   if (*fAngle < -180)
	  *fAngle += 360 * ((int) (-*fAngle / 360) + 1); // and not 0.5
   if ((*fAngle >= 180) || (*fAngle < -180))
	  *fAngle = 0; // heck, if we're still above the limit then something's REALLY fuckedup!
}

void UTIL_ClampVector (Vector *vecAngles)
{
   // Whistler, TEST your bugfixes before submitting them!!! :D
   if (vecAngles->x >= 180)
	  vecAngles->x -= 360 * ((int) (vecAngles->x / 360) + 1); // and not 0.5
   if (vecAngles->x < -180)
	  vecAngles->x += 360 * ((int) (-vecAngles->x / 360) + 1); // and not 0.5
   if (vecAngles->y >= 180)
	  vecAngles->y -= 360 * ((int) (vecAngles->y / 360) + 1); // and not 0.5
   if (vecAngles->y < -180)
	  vecAngles->y += 360 * ((int) (-vecAngles->y / 360) + 1); // and not 0.5
   vecAngles->z = 0.0;
   if (vecAngles->x > 89)
	  vecAngles->x = 89;
   else if (vecAngles->x < -89)
	  vecAngles->x = -89;
   if ((vecAngles->x >= 180) || (vecAngles->x < -180))
	  vecAngles->x = 0; // heck, if we're still above the limit then something's REALLY fuckedup!
   if ((vecAngles->y >= 180) || (vecAngles->y < -180))
	  vecAngles->y = 0; // heck, if we're still above the limit then something's REALLY fuckedup!
}
I'm compiling a nunux library and then I'll wrap all this up together in a .zip file.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."