PDA

View Full Version : position objects on a circle


ehmdjii
12-28-2004, 04:35 PM
hello,
i want several objects positioned in a circle. i thought maxscript is the best way to do this, if not please tell me. ;)

now, what i try is the following:

r=20.0
p=3.1415
for i=1 to 16 do
(
mycyl = cylinder radius:6 height:20
mycyl.name = "cyl_"+ i as string
xx=sin(p*i/16.0)*r
yy=cos(p*i/16.0)*r
mycyl.pos = [xx,yy,0]
)

unfortunately this doesnt work and i cant figure out why?
thanks for any help.


edit: 2 minutes after i posted this, i figured it out.
sorry.
sin is calculated from 0 to 360 degrees and not from 0 to pi as in most languages.

Bobo
12-28-2004, 05:40 PM
hello,
i want several objects positioned in a circle. i thought maxscript is the best way to do this, if not please tell me. ;)


edit: 2 minutes after i posted this, i figured it out.
sorry.
sin is calculated from 0 to 360 degrees and not from 0 to pi as in most languages.
A couple of small notes:

In case you need Pi again some day, you can use it directly as it is already pre-defined as a System Global (sort of constant).

Also, in the function of the Circle, Cos is used to calculate the X and Sin is used for Y. You've got them the other way round...

ehmdjii
12-28-2004, 10:02 PM
thank you, first of all.

A couple of small notes:

In case you need Pi again some day, you can use it directly as it is already pre-defined as a System Global (sort of constant).
ok, and how is it defined?


Also, in the function of the Circle, Cos is used to calculate the X and Sin is used for Y. You've got them the other way round...
i dont think that matters...

Rens
12-28-2004, 10:43 PM
ok, and how is it defined?
As pi. http://www.rensheeren.com/images/cgtalk/dealF1.gif

galagast
12-30-2004, 07:34 PM
this may be very embarassing, but i wud really want to understand how this works... im really eager to learn stuff like this... i guess i wasnt really paying much attention on this topic when i was in school... :sad:

sin(360*i/16.0)*r

or any of u guys can recommend a good book or site?

im looking at some stuff on the net right now, i was just hoping to hav more reference on this one... thanx in advance! :)

CGTalk Moderation
01-20-2006, 06:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.