[Home]Trigonometry/TurnCircleRadius

Robo Home | Trigonometry | Changes | Preferences | AllPages

Difference (from prior major revision) (no other diffs)

Changed: 38c38,42
Questions / Comments
Questions / Comments

I was using radius = velocity / ( 2 * sin ( turn rate / 2 ) ) after painstakingly doing the trig. But using the small angle approximation (as you have) cuts out a sine calculation. The inaccuracy is not more than 0.02 pixels by the way. *Does global delete of Math.sin in robocode project directory*

--[Russ Graham]?



/**
 * See <a href="http://www.robowiki.net/cgi-bin/robowiki?Trigonometry/TurnCircleRadius">
 * http://www.robowiki.net/cgi-bin/robowiki?Trigonometry/TurnCircleRadius
 * </a> for a description of this method.
 * 
 * @author David Alves
 * @param velocity - velocity that the robot is traveling at
 * @return the radius of the turning circle if the robot is traveling in a circle, turning at max velocity 
 */
public double turnCircleRadius(double velocity){
   return (Math.abs(v) * 360.0 / (10.0 - .75 * Math.abs(v))) / (2.0 * Math.PI);
}


Here's the math behind this shortcut:

A robot at velocity v has a max turn rate of (10 - .75 * Math.abs(v)) degrees / tick. Therefore it takes 360 / (10 - .75 * Math.abs(v)) ticks to drive in a complete circle. After this time it will have traveled a distance of Math.abs(v) * 360 / (10 - .75 * Math.abs(v)). This is the circumference of the circle the bot is driving in, so dividing by 2 * pi gives the radius: Math.abs(v) * 360 / (10 - .75 * Math.abs(v)) / (2 * Math.PI). Note that this is not an exact answer (bots don't drive in continuous curves), but it should be within a pixel or two.

Radius at velocity 8: 114.6
Radius at velocity 7: 84.4
Radius at velocity 6: 62.5
Radius at velocity 5: 45.8 (SpinBot)
Radius at velocity 4: 32.7
Radius at velocity 3: 22.2
Radius at velocity 2: 13.5
Radius at velocity 1: 6.2

 --David Alves


Questions / Comments

I was using radius = velocity / ( 2 * sin ( turn rate / 2 ) ) after painstakingly doing the trig. But using the small angle approximation (as you have) cuts out a sine calculation. The inaccuracy is not more than 0.02 pixels by the way. *Does global delete of Math.sin in robocode project directory*

 --[Russ Graham]? 

Robo Home | Trigonometry | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited December 7, 2004 13:29 EST by sdn-ap-015txhousP0505.dialsprint.net (diff)
Search: