Turn points arround the center by x degrees?

Blitz3D Forums/Blitz3D Programming/Turn points arround the center by x degrees?

bytecode77(Posted 2008) [#1]
hi!

this is a simple math question: i need to turn a figure (in this example just a line) arround the center of the coordinate system by a certain angle

Graphics 640, 480, 32, 2
SetBuffer BackBuffer()

While Not KeyHit(1)
	;the center of the coordinate system
	Plot 300, 200
	
	;these variables are the coordinates of the line,
	;hich needs to be turned arround the center of
	;the coordinate system
	x1 = -50
	y1 = 80
	x2 = 50
	y1 = 80
	;(they can be ANYTHING besides this)
	
	;the calculations, which are wrong!
	timer = timer + 5
	p1x = x1 * Cos(timer)
	p1y = y1 * Sin(timer)
	p2x = x2 * Cos(timer)
	p2y = y1 * Sin(timer)
	
	;just draw it
	Line 300 + p1x, 200 + p1y, 300 + p2x, 200 + p2y
	Flip
	Cls
Wend
End


but this is not working as it should. i already drew a few sheets of paper with my thoughts and they all ended up in the garbage. i'd appreceate it, if someone would help me:)

thanks so far :)


Stevie G(Posted 2008) [#2]
Like this ?

Graphics 640, 480, 32, 2
SetBuffer BackBuffer()

Global Cx# = 300
Global Cy# = 200

While Not KeyHit(1)

	Angle = Angle + 1

	;the center of the coordinate system
	Plot Cx, Cy
	
	;these variables are the coordinates of the line,
	;hich needs to be turned arround the center of
	;the coordinate system
	x1 = -50
	y1 = 80
	x2 = 50
	y1 = 80
	;(they can be ANYTHING besides this)

	p1x = Cx + x1 * Cos( Angle ) + y1 * Sin( Angle )
	p1y = Cy + y1 * Cos( Angle ) - x1 * Sin( Angle )
	p2x = Cx + x2 * Cos( Angle ) + y2 * Sin( Angle )
	p2y = Cy + y2 * Cos( Angle ) - x2 * Sin( Angle )
			
	;just draw it
	Line p1x, p1y, p2x, p2y
	Flip
	Cls
Wend
End



bytecode77(Posted 2008) [#3]
thats what i was looking for :)
THX dude!