From: Dockeen <do...@mc...> - 2002-06-21 03:03:19
|
I haven't had as much chance as I would like in a while, so I figured I would take a quick shot at a cylinder example. I did not write comments, but I think the code is fairly simple. It is crude, but it works. from visual import * from Numeric import * length = 3.0 radius = 1.0 number_of_steps_length = 30 number_of_angle_steps = 30 length_step = length / number_of_steps_length angle_step = 2.0 * 3.1415926 / number_of_angle_steps scene = display(title='Cylinder', width=500, height=500, center=(0,0,0), range=(5,5,5)) for i in xrange(0,number_of_steps_length): x1 = i * length_step x2 = (i + 1) * length_step for j in xrange(0,number_of_angle_steps): theta = j * angle_step y1 = radius * sin(theta) z1 = radius * cos(theta) y2 = radius * sin(theta + angle_step) z2 = radius * cos(theta + angle_step) convex(pos = [(x1,y1,z1),(x1,y2,z2),(x2,y1,z1),(x2,y2,z2)], color = color.red) Have fun, you just GOTTA love this tool! Wayne Keen |