Posts: 3,368
Threads: 195
Joined: Jan 2003
Let's say I have a circle. The center has (x, y) coordinates (0, 0).
How do I determine the (x, y) coordinates of n points around the circumference of the circle spaced equally apart (along the circumference), assuming we start at a point (0, r), r being the radius?
Thanks....
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 838
Threads: 17
Joined: Jan 2002
Like this?
Code:
#define PI 3.141592
dim as double radians
dim as integer cx, cy, r, numPoints, px, py
screen 14
cx=150
cy=120
r=100
numPoints=10
for radians=0 to PI*2 step PI*2/numPoints
px=cx+cos(radians)*r
py=cy-sin(radians)*r
pset(px,py)
'or save coordinates here
'subtract cx and cy from px and py respectively to get
'coordinates relatively from (0, 0)
next radians
sleep
url=http://www.copy-pasta.com]CopyPasta[/url] -
FilePasta
Posts: 476
Threads: 35
Joined: May 2006
This (basically the same as Zap's heheh)?
Code:
#define PI 3.141592
dim as double radians
dim as integer angle, r, px, py
screenres 640, 480
angle = 30
r=100
numPoints=10
Do
radians = angle * 3.14/180
px = r * cos(radians)
py = r * sin(radians)
Line (320, 240)-(320 + px, 240 + py)
Print PX, PY
Angle += 30
Loop until angle > 360
sleep
Posts: 3,368
Threads: 195
Joined: Jan 2003
Thanks guys!
I needed this for a custom scenario in a Microsoft game called Rise of Legends, btw.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.