Animating object on a circle

BlitzPlus Forums/BlitzPlus Beginners Area/Animating object on a circle

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.

The formula for converting polar coordinates to cartesian is:

X = Radius * Cos(Angle)
Y = Radius * Sin(Angle)


So, if I want to place a circle centered at 320, 240, and place a sprite at angle 0, which is the right side of the circle, then I would go:

SpriteAngle# = 0

SpriteXOff# = CircleRadius# * Cos(SpriteAngle#)
SpriteYOff# = CircleRadius# * Sin(SpriteAngle#)

SpriteX# = 320.0 + SpriteXOff#
SpriteY# = 240.0 + SpriteYOff#


Note that 90 is the top of the circle, and that SpriteXOff# and SpriteYOff# will be negative at times, because the polar coordinate equation produces a circle centered at 0,0 in cartesian space.