Rotating a point about an axis or three.

BlitzMax Forums/BlitzMax Beginners Area/Rotating a point about an axis or three.

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.

simply put. 2D rotations are blazingly simple. You have a single point that represents a single axis and you determine the distance from that axis using a radius. use the mousewheel to grow/shrink the circle.


Global GW = 640 , GH = 480 , midw = GW/2 , midh = GH/2
Global xend , yend
Graphics GW,GH,0
Local frametimer = CreateTimer(30)
Global radius = 10
Repeat
	
	mx = MouseX()
	my= MouseY()
	
	radius = 20+ MouseZ()	
	angle#:+.1
	
	xend = midw+Cos(angle#)*radius
	yend = midh+Sin(angle#)*radius

	
	DrawText "x="+xend+" y="+yend,xend,yend
	DrawText "Radius="+radius,xend,yend+20
	DrawText "Angle="+angle,xend,yend+40

	
	DrawLine(midw,midh,xend,yend)


	WaitTimer(frametimer)
	Flip ; Cls
Until KeyDown(KEY_ESCAPE)





for 3D, there are 3 axes for every point. Each axis can be a part of a global coordinate system (the world) or a local coordinate system (the object). 3D rotations are called 'transforms'. It is not really as simple as doing sin/cos for each of the 3 axes. that can be very messy and difficult to maintain. hence the Euler method, Matrices and Quaternions I mentioned above. Each method has pro's and cons. I would save Quats for last because they are more difficult to visualize (Eulers make more *spatial* sense)