From: CATIA <ca...@un...> - 2012-12-29 12:14:14
|
Hi, use origin instead of pos! Hans 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 #allows viewing and zooming before the start of the loop s = input("type number to start:") for i in range(20): ball.rotate(angle=rotationAngle, origin=(2,0,0), axis=(1,0,0)) sleep(0.2) Am 28.12.2012 14:55, schrieb Zittlow, Mike: > 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 > > > ------------------------------------------------------------------------------ > Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and > much more. Get web development skills now with LearnDevNow - > 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. > SALE $99.99 this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122812 > > > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |