Need Help With Sin, Cos, and Tan

BlitzMax Forums/BlitzMax Beginners Area/Need Help With Sin, Cos, and Tan

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here's a little "analogue clock" example I threw together...
SuperStrict

' analogue clock example by BaH, showing use of Cos and Sin

Graphics 200, 200, 0

Local radius:Int = 98

' set the origin to the clock center
SetOrigin 100, 100

While Not KeyDown(KEY_ESCAPE)

	SetColor 255, 255, 255
	
	Local time:String = CurrentTime()
	Local hours:Int = time[..2].toInt()
	Local minutes:Int = time[3..5].toInt()
	Local seconds:Int = time[6..].toInt()

	Cls
	
	' draw face
	For Local deg:Int = 0 Until 359
		Plot Sin(deg) * radius, -Cos(deg) * radius
	Next
	
	' draw hour segments
	For Local deg:Int = 0 Until 359 Step 30
		DrawLine Sin(deg) * radius, -Cos(deg) * radius, Sin(deg) * (radius - 10), -Cos(deg) * (radius - 10)
	Next
	
	' draw hour hand - 30 degrees per tick
	Local deg:Int = (hours Mod 12) * 30
	DrawLine 0, 0, Sin(deg) * (radius/2), -Cos(deg) * (radius/2)

	' draw minute hand - 6 degrees per tick
	deg = (minutes Mod 60) * 6
	DrawLine 0, 0, Sin(deg) * (radius * 0.8), -Cos(deg) * (radius * 0.8)

	' draw second hand - 6 degrees per tick
	deg = (seconds Mod 60) * 6
	SetColor 255, 0, 0
	DrawLine 0, 0, Sin(deg) * (radius*0.75), -Cos(deg) * (radius*0.75)

	Flip

Wend


Hope it helps.