View Full Version : can someone help me excute the code?

incognitoDave
03 March 2009, 07:10 AM
try something like this

fn easeIn t b c d =
(
c * pow 2 (10 * (t/d - 1)) + b
)

cyl_count = 20
t = 0
base = 0
c = 5

while t < cyl_count do
(
v = 0
v = easeIn t base c cyl_count
sp = cylinder radius:0.04 height:v pos:[t, 0, 0]
t += .25
)

flyingaway
03 March 2009, 01:12 AM
but what if I want to keep the cylinders position and height ?

incognitoDave
03 March 2009, 02:49 AM
Sure there is a better way but you could try something like this:

fn easeIn t b c d =
(
c * pow 2 (10 * (t/d - 1)) + b
)

(
d = 20
t = 0
base = 0
c = 5

cyl_array =#()
counter = 1

while t < d do
(
v = 0
v = easeIn t base c d
cyl_array[counter] = cylinder radius:0.04 height:v pos:[t, 0, 0]
t += .25
counter += 1
)

print cyl_array.count
print cyl_array[34].height
)

flyingaway
03 March 2009, 04:22 AM
thank you
but I think perhaps I didnt express myself exactly
when I say keep the cylinders' position and height I mean to make the cylinders' postion and height as I given in the code
but still thanks for your kindness

msmith81
03 March 2009, 03:51 PM
try this code, which will print a list of values to compare with your original listing. The positions match exactly, but the height followed a very strange pattern that I did not have time to decode. I was able to get it close - you will notice that the first and last values are the same, but in between the values have a small margin of error. If you want the height values to be 100% correct, I will need more information on where these values came from. But hopefully this will be close enough for you.

counter = 0 -- this is for formatting the output only
-- Now declare some variables to be used with the cylinders
theHeight = 2.2
theXPos = .126
theYPos = 17
theZPos = 49.3
d = #()-- an empty array to add the cylinders to
theHeightAdd = -.229268 -- this is the amount of increase in the large jump in height values

--Now create each cylinder and add it to the array
for f = 1 to 42 do -- each loop will make 2 cylinders
(
TheHeightAdd += (.229268 - (if counter < 6 then 0 else 0.1))-- increase the amount of the large jump in values
theHeight += theHeightAdd -- this is the larger jump in values minus the smaller change in values
theXPos += 15.496 -- this is the larger jump in values minus the smaller change in values
for c = 1 to 2 do
(
counter += 1 -- for the output only, not necessary for cylinder creation
theHeight += (if counter < 7 then 0 else 0.1) -- add the smaller jump in values
theXPos += 0.252 -- add the smaller jump in values
dTemp = cylinder radius:theRadius height:theHeight pos:[theXPos, theYPos, theZPos] -- make the cylinder!!
format "d%=cylinder radius:% height:% pos:[%,%,%]\n" counter theRadius theHeight theXPos theYPos theZPos -- this will display the list to check the values
append d dTemp -- add the cylinder to the array
)
)

-- this part I left unchanged from the original
for i=1 to 42 do
(
copy d[2*i] pos:[0.126+i*16,-17,49.3]
copy d[2*i-1] pos:[-0.126+16*i,-17,49.3]
copy d[2*i-1] pos:[-0.126-16*i,17,49.3]
copy d[2*i] pos:[0.126-i*16,17,49.3]
copy d[2*i] pos:[0.126-i*16,-17,49.3]
copy d[2*i-1] pos:[-0.126-16*i,-17,49.3]
)

flyingaway
03 March 2009, 06:31 AM
msmith81 ,thank you to take time to try out the foumula

CGTalk Moderation
03 March 2009, 06:31 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.

1