Calculate Width of Circle?

Miscellaneous Forums/General Discussion/Calculate Width of Circle?

You can just use Pythagoras' theorem.

local width:Float = 2.0 * Sqr( radius*radius - ypos*ypos )

Strict

Graphics 640,480,0

Local radius:Float=100

While Not KeyDown(KEY_ESCAPE)

Cls

For Local y:Float=0 To radius Step 4
	Local hw:Float = circleHalfWidthAtY( radius, y )
	DrawLine 320-hw,240-y,320+hw,240-y
	DrawLine 320-hw,240+y,320+hw,240+y
Next

Flip
Wend


Function CircleHalfWidthAtY:Float( radius:Float, y:Float )
	Return Sqr(radius*radius - y*y )
End Function