From: Bruce S. <Bru...@nc...> - 2009-04-18 21:47:55
|
Footnote: the "radians" and "degrees" functions actually come from the math module, as do functions such as sin, cos, and sqrt. Visual automatically imports the math module and the array module "numpy" (or the older Numeric for Visual 3). But it makes sense to advertise the radians and degrees functions in the Visual documentation dealing with rotations. Of course radians(x) is equivalent o x*pi/180, and degrees(x) is equivalent to x*180/pi. Bruce Sherwood Bruce Sherwood wrote: > Oh, now I see your point. I did misread the original question. (I didn't even > realize that there is a Visual function "radians"! I better get this into the > documentation.) > > But there's nothing wrong with the radians function: it's doing its job of > converting radians(90) into pi/2 radians. The problem is that in the first > iteration through the loop the rotation is through 0, the next time through 1 > degree, the next time through 2 degrees STARTING FROM A DIRECTION THAT HAD > ALREADY BEEN ROTATED 1 degree, so the new direction is 3 degrees away from the > original direction. The next rotation will be by 3 degrees, for a total rotation > of 6 degrees, etc. > > So my corrections to those programs should have said > > ....rotate(angle=radians(1), ..... > > That way one is always rotating by 1 degree each time through the loop. > > Bruce Sherwood > > Lenore Horner wrote: >> The command "radians" which he was using to turn his degree angles into >> radian angles. >> >> On Apr 18, 2009, at 12:48 , Bruce Sherwood wrote: >> >>> What is there to squawk about? 90 radians is a completely legal angle. >>> >>> Bruce Sherwood >>> >>> Lenore Horner wrote: >>>> VPython doesn't have a radians command to turn degrees into radians? >>>> Shouldn't it squawk when he uses an illegal command? >>>> Lenore >>>> On Apr 18, 2009, at 11:40 , Bruce Sherwood wrote: >>>>> The angle used by rotations must be in radians, not degrees. >>>>> >>>>> You want ....rotate(angle=alfa*pi/180, .... >>>>> >>>>> Bruce Sherwood >>>>> >>>>> alessandro wrote: >>>>>> I want to rotate 90° around the center objects with an animation. I >>>>>> tried this: >>>>>> >>>>>> >>>>>> from visual import * >>>>>> ball = sphere(pos=(-5,0,0), radius=0.5, color=color.red) >>>>>> wallR = box(pos=(6,0,0), size=(0.2,4,4), color=color.green) >>>>>> alfa=0 >>>>>> while alfa < radians(90): >>>>>> rate(20) >>>>>> >>>>>> scene.forward = scene.forward.rotate(angle=alfa, axis=(0,1,0)) >>>>>> >>>>>> alfa += radians(1) >>>>>> >>>>>> both the sphere & box rotate but they rotate for not only for 90° but >>>>>> serveral time. Where is the error? >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> >>>>>> Stay on top of everything new and different, both inside and >>>>>> around Java (TM) technology - register by April 22, and save >>>>>> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. >>>>>> 300 plus technical and hands-on sessions. Register today. >>>>>> Use priority code J9JMT32. http://p.sf.net/sfu/p >>>>>> _______________________________________________ >>>>>> Visualpython-users mailing list >>>>>> Vis...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/visualpython-users >>>>> ------------------------------------------------------------------------------ >>>>> >>>>> Stay on top of everything new and different, both inside and >>>>> around Java (TM) technology - register by April 22, and save >>>>> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. >>>>> 300 plus technical and hands-on sessions. Register today. >>>>> Use priority code J9JMT32. http://p.sf.net/sfu/p >>>>> _______________________________________________ >>>>> Visualpython-users mailing list >>>>> Vis...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/visualpython-users >>>>> > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |