From: Bruce Sherwood <Bruce_Sherwood@nc...>  20070129 14:25:30

See the curve object; just give starting and ending locations to draw a line. Bruce Sherwood siggi wrote: > Hi all, > > I am a complete newbie to VPython, but I got hooked. I > tried the bouncing ball, enriched it with audio from > Pygame, and the simple function plot; so little code, > so great > effects! > > My first problem: how do I draw a line from x to y? I > know how to plot functions with VPython, such as > x = f(x), see above > > but how do I plot a 2D function such as > x = f1(x) > y = f2(y) > draw line between x and y? > > In Python it is done, e.g., like this > > while theta < 75.39: > r = math.exp(math.cos(theta)) > 2*math.cos(4*theta)+(math.sin(theta/12))**5 > # convert from polar coordinates > x = r*math.cos(theta) > y = r*math.sin(theta) > # scale to canvas size > xx = (x*30) + 150 > yy = (y*30) + 150 > if (theta == 0.0): > Canvas.Line(self.canvas, xx, yy, xx, yy) > else: > Canvas.Line(self.canvas, xOld, yOld, xx, yy) > self.canvas.update_idletasks() > xOld = xx > yOld = yy > theta = theta + 0.02 > > which, in this case, creates a butterfly curve > (from http://www.pythonmania.de/article/pybutt.html) > > Unfortunately, browsing tutorials and documents on > http://www.vpython.org, I could not find a "line " command. > If there would be one, 3D "butterfly" curves > would be possible, too. > > Thanks, > > siggi > > > > > > > ____________________________________________________________________________________ > Any questions? Get answers on any topic at http://www.Answers.yahoo.com. Try it now. > >  > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys  and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Visualpythonusers mailing list > Visualpythonusers@... > https://lists.sourceforge.net/lists/listinfo/visualpythonusers > 