public static Vertices createGear( float radius, int numberOfTeeth, float tipPercentage, float toothHeight )
{
var vertices = new Vertices();
float stepSize = MathHelper.TwoPi / numberOfTeeth;
tipPercentage /= 100f;
MathHelper.Clamp( tipPercentage, 0f, 1f );
float toothTipStepSize = ( stepSize / 2f ) * tipPercentage;
float toothAngleStepSize = ( stepSize - ( toothTipStepSize * 2f ) ) / 2f;
for( int i = numberOfTeeth - 1; i >= 0; --i )
{
if( toothTipStepSize > 0f )
{
vertices.Add(
new Vector2( radius *
(float)Math.Cos( stepSize * i + toothAngleStepSize * 2f + toothTipStepSize ),
-radius *
(float)Math.Sin( stepSize * i + toothAngleStepSize * 2f + toothTipStepSize ) ) );
vertices.Add(
new Vector2( ( radius + toothHeight ) *
(float)Math.Cos( stepSize * i + toothAngleStepSize + toothTipStepSize ),
-( radius + toothHeight ) *
(float)Math.Sin( stepSize * i + toothAngleStepSize + toothTipStepSize ) ) );
}
vertices.Add( new Vector2( ( radius + toothHeight ) *
(float)Math.Cos( stepSize * i + toothAngleStepSize ),
-( radius + toothHeight ) *
(float)Math.Sin( stepSize * i + toothAngleStepSize ) ) );
vertices.Add( new Vector2( radius * (float)Math.Cos( stepSize * i ),
-radius * (float)Math.Sin( stepSize * i ) ) );
}
return vertices;
}