From: Zittlow, M. <mzi...@so...> - 2012-12-28 14:23:31
|
I wrote a little program to get an understanding of the rotation of objects and have not been able to get things to work as I would like. I cannot get objects rotate about their centers. Believe is some code where I am trying to get a sphere to rotate about the x-axis while maintaining a 2 unit distance from the yz-plane. Any assistance would be greatly appreciated. from visual import * from time import sleep #create a set of axes for a visual reference when rotating xaxis=cylinder(pos=(0,0,0), axis=(5,0,0), color=(1,0,0), radius=0.2) yaxis=cylinder(pos=(0,0,0), axis=(0,5,0), color=(0,1,0), radius=0.2) zaxis=cylinder(pos=(0,0,0), axis=(0,0,5), color=(0,0,1), radius=0.2) #create the ball to be rotated ball = sphere(pos=(2,2,0), radius = 0.5) #set rotation angle for 1/20 of a rotation rotationAngle = 6.28/20.0 #have the ball rotate about the x-axis while #maintaining 2 units from the xy-plane for i in range(20): ball.rotate(angle=rotationAngle, pos=(2,0,0), axis=(1,0,0)) sleep(0.2) thanks again, Mike -- Michael Zittlow Mathematics Department Chairperson Southern Door High School Brussels, WI 54204 |