A little help with trig please.

Blitz3D Forums/Blitz3D Programming/A little help with trig please.

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.

Something like this what you mean?

	Graphics 800,600
	SetBuffer BackBuffer()
	
	; Set the two vertices defining the 'start' line.
	start_x# = 100
	start_y# = 300
	end_x# = 120
	end_y# = 180
	
	delta_x = end_x - start_x
	delta_y = end_y - start_y

	ang# = ATan2(delta_y,delta_x)
	side_len# = Sqr(delta_x*delta_x + delta_y*delta_y)
		
	While Not KeyHit(1)
	
		Cls

		Locate 0,0
		num_sides = Input("Enter number of sides: ")

		; Draw 'start' line in red.
		Color 255,0,0
		Line start_x,start_y,end_x,end_y
		
		; Draw remaining poly sides in white.
		Color 255,255,255
		x1 = end_x
		y1 = end_y
		d_ang# = 360.0 / num_sides
		For n = 1 To num_sides-1
			x2 = x1 + (Cos((d_ang*n) + ang) * side_len)
			y2 = y1 + (Sin((d_ang*n) + ang) * side_len)
			
			Line x1,y1,x2,y2
			
			x1 = x2
			y1 = y2
		Next
	
		VWait : Flip False
		
	Wend
	
	End