You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(1) |
Aug
|
Sep
(15) |
Oct
(32) |
Nov
(35) |
Dec
(48) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(46) |
Feb
(22) |
Mar
(65) |
Apr
(49) |
May
(22) |
Jun
(29) |
Jul
(51) |
Aug
(34) |
Sep
(32) |
Oct
(46) |
Nov
(30) |
Dec
(32) |
2002 |
Jan
(48) |
Feb
(4) |
Mar
(20) |
Apr
(28) |
May
(13) |
Jun
(34) |
Jul
(51) |
Aug
(15) |
Sep
(15) |
Oct
(35) |
Nov
(15) |
Dec
(20) |
2003 |
Jan
(31) |
Feb
(111) |
Mar
(41) |
Apr
(28) |
May
(36) |
Jun
(29) |
Jul
(27) |
Aug
(29) |
Sep
(47) |
Oct
(28) |
Nov
(7) |
Dec
(26) |
2004 |
Jan
(44) |
Feb
(9) |
Mar
(17) |
Apr
(26) |
May
(58) |
Jun
(13) |
Jul
(44) |
Aug
(64) |
Sep
(30) |
Oct
(11) |
Nov
(21) |
Dec
(28) |
2005 |
Jan
(29) |
Feb
(11) |
Mar
(11) |
Apr
(22) |
May
(85) |
Jun
(46) |
Jul
(17) |
Aug
(18) |
Sep
(14) |
Oct
(22) |
Nov
(1) |
Dec
(45) |
2006 |
Jan
(20) |
Feb
(36) |
Mar
(18) |
Apr
(24) |
May
(21) |
Jun
(48) |
Jul
(23) |
Aug
(20) |
Sep
(10) |
Oct
(41) |
Nov
(46) |
Dec
(40) |
2007 |
Jan
(40) |
Feb
(20) |
Mar
(13) |
Apr
(6) |
May
(24) |
Jun
(31) |
Jul
(30) |
Aug
(11) |
Sep
(11) |
Oct
(10) |
Nov
(56) |
Dec
(64) |
2008 |
Jan
(64) |
Feb
(22) |
Mar
(63) |
Apr
(28) |
May
(25) |
Jun
(36) |
Jul
(11) |
Aug
(9) |
Sep
(14) |
Oct
(41) |
Nov
(46) |
Dec
(130) |
2009 |
Jan
(95) |
Feb
(41) |
Mar
(24) |
Apr
(35) |
May
(53) |
Jun
(67) |
Jul
(48) |
Aug
(48) |
Sep
(86) |
Oct
(75) |
Nov
(64) |
Dec
(52) |
2010 |
Jan
(57) |
Feb
(31) |
Mar
(28) |
Apr
(40) |
May
(25) |
Jun
(42) |
Jul
(79) |
Aug
(31) |
Sep
(49) |
Oct
(66) |
Nov
(38) |
Dec
(25) |
2011 |
Jan
(29) |
Feb
(18) |
Mar
(44) |
Apr
(6) |
May
(28) |
Jun
(31) |
Jul
(36) |
Aug
(24) |
Sep
(30) |
Oct
(23) |
Nov
(21) |
Dec
(27) |
2012 |
Jan
(14) |
Feb
(11) |
Mar
(2) |
Apr
(48) |
May
(7) |
Jun
(32) |
Jul
(22) |
Aug
(25) |
Sep
(31) |
Oct
(32) |
Nov
(21) |
Dec
(17) |
2013 |
Jan
(44) |
Feb
(27) |
Mar
(3) |
Apr
(1) |
May
|
Jun
|
Jul
(3) |
Aug
(4) |
Sep
(1) |
Oct
(7) |
Nov
(5) |
Dec
(5) |
2014 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
(2) |
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
(7) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Scott D. D. <Sco...@Ac...> - 2008-01-11 01:48:08
|
Lorenzo Isella wrote: > ... > pos_list=s.zeros(3) # I initialize the array to contain the single > particle's coordinates > my_rad=1.06/2. > for i in xrange(0,n_part): #n_part is the number of particles in my system > pos_list[0]=x_list[i] #x_list contains a list of the x-coordinate > of all the particles in the system at a given time > pos_list[1]=y_list[i] > pos_list[2]=z_list[i] > particle=v.sphere(pos=pos_list,radius=my_rad,color=v.color.blue) > In a sense, I have filled the space with the same particle repeated > many times, whereas I would like to have an array of particles > part[j] whose positions can be updated in time. Try this (to get all points in the frame): my_rad = 1.06 / 2. particles = [v.sphere(pos=loc, radius=my_rad, color=v.color.blue) for loc in zip(x_list, y_list, z_list)] > 1)zooming and selecting a part of the scene (i.e. some specific particle > configurations) and generating a pdf or eps or jpg or png file. See Ruth Chabay's contributed program to go from Vpython to POV-Ray source, then use POV-Ray to go from source to .png image. > 2)generating a movie. I saw there is a contributed program which should > work only for MacOS and I wonder if there is anything similar available > for Linux (I am running Debian testing on my box). First, you are not asking anything simple when you ask to go to a movie. Your head needs to get higher if you really want to do this. E-mail me separately if you have everything solved up through getting .png images, and I can provide you with "no redistribution; no comercial use" code to take a bunch of .png files to a .mng file (which is an obscure movie format, but there _are_ a few readers out there). --Scott David Daniels Sco...@Ac... |
From: Lorenzo I. <lor...@gm...> - 2008-01-10 21:55:01
|
Dear All, I am a newbie in visual Python, so apologies if this is a FAQ. I am interested in using Vpython to investigate the motion of a bunch of particles in space; I save the (x,y,z) coordinates of each particle as a function of time and I can plot easily a snapshot of the system using a code like: #! /usr/bin/env python import scipy as s import numpy as n import pylab as p import visual as v #here I do my stuff to read the configuration of the system #and then I can finally plot a snapshot of the system at a specific time pos_list=s.zeros(3) # I initialize the array to contain the single particle's coordinates my_rad=1.06/2. for i in xrange(0,n_part): #n_part is the number of particles in my system pos_list[0]=x_list[i] #x_list contains a list of the x-coordinate of all the particles in the system at a given time pos_list[1]=y_list[i] pos_list[2]=z_list[i] particle=v.sphere(pos=pos_list,radius=my_rad,color=v.color.blue) and so far so good. However, I am having a hard time in making an animation out of this. In a sense, I have filled the space with the same particle repeated many times, whereas I would like to have an array of particles part[j] whose positions can be updated in time. Does anyone know how to achieve this? The example program: http://www.vpython.org/vpythonprog.htm is very clear but deals with a single object. Furthermore, I am after 2 other things: 1)zooming and selecting a part of the scene (i.e. some specific particle configurations) and generating a pdf or eps or jpg or png file. 2)generating a movie. I saw there is a contributed program which should work only for MacOS and I wonder if there is anything similar available for Linux (I am running Debian testing on my box). I know this is also dealt with in http://www.vpython.org/FAQ.html but this seems to be flying over my beginner's head. Many thanks Lorenzo |
From: Joel K. <jj...@ya...> - 2008-01-10 01:15:07
|
This is technically sort of off-topic, but . . . http://sourceforge.net/projects/geogebra3d/ Perhaps some teachers and students who work with VPython might be interested in reviving Geogebra 3D as an educational project; both 3D systems might benefit from the work. Joel ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |
From: Bruce S. <Bru...@nc...> - 2008-01-09 20:25:53
|
As you may have seen from a flurry of recent notes, various people have urged that there be built into VPython for functions to go between frame coordinates and "world" coordinates. Although several people have written their own routines, it's not unreasonable to ask that these be built-in, and I've added this to a mental list of things to do. There's no more "vpythonish" way to make a box with different colors on the sides than to resort as you did to the basic faces object. I've never known or understood how packages spring into being for various Linux distributions. I put tarballs on vpython.org (for the production version) and on sourceforge (for the beta version), and apparently various people somewhere pick some version and package it for their favorite flavor of Linux. That this process is imperfect can be seen in the most recent version 7 of Ubuntu, where the package for VPython is quite old (if I remember correctly, it is 3.2.1 rather than 3.2.9). As for not being able to compile the beta version on your own, can you describe the symptoms of what prevents you from getting through the instructions given in INSTALL.txt, part of the tarball? My goal is to provide enough information to people that one doesn't need much special knowledge in order to build the beta version from source. Bruce Sherwood Emanuele Gissi wrote: > Hi, > > first of all *thank you* very much for developing VPython and making it > open source. > > My name is Emanuele Gissi and I am a recent subscriber to this list. > I am not a professional developer (http://gissi.free.fr > <http://gissi.free.fr/>), I am an officer of the Italian National Fire > Brigade ( http://www.vigilfuoco.it/). > I am using Ubuntu Linux and rather new to Python, but really impressed > by its power and simplicity. > > I encountered VPython while trying to develop a small and simple > preprocessor for an open source CFD program named FDS ( > http://www.fire.nist.gov/fds/) used to simulate fires in buildings. > FDS does not have an own GUI to enter the geometry of the building. > (Yes, there is Pyrosim ( http://thunderheadeng.com/pyrosim/), but it is > a commercial application, not from NIST, closed source and Windows > version only). > > And developers at NIST would be very interested in a open source, multi > platform GUI for FDS. > > My small (for now ;-) preprocessor (FDScad) is a sort of CAD for the > geometry of the building and its boundary conditions. > I attach the current version to this email. > I don't think it can be still a candidate for "contributed programs": > it's in its infancy and it is a very rough prototype! > > Now, question time: > > 1) Is there a more vpython-ish way to do the following: (probably in > 4beta version?) > a - I reimplemented the box class, as I needed a box with differently > colored faces. > b - I implemented a function for absolute positions of objects. > c - Another function calculates the absolute normals of faces of my > reimplemented box. > > 2) Is there a binary package (deb, tar.gz, rpm) for the 4beta version? I > admit that I am not able to compile it on my own... > This would facilitate testing. > > Thank you, once more, in advance. > Emanuele Gissi. > > > ------------------------------------------------------------------------ > > # -*- encoding: utf-8 -*- > # > # Copyright (c) 2007 Ing. Emanuele Gissi. (http://gissi.free.fr) All Rights Reserved. > # > # This program is Free Software, GNU General Public License, version 3, > # as published by the Free Software Foundation. > # > > # Fare class obst, hole, surf, mesh, devc > # Cancellare gli oggetti? > # Che succede quando cancello una bondary condition? > # Un frame, un oggetto? > > # __self eccetera init, getter setter > # test 2D 2d e protect size > > > > from visual import * > > # constants > > vx = vector(1,0,0) > vy = vector(0,1,0) > vz = vector(0,0,1) > > # functions > > def calcparentpos(frame, pos): > """Expresses a pos relative to a frame (that can be taken from an object), > in coords relative to its parent ref (parent frame or universe). > For now, my program does not use it. > frame: obj, a ref frame or obj. > pos: vector, position of the point expressed in frame coordinates > """ > pos = vector(pos) > if frame: > # Calcs 3 versors of frame or obj axis in parent frame coordinates > x_axis = norm(frame.axis) > z_axis = norm(cross(frame.axis, frame.up)) > y_axis = norm(cross(z_axis, x_axis)) > # Returns the new coordinates relative to parent ref > return frame.pos + pos.x * x_axis + pos.y * y_axis + pos.z * z_axis > else: > return pos > > def calcabspos(frame, pos): > """Expresses a pos relative to a frame (that can be taken from an object), > in coords relative to the universe. It's a recursive function. > frame: obj, a ref frame or obj. > pos: vector, position of the point expressed in frame coordinates > """ > pos = vector(pos) > if frame: > # Calcs 3 versors of frame or obj axis in parent frame coordinates > x_axis = norm(frame.axis) > z_axis = norm(cross(frame.axis, frame.up)) > y_axis = norm(cross(z_axis, x_axis)) > # Returns the new coordinates relative to parent ref > return calcabspos(frame.frame, frame.pos + pos.x * x_axis + pos.y * y_axis + pos.z * z_axis) > else: > return pos > > def calcabsrotz(frame, pos=(1,0,0)): > """Calcs the number of pi/2 absolute rotations of the frame (or obj) around z axis, > relative to the universe. It's used by EBox to calc absolute faces used > by FDS for boundary conditions. The rotation should be around z axis only! > frame: obj, a ref frame or obj. > Don't use the parameter pos, it'used for recursion. Yes, I know, it's not elegant... > """ > pos = vector(pos) > if frame: > # Calcs 3 versors of frame or obj axis in parent frame coordinates > x_axis = norm(frame.axis) > z_axis = norm(cross(frame.axis, frame.up)) > y_axis = norm(cross(z_axis, x_axis)) > # Returns the new coordinates relative to parent ref > return calcabsrotz(frame.frame, pos.x * x_axis + pos.y * y_axis + pos.z * z_axis) > else: > # The current pos is the initial x axis referenced to universe frame. > # Calcs the angle formed with the absolute axis x and y > diffx = vx.diff_angle(pos) > diffy = vy.diff_angle(pos) > # Check the values to discover the value of rotation > if diffx < .1 : > # 0° around z > return 0 > elif diffy < .1 : > # 90° around z > return 1 > elif diffx > pi -.1: > # 180° around z > return 2 > elif diffy > pi -.1: > # 270° around z > return 3 > else: > raise Exception("Unknown rotation around z axis!") > return absffnames > > # classes > > class EFrame(frame): > """Enhanced frame. > id: string, id of the instance, why hardwired __name__ does not work? > visible: boolean, visibility of local objs > color: triplet, color of the handler > pos: vector, position relative to the parent frame > frame: obj, reference frame > abspos: vector, absolute position of origin > label: obj, label > handler: obj, sphere > rotate(): simplyfied rotation around z axis. > """ > def __init__(self, id, visible=True, color=color.yellow, pos=(0,0,0), frame=None): > super(EFrame, self).__init__(frame=frame, pos=pos) # create the frame, with few parameters > self.id = id # record the id of the object, instead of __name__ > self.__visible = visible # visibility of all local objects > # label and handler (FIX IT: si potrebbe aggiungere il posizionamento random delle etichette) > self.label = label(frame=self, pos=(0,0,0), text=id, xoffset=20, box=False) > self.handler = sphere(frame=self, pos=(0,0,0), radius=.1, color=color) > self.handler.container = self # FIX IT used to pick it up with mouse > self.arrows = [arrow(frame=self, pos=(0,0,0), axis=(1,0,0), color=(1,0,0), shaftwidth=.03), > arrow(frame=self, pos=(0,0,0), axis=(0,1,0), color=(0,1,0), shaftwidth=.03), > arrow(frame=self, pos=(0,0,0), axis=(0,0,1), color=(0,0,1), shaftwidth=.03)] > > def rotate(self, n=1): > """Simplified rotation""" > for i in range(n): > super(EFrame, self).rotate(angle=pi/2, axis=(0,0,1)) > > def getvisible(self): > """Get visibility""" > return self.__visible > > def setvisible(self, visible): > """Set visibility of all the local objects""" > self.__visible = visible > self.label.visible = visible > self.handler.visible = visible > for arrow in self.arrows: > arrow.visible = visible > > visible = property(getvisible, setvisible) > > def getabspos(self): > """Get absolute position of the origin""" > return calcabspos(self.frame, self.pos) > > abspos = property(getabspos) # readonly > > class EBox(EFrame): > """Enhanced box > size: vector, size in local x, y, z directions > origin: vector, relative position of origin in local x, y, z, directions > wireframe: boolean, show wireframe > solid: boolean, show solid > colors: list, colors of x0, x1, y0, y1, z0, z1 faces > colorw: triplet, color of wireframe > abscoordinates: list, absolute coordinates of the box in FDS notation > absff: list, list of absolute faces orientation in FDS notation > """ > def __init__(self, size=(2,2,2), origin=(0,0,0), wireframe=True, solid=True, > colors=[color.white] * 6, colorw=color.white, **args): > super(EBox, self).__init__(**args) > self.__size = size > self.__origin = origin > self.__wireframe = wireframe > self.__solid = solid > self.__colors = colors > self.__colorw = colorw > self.__ff = [] # list of flat faces > self.__fw = [] # list of wireframe faces > self.__p000 = [] # position of ebox 000 vertex > self.__p111 = [] # position of ebox 111 vertex > # calcs faces > ffpos, fwpos = self._calcfaces(size, origin) > ffnormals = [[-vx] * 6, [vx] * 6, [-vy] * 6, [vy] * 6, [vz,] * 6, [vz] * 6] > # creates faces and wireframes > for face in range(6): > self.__ff.append(faces(frame = self, pos = ffpos[face], > normal = ffnormals[face], > color = colors[face], visible = solid)) > self.__fw.append(curve(frame = self, pos = fwpos[face], > color = colorw, visible = wireframe)) > > def _calcfaces(self, size, origin): > """Calculate faces position""" > # get 3 sides and origin position relative to sizes > sx, sy, sz = size > ox, oy, oz = origin > # calc 6 vertexes, considering the right alignments > p000 = vector(-ox * sx, -oy * sy, -oz * sz) > p100 = p000 + vector( sx, 0, 0) > p010 = p000 + vector( 0, sy, 0) > p001 = p000 + vector( 0, 0, sz) > p110 = p000 + vector( sx, sy, 0) > p101 = p000 + vector( sx, 0, sz) > p011 = p000 + vector( 0, sy, sz) > p111 = p000 + vector( sx, sy, sz) > # calc pos for flat faces and wireframe faces > ffpos = [] > ffpos.append([p000,p011,p010,p000,p001,p011]) > ffpos.append([p100,p110,p111,p100,p111,p101]) > ffpos.append([p000,p100,p101,p000,p101,p001]) > ffpos.append([p010,p111,p110,p010,p011,p111]) > ffpos.append([p000,p010,p110,p000,p110,p100]) > ffpos.append([p001,p111,p011,p001,p101,p111]) > fwpos = [] > fwpos.append([p000,p001,p011,p001,p000]) > fwpos.append([p100,p101,p111,p101,p100]) > fwpos.append([p000,p100,p101,p001,p000]) > fwpos.append([p010,p110,p111,p011,p010]) > fwpos.append([p000,p010,p110,p100,p000]) > fwpos.append([p001,p011,p111,p101,p001]) > # save positions of extreme vertexes > self.__p000 = p000 > self.__p111 = p111 > return (ffpos, fwpos) > > def redraw(self): > """Recalc and correct the faces""" > ffpos, fwpos = self._calcfaces(self.__size, self.__origin) > # correct the faces > for face in range(6): > self.__ff[face].pos = ffpos[face] > self.__ff[face].color = self.__colors[face] > self.__ff[face].visible = self.__solid > # wireframe faces > self.__fw[face].pos = fwpos[face] > self.__fw[face].color = self.__colorw > self.__fw[face].visible = self.__wireframe > > def getsize(self): > """Get size""" > return self.__size > > def setsize(self, size): > """Set size and redraw""" > self.__size = size > self.redraw() > > size = property(getsize, setsize) > > def getorigin(self): > """Get origin""" > return self.__origin > > def setorigin(self, origin): > """Set origin and redraw""" > self.__origin = origin > self.redraw() > > origin = property(getorigin, setorigin) > > def getcolors(self): > """Get colors of the faces""" > return self.__colors > > def setcolors(self, colors): > """Set colors of the faces and redraw""" > self.__colors = colors > self.redraw() > > colors = property(getcolors, setcolors) > > def getcolorw(self): > """Get color of the wireframe""" > return self.__colorw > > def setcolorw(self, colorw): > """Set color of the wireframe and redraw""" > self.__colorw = colorw > self.redraw() > > colorw = property(getcolorw, setcolorw) > > def getwireframe(self): > """Get wireframe state""" > return self.__wireframe > > def setwireframe(self, wireframe): > """Set wireframe state and redraw""" > self.__wireframe = wireframe > self.redraw() > > wireframe = property(getwireframe, setwireframe) > > def getsolid(self): > """Get solid state""" > return self.__solid > > def setsolid(self, solid): > """Set solid state and redraw""" > self.__solid = solid > self.redraw() > > solid = property(getsolid, setsolid) > > def getvisible(self): > """Get visibility""" > # This property is redefined from EFrame > return self.__visible > > def setvisible(self, visible): > """Set visibility and redraw or correct""" > # This property is redefined from EFrame > # Set the visibility of the eframe > super(EBox, self).setvisible(visible) > # Set the visibility of the object > self.__visible = visible > if visible: self.redraw() > else: > for face in range(6): > self.__ff[face].visible = False > self.__fw[face].visible = False > > visible = property(getvisible, setvisible) > > def getabsff(self): > """Calc the absolute orientation of the faces""" > absrotz = calcabsrotz(self) > if absrotz == 0: > absff = ["x0","x1","y0","y1","z0","z1"] > elif absrotz == 1: > absff = ["y0","y1","x1","x0","z0","z1"] > elif absrotz == 2: > absff = ["x1","x0","y1","y0","z0","z1"] > elif absrotz == 3: > absff = ["y1","y0","x0","x1","z0","z1"] > else: > raise Exception("Unknown rotation of an EBox!") > return absff > > absff = property(getabsff) > > def getabscoordinates(self): > """Get absolute coordinates, as in FDS convention. > This works only for pi/2 rotations!""" > pos0 = calcabspos(self, self.__p000) > pos1 = calcabspos(self, self.__p111) > abscoordinates = [min(pos0.x,pos1.x), max(pos0.x,pos1.x), > min(pos0.y,pos1.y), max(pos0.y,pos1.y), > min(pos0.z,pos1.z), max(pos0.z,pos1.z)] > return abscoordinates > > abscoordinates = property(getabscoordinates) > > class Surf(object): > """FDS SURF directive. This describes a particular boundary condition. > id: string, id of the SURF. > color: triplet, color of the SURF. > fdsparam: string, FDS parameters of the SURF. These are passed to FDS as they are. > fdscommand: string, FDS command to export. > """ > def __init__(self, id, color=color.white, fdsparam=None): > self.id = id > self.__color = color > self.fdsparam = fdsparam > > def getcolor(self): > """Get color of the Surf""" > return self.__color > > def setcolor(self, color): > """Set color of the Surf and redraw all""" > self.__color = color > #FIX IT redrawall() > > color = property(getcolor, setcolor) > > def getfdscommand(self): > """Get the FDS command of this obj""" > fdscommand = "&SURF " > fdscommand += "ID=\'" + self.id + "\'" > fdscommand += ",COLOR=\'" + str(self.__color) + "\'" > if self.fdsparam: fdscommand += "," + self.fdsparam > fdscommand += " \\" > return fdscommand > > fdscommand = property(getfdscommand) > > class Obst(EBox): > """FDS OBST directive. This describes an obstacle. > surfs: list, list of 1, 3, 6 SURFs as boundary conditions for the OBST (SURF_ID, SURF_IDS, SURF_ID6) > fdsparam: string, FDS parameters of the OBST. These are passed to FDS as they are. > fdscommand: string, FDS command to export. > """ > def __init__(self, surfs = None, fdsparam=None, wireframe=True, solid=True, **args): > self.__surf6 = self.__calcsurf6(surfs) # convert surfs in surf6 (6 values). Useful for rotation of faces! > colors = self.__calccolors(self.__surf6) # take colors of the 6 surf6 > self.fdsparam = fdsparam # record the FDS additional parameters > # send the colors to the EBox, if they exist > if colors: > super(Obst, self).__init__(colors = colors, wireframe=wireframe, solid=solid, **args) > else: > super(Obst, self).__init__(wireframe=wireframe, solid=solid, **args) > > def getsurfs(self): > """Get __surf6 list""" > return self.__surf6 # surfs are now surf6, whether they were entered > > def setsurfs(self, surfs): > """Set __surf6 list""" > self.__surf6 = self.__calcsurf6(surfs) # convert surfs in surf6 (6 values) > self.colors = self.__calccolors(self.__surf6) # take colors of the 6 surf6 and set the property > self.redraw() # and now redraw, with new colors > > surfs = property(getsurfs, setsurfs) > > def __calcsurf6(self, surfs): > """transform the surfs (SURF_ID, SURF_IDS, SURF_ID6) in surf6 (SURF_ID6)""" > if surfs: > if len(surfs) == 1: # SURF_ID, 1 bc for 6 faces > surf6 = [surfs[0]] * 6 > return surf6 > elif len(surfs) == 3: # SURF_IDS, 3 bc: top, sides, bottom > surf6 = [surfs[1]] * 4 # sides, x0 x1 y0 y1 > surf6.append(surfs[2]) # bottom, z0 > surf6.append(surfs[0]) # top, z1 > return surf6 > elif len(surfs) == 6: # SURF_ID6, 6 bc for 6 faces > return surfs > else: # Something bad has happened, no bc set > return None > > def __calccolors(self, surf6): > """transform the surfs (SURF_ID, SURF_IDS, SURF_ID6) in surf6 (SURF_ID6)""" > if surf6: > return [ surf6[i].color for i in range(6) ] # Returns the color of each face > else: > return None > > def getabssurf6(self): > """Get absolute surf6 (boundary conditions), as in FDS convention. > This works only for pi/2 rotations!""" > # reorder the __surf6 list of bc, depending on absolute rotation of faces around z axis (absff) > ff = ["x0","x1","y0","y1","z0","z1"] # all the faces in list order > return [dict(zip(self.absff,self.__surf6))[face].id for face in ff] > > abssurf6 = property(getabssurf6) > > def getfdscommand(self): > """Get the FDS command of this obj""" > fdscommand = "&OBST " > fdscommand += "ID=\'" + self.id + "\'" > fdscommand += ",XB=" + ",".join([str(a) for a in self.abscoordinates]) > fdscommand += ",SURF_ID6=" + ",".join([str(a) for a in self.abssurf6]) > if self.fdsparam: fdscommand += "," + self.fdsparam > fdscommand += " \\" > return fdscommand > > fdscommand = property(getfdscommand) > > class Hole(EBox): > """FDS HOLE directive. This describes an hole in an obstacle. > fdsparam: string, FDS parameters of the HOLE. (Is there any? No.) These are passed to FDS as they are. > fdscommand: string, FDS command to export. > """ > def __init__(self, surfs = None, fdsparam=None, wireframe=True, solid=False, **args): > self.fdsparam = fdsparam > super(Hole, self).__init__(wireframe=wireframe, solid=solid, colorw=(0,1,1), **args) > > def getfdscommand(self): > """Get the FDS command of this obj""" > fdscommand = "&HOLE " > fdscommand += "ID=\'" + self.id + "\'" > fdscommand += ",XB=" + ",".join([str(a) for a in self.abscoordinates]) > if self.fdsparam: fdscommand += "," + self.fdsparam > fdscommand += " \\" > return fdscommand > > fdscommand = property(getfdscommand) > > class Vent(EBox): > """FDS VENT directive. This is used to apply a particular bc to a solid obstruction or a mesh boundary. > surf: obj, the boundary conditions to apply > size2d: 2-plet, size of the 2D VENT. > normal: vector, normal to the surface > fdsparam: string, FDS parameters of the VENT. These are passed to FDS as they are. > fdscommand: string, FDS command to export. > """ > def __init__(self, surf=None, fdsparam=None, wireframe=True, solid=True, size2d=(1,1), normal=(1,0,0), **args): > self.__surf = surf # records the surf > color = self.__surf.color # records the color of the surf > self.fdsparam = fdsparam # record the FDS additional parameters > self.__size2d = size2d # records the size. Only the first two value will be used! > self.__normal = normal # records the normal vector > super(Vent, self).__init__(colors = [color] * 6, wireframe=wireframe, solid=solid, size=self.__calcsize3d(size2d,normal), **args) > > def __calcsize3d(self, size2d, normal): > if normal == (1,0,0): > size3d = (0, size2d[0], size2d[1]) > elif normal == (0,1,0): > size3d = (size2d[0], 0, size2d[1]) > else: > size3d = (size2d[0], size2d[1], 0) > return size3d > > def getsize2d(self): > return self.__size2d > > def setsize2d(self, size2d): > self.__size2d = size2d > self.__size = self.__calcsize3d(size2d, self.__normal) > self.redraw() > > size2d = property(getsize2d, setsize2d) > > def getnormal(self): > return self.__normal > > def setnormal(self, normal): > self.__normal = normal > self.__size = self.__calcsize3d(self.__size2d, normal) > self.redraw() > > normal = property(getnormal, setnormal) > > def getsurf(self): > """Get __surf element""" > return self.__surf # surf is the applied bc > > def setsurf(self, surf): > """Set __surf element""" > self.__surf = surf # records the surf > color = self.__surf.color # records the color of the surf > self.redraw() # and now redraws, with new color > > surf = property(getsurf, setsurf) > > def getfdscommand(self): > """Get the FDS command of this obj""" > fdscommand = "&VENT " > fdscommand += "ID=\'" + self.id + "\'" > fdscommand += ",XB=" + ",".join([str(a) for a in self.abscoordinates]) > fdscommand += ",SURF_ID=" + self.__surf.id > if self.fdsparam: fdscommand += "," + self.fdsparam > fdscommand += " \\" > return fdscommand > > fdscommand = property(getfdscommand) > > # main > > print "scene" > scene = display(title="FDSCad view", forward=(-1,-1,0),up=(0,0,1), autocenter=True, autoscale=True) > > # Building frames > print "Building frames:" > print " O : universe" > print " f1: first frame depending on the universe" > print " f2: second frame depending on f1" > > O = EFrame(frame=None, id="O", pos=(0,0,0)) > f1 = EFrame(frame=O, id="f1", pos=(1,2,1)) > f1.rotate() > f2 = EFrame(frame=f1, id="f2", pos=(4,2,0)) > f2.rotate() > raw_input("Proceed?") > > # Test visibility > print "Test visibility of f2" > f2.visible = False > raw_input("Proceed?") > f2.visible = True > > # Defining boundary conditions > wood = Surf(id="wood",color=(1,0,0),fdsparam="PROVA") > water = Surf(id="water",color=(0,0,1),fdsparam="PROVA") > inert = Surf(id="inert",color=(1,1,1),fdsparam="PROVA") > print wood.fdscommand > print water.fdscommand > print inert.fdscommand > > # Building an obstacle > print "Building an obstacle o1, depending on f2" > surfs = [wood,water,inert] > o1 = Obst(frame=f2, id="o1", pos=(3,2,0), size=(5,4,3), origin=(0,0,0), surfs=surfs, fdsparam="PROVA") > print o1.fdscommand > raw_input("Proceed?") > > # Building an obstacle > print "Building an obstacle o2, depending on f1" > surfs = [inert] > o2 = Obst(frame=f1, id="o2", pos=(-2.5,-2,0), size=(1,1,5), origin=(0,1,.5), surfs=surfs, fdsparam="PROVA2") > print o2.fdscommand > raw_input("Proceed?") > > # test changing bounday conditions > print "Changing o1 boundary conditions." > surfs = [wood,water,inert,inert,inert,inert] > o1.surfs = surfs > print o1.fdscommand > raw_input("Proceed?") > > # Building an hole > print "Building an hole h1, to o1." > h1 = Hole(frame=o1, id="h1", pos=(3,2,1), size=(2,3,1), origin=(.5,0,0), fdsparam="PROVA") > print h1.fdscommand > raw_input("Proceed?") > > # Testing wireframe > print "Wireframe o1." > o1.solid = False > raw_input("Proceed?") > o1.solid = True > > # Building a Vent > print "Building a Vent 1, to o1." > s1 = Vent(frame=o1, id="s1", pos=(-0.01,1,1), size2d=(2,1), surf=water, normal=(1,0,0)) > print s1.fdscommand > raw_input("Proceed?") > > # Rotate, calculate the coordinates and the absolute positions of faces > for i in range(4): > o1.rotate() > print "o1 rotation #" + str(i) > print " o1 abs pos of origin (handler): ", o1.abspos > print " o1 abs coords of the box (FDS notation): ", o1.abscoordinates > print " o1 abs faces (FDS notation: faces x0, x1, y0, y1, z0, z1): ", o1.abssurf6 > print " o1 fdsparam (passed as it is to FDS): ", o1.fdsparam > print o1.fdscommand > print > raw_input("Proceed?") > > for i in range(4): > f2.rotate() > print "f2 rotation #" + str(i) > print " o1 abs pos of origin (handler): ", o1.abspos > print " o1 abs coords of the box (FDS notation): ", o1.abscoordinates > print " o1 abs faces (FDS notation: faces x0, x1, y0, y1, z0, z1): ", o1.abssurf6 > print " o1 fdsparam (passed as it is to FDS): ", o1.fdsparam > print o1.fdscommand > print > raw_input("Proceed?") > > for i in range(4): > f1.rotate() > print "f1 rotation #" + str(i) > print " o1 abs pos of origin (handler): ", o1.abspos > print " o1 abs coords of the box (FDS notation): ", o1.abscoordinates > print " o1 abs faces (FDS notation: faces x0, x1, y0, y1, z0, z1): ", o1.abssurf6 > print " o1 fdsparam (passed as it is to FDS): ", o1.fdsparam > print o1.fdscommand > print > raw_input("Proceed?") > > print "Ended." > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > > ------------------------------------------------------------------------ > > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |
From: Ron A. <rr...@ro...> - 2008-01-09 17:46:06
|
Frédéric Mantegazza wrote: > On mardi 08 janvier 2008, Ron Adam wrote: > >> Personally, I'd love to see that feature as methods of shapes and >> frames. > > Well, your are using a OO language ;o) just create a new MyFrame object, > from frame, and add the new methods... > > class MyFrame(frame): > def relocate(self, parent): > ... > Yes, that would work for frame, but to be complete, you would also need to do the other 13 objects as My____(). So maybe a general use function would be better after all. <shrug> def reframe(obj, new_frame): ... Still thats only part of the solution for objects with direction attributes such as volocities that also need to be adjusted. Ron |
From: Emanuele G. <ema...@gm...> - 2008-01-09 13:39:17
|
Hi, first of all *thank you* very much for developing VPython and making it open source. My name is Emanuele Gissi and I am a recent subscriber to this list. I am not a professional developer (http://gissi.free.fr), I am an officer of the Italian National Fire Brigade ( http://www.vigilfuoco.it/). I am using Ubuntu Linux and rather new to Python, but really impressed by its power and simplicity. I encountered VPython while trying to develop a small and simple preprocessor for an open source CFD program named FDS ( http://www.fire.nist.gov/fds/) used to simulate fires in buildings. FDS does not have an own GUI to enter the geometry of the building. (Yes, there is Pyrosim ( http://thunderheadeng.com/pyrosim/), but it is a commercial application, not from NIST, closed source and Windows version only). And developers at NIST would be very interested in a open source, multi platform GUI for FDS. My small (for now ;-) preprocessor (FDScad) is a sort of CAD for the geometry of the building and its boundary conditions. I attach the current version to this email. I don't think it can be still a candidate for "contributed programs": it's in its infancy and it is a very rough prototype! Now, question time: 1) Is there a more vpython-ish way to do the following: (probably in 4beta version?) a - I reimplemented the box class, as I needed a box with differently colored faces. b - I implemented a function for absolute positions of objects. c - Another function calculates the absolute normals of faces of my reimplemented box. 2) Is there a binary package (deb, tar.gz, rpm) for the 4beta version? I admit that I am not able to compile it on my own... This would facilitate testing. Thank you, once more, in advance. Emanuele Gissi. |
From:
<fre...@gb...> - 2008-01-08 23:24:37
|
On mardi 08 janvier 2008, Ron Adam wrote: > Personally, I'd love to see that feature as methods of shapes and > frames. Well, your are using a OO language ;o) just create a new MyFrame object,=20 from frame, and add the new methods... class MyFrame(frame): def relocate(self, parent): ... =2D-=20 Fr=E9d=E9ric http://www.gbiloba.org |
From: Ron A. <rr...@ro...> - 2008-01-08 22:08:06
|
Bruce Sherwood wrote: > I agree that we need ways to move between frame and scene coordinates. I > too have tripped over these missing links. > > Moving from frame to frame seems to me a rather different and more > complex issue. After a lot of trial and error, I figured out the following. def frame_to_world_pos(local_pos, frame): """ Frame position in world coordinates. """ x_axis = norm(frame.axis) z_axis = norm(cross(x_axis, frame.up)) y_axis = norm(cross(z_axis, x_axis)) x, y, z = local_pos return frame.pos + x * x_axis + y * y_axis + z * z_axis def world_to_frame_pos(world_pos, frame): """ World position in frame coordinates. """ x_axis = norm(frame.axis) z_axis = norm(cross(x_axis, frame.up)) y_axis = norm(cross(z_axis, x_axis)) dist = vector(world_pos) - frame.pos return vector(dot(dist, x_axis), dot(dist, y_axis), dot(dist, z_axis)) def frame_to_frame_pos(pos, frame1, frame2): """ Frame position in other frame coordinates. """ wpos = frame_to_world_pos(pos, frame1) return world_to_frame_pos(wpos, frame2) I think with these I can now make some relocate functions that move objects between frames without changing the rotation and position relative to world space. Personally, I'd love to see that feature as methods of shapes and frames. shape.relocate(new_parent_frame) frame.relocate(new_parent_frame) Cheers, Ron > Ron Adam wrote: >> I want to add a vector in world relative coordinates to objects in a >> rotated frame. It first needs to be translated to frame coordinates. >> >> I can do this for single axis, but when the frame rotation involves >> rotation of more than one axis, I can't seem to get it correct. >> >> >> It would be nice to have these three functions ... >> >> >> # The current world_space_function. >> >> def frame_to_world_pos(pos, frame): >> """ Frame position in world space coordinates. """ >> x_axis = norm(frame.axis) >> z_axis = norm(cross(frame.axis, frame.up)) >> y_axis = norm(cross(z_axis, x_axis)) >> return frame.pos+pos.x*x_axis+pos.y*y_axis+pos.z*z_axis >> >> >> def world_to_frame_pos(pos, frame): >> """ World position in frame space coordinates. """ >> ??? >> return frame_pos >> >> >> def frame_to_frame_pos(pos, frame1, frame2): >> """ Frame position in other frame space coordinates. """ >> wpos = frame_to_world_pos(pos, frame1) >> return world_to_frame_pos(wpos, frame2) >> >> >> Is there an easy way to move objects from frame to frame and keep their >> orientation relative to world space? >> >> >> Thanks, Ron >> >> >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2005. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Visualpython-users mailing list >> Vis...@li... >> https://lists.sourceforge.net/lists/listinfo/visualpython-users >> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ |
From: Martin C. <cos...@wa...> - 2008-01-07 06:59:35
|
Joe Heafner wrote: > I've just built visual-py25 under Fink under OS X 10.5.1 with all the > Xquartz updates applied. I get no trackpad functionality at all, but my > USB mouse (Logitech VX Nano) works just fine. Am I missing something? For me it works as expected (*). If you run xev, does it show the trackpad events as you expect them, i.e. alt-click = button2 and cmd-click = button3? If not, you need to look at your X11 preferences. (*) I have never managed to do anything reasonable with mouse (or trackbad) button 1 in vpython, except make the scene disappear sideways or into the depths of the universe. -- Martin |
From: Bruce S. <Bru...@nc...> - 2008-01-07 06:48:47
|
Ruth Chabay ran the production version of VPython on 10.5 without mouse problems. The insuperable problem she encountered was the problems with the graphics driver on recent MacBook Pros, which affects all OpenGL programs including VPython and Second Life and still has not been addressed by Apple. Bruce Joe Heafner wrote: > I've just built visual-py25 under Fink under OS X 10.5.1 with all the > Xquartz updates applied. I get no trackpad functionality at all, but my > USB mouse (Logitech VX Nano) works just fine. Am I missing something? > > Joe |
From: Joe H. <hea...@gm...> - 2008-01-06 23:27:18
|
I've just built visual-py25 under Fink under OS X 10.5.1 with all the Xquartz updates applied. I get no trackpad functionality at all, but my USB mouse (Logitech VX Nano) works just fine. Am I missing something? Joe |
From: Bruce S. <Bru...@nc...> - 2008-01-05 23:43:43
|
I agree that we need ways to move between frame and scene coordinates. I too have tripped over these missing links. Moving from frame to frame seems to me a rather different and more complex issue. Bruce Sherwood Ron Adam wrote: > I want to add a vector in world relative coordinates to objects in a > rotated frame. It first needs to be translated to frame coordinates. > > I can do this for single axis, but when the frame rotation involves > rotation of more than one axis, I can't seem to get it correct. > > > It would be nice to have these three functions ... > > > # The current world_space_function. > > def frame_to_world_pos(pos, frame): > """ Frame position in world space coordinates. """ > x_axis = norm(frame.axis) > z_axis = norm(cross(frame.axis, frame.up)) > y_axis = norm(cross(z_axis, x_axis)) > return frame.pos+pos.x*x_axis+pos.y*y_axis+pos.z*z_axis > > > def world_to_frame_pos(pos, frame): > """ World position in frame space coordinates. """ > ??? > return frame_pos > > > def frame_to_frame_pos(pos, frame1, frame2): > """ Frame position in other frame space coordinates. """ > wpos = frame_to_world_pos(pos, frame1) > return world_to_frame_pos(wpos, frame2) > > > Is there an easy way to move objects from frame to frame and keep their > orientation relative to world space? > > > Thanks, Ron > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
From: Ron A. <rr...@ro...> - 2008-01-05 22:29:29
|
I want to add a vector in world relative coordinates to objects in a rotated frame. It first needs to be translated to frame coordinates. I can do this for single axis, but when the frame rotation involves rotation of more than one axis, I can't seem to get it correct. It would be nice to have these three functions ... # The current world_space_function. def frame_to_world_pos(pos, frame): """ Frame position in world space coordinates. """ x_axis = norm(frame.axis) z_axis = norm(cross(frame.axis, frame.up)) y_axis = norm(cross(z_axis, x_axis)) return frame.pos+pos.x*x_axis+pos.y*y_axis+pos.z*z_axis def world_to_frame_pos(pos, frame): """ World position in frame space coordinates. """ ??? return frame_pos def frame_to_frame_pos(pos, frame1, frame2): """ Frame position in other frame space coordinates. """ wpos = frame_to_world_pos(pos, frame1) return world_to_frame_pos(wpos, frame2) Is there an easy way to move objects from frame to frame and keep their orientation relative to world space? Thanks, Ron |
From: Bruce S. <Bru...@nc...> - 2008-01-05 05:00:46
|
Now available at sourceforge: 4.beta23 for Windows and Linux offering significant speed-up in rendering of boxes and curves. In testing this version, I found very few test programs not working properly, and for the most part performance is about as good as with the production version of VPython. If you are the least bit adventurous I encourage you to try the beta version. Please report any bugs you find that are not mentioned in the bug section of the documentation on new features found in the on-line help. If possible, please offer a very small test program that demonstrates the problem, and briefly describe the symptoms that you observe on your computer, as sometimes bugs are computer-specific. Bruce Sherwood |
From: Bruce S. <Bru...@nc...> - 2008-01-02 16:55:51
|
I've just posted a corrected version of pixelplot.py in the contributed section of vpython.org. I made an off-by-one error in "connecting the dots" in the curves that are used with the production version of VPython. The effect was to blend/blur adjacent colors rather than make them distinct as intended. Bruce Sherwood > ----------------------- > A colleague asked me about pixel-oriented plotting in VPython, for doing > such things as chaos-related plots. I replied that there really isn't > good support for that in the production version of VPython, though the > new "points" object in the beta version is appropriate. > > But then I realized that there is something one can do: Create a stack > of horizontal lines (curve objects) and set colors at points that way. > It works, and in the contributed section of vpython.org there is now a > little program pixelplot.py which makes a display of the famous > Mandelbrot set. The program also checks to see whether there is a > "points" object available and uses that, which is faster and simpler. > > There's a slightly tricky issue when using curves, which is explained in > the documentation for curve. Colors are interpolated between points. So > to make the right color at a point, you have to stick in an extra point. > So 4 pixels requires 8 points on the curve: 0-1, 1-2, 2-3, 3-4. > > Bruce Sherwood > > P.S. In the process I found that there are bugs in the points object. It > dies when you try to append more than 33000 points. Dunno why yet. But > this doesn't affect the posted program. > > > |
From: Bruce S. <Bru...@nc...> - 2008-01-01 23:00:44
|
A colleague asked me about pixel-oriented plotting in VPython, for doing such things as chaos-related plots. I replied that there really isn't good support for that in the production version of VPython, though the new "points" object in the beta version is appropriate. But then I realized that there is something one can do: Create a stack of horizontal lines (curve objects) and set colors at points that way. It works, and in the contributed section of vpython.org there is now a little program pixelplot.py which makes a display of the famous Mandelbrot set. The program also checks to see whether there is a "points" object available and uses that, which is faster and simpler. There's a slightly tricky issue when using curves, which is explained in the documentation for curve. Colors are interpolated between points. So to make the right color at a point, you have to stick in an extra point. So 4 pixels requires 8 points on the curve: 0-1, 1-2, 2-3, 3-4. Bruce Sherwood P.S. In the process I found that there are bugs in the points object. It dies when you try to append more than 33000 points. Dunno why yet. But this doesn't affect the posted program. |
From: Bruce S. <Bru...@nc...> - 2007-12-31 19:21:16
|
I repeated my own timings and then remembered why I didn't use try/except. The try/except scheme does give the fastest square root of a scalar (1.2 microsec on my 1 GHz laptop) but doubles the time for sqrt(array([1,2,3,4,5,6,7,8,9,10])), from about 10 microsec to about 20 microsec. So I've settled for the following, which gives sqrt(scalar) of 1.7 microsec and almost no change in sqrt(array): def sqrt(x): t = type(x) if t is float or t is int or t is long: return _m_sqrt(x) return _n_sqrt(x) Thanks again for thinking about this issue, and for alerting me to check not just for float. Bruce Sherwood P.S. What's in the just-released 4.beta22 only checks for float, but the correction is now in CVS. Scott David Daniels wrote: > Bruce Sherwood wrote: > >> In a test version not yet released I've implemented essentially the >> scheme suggested by Scott David Daniels, and it works very well. Thanks! >> >> I found by timing measurements that a faster scheme with less penalty >> for the case of sqrt(array) looks like this: >> >> def sqrt(x): >> if type(x) is float: return mathsqrt(x) >> return numpysqrt(x) >> >> This scheme not only solves the problem but actually yields faster >> square roots of scalar arguments than numpy, by about a factor of 3. So >> what was conceived as a workaround is actually a performance enhancement. >> > > I actually did a bit of timing before I suggested the try/except version. > I use subclasses of ints and floats in some of the code I write. > A simple example (to make values more obvious): > class Float(float): > def __repr__(self): > return '%s(%s)' % (self.__class__.__name__, > float.__repr__(self)) > class Meters(Float): pass > class Grams(Float): pass > ... > Then I can make physical constants a little more obvious interactively. > > My first version was: > def sqrt(x): > if isinstance(x, (int, long, float)): > return mathsqrt(x) > else: > return numpysqrt(x) > > I then realized math.sqrt was already doing this check. Since the check > is already there, I decided not to slow down the more common scalar > case. That was when I switched to the "try: ... except TypeError: ..." > form (to use math.sqrt's type checks). I then made sure performance on > a short (ten-element) vector was not too severely impacted. If you > still want to exact match on types, I'd suggest accepting at least > floats and ints, since you'll otherwise get performance reports about > how much slower sqrt(4) is than sqrt(4.0). > > Something more like: > def sqrt(x): > t = type(x) > if t is float or t is int: > return mathsqrt(x) > else: > return numpysqrt(x) > > --Scott David Daniels > Sco...@Ac... > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
From: Bruce S. <Bru...@nc...> - 2007-12-31 18:46:34
|
4.beta22 now available for Windows and Linux at sourceforge. Fixed a bug which made rendering of spheres very slow. When doing some experiments on adjusting the level of detail for spheres, Arthur Siegel in December 2006 commented out the statement that used a cached description of a sphere. The effect was to recompute a 3D model of every sphere in every render cycle. There are still some issues with slow rendering in the beta version, but this was certainly the most serious bug. The recently contributed program vspace.py now runs on the beta version, though not as well as on the production version of VPython. Bruce Sherwood |
From: Bruce S. <Bru...@nc...> - 2007-12-31 05:25:42
|
Good points. Thanks. Bruce Sherwood Scott David Daniels wrote: > Bruce Sherwood wrote: > >> In a test version not yet released I've implemented essentially the >> scheme suggested by Scott David Daniels, and it works very well. Thanks! >> >> I found by timing measurements that a faster scheme with less penalty >> for the case of sqrt(array) looks like this: >> >> def sqrt(x): >> if type(x) is float: return mathsqrt(x) >> return numpysqrt(x) >> >> This scheme not only solves the problem but actually yields faster >> square roots of scalar arguments than numpy, by about a factor of 3. So >> what was conceived as a workaround is actually a performance enhancement. >> > > I actually did a bit of timing before I suggested the try/except version. > I use subclasses of ints and floats in some of the code I write. > A simple example (to make values more obvious): > class Float(float): > def __repr__(self): > return '%s(%s)' % (self.__class__.__name__, > float.__repr__(self)) > class Meters(Float): pass > class Grams(Float): pass > ... > Then I can make physical constants a little more obvious interactively. > > My first version was: > def sqrt(x): > if isinstance(x, (int, long, float)): > return mathsqrt(x) > else: > return numpysqrt(x) > > I then realized math.sqrt was already doing this check. Since the check > is already there, I decided not to slow down the more common scalar > case. That was when I switched to the "try: ... except TypeError: ..." > form (to use math.sqrt's type checks). I then made sure performance on > a short (ten-element) vector was not too severely impacted. If you > still want to exact match on types, I'd suggest accepting at least > floats and ints, since you'll otherwise get performance reports about > how much slower sqrt(4) is than sqrt(4.0). > > Something more like: > def sqrt(x): > t = type(x) > if t is float or t is int: > return mathsqrt(x) > else: > return numpysqrt(x) > > --Scott David Daniels > Sco...@Ac... > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
From: Ron A. <rr...@ro...> - 2007-12-31 04:01:27
|
Bruce Sherwood wrote: > That's a spectacular demonstration of work that needs to be done on the > beta version, as it takes 5 seconds (!) to render the scene on my > laptop, whereas the display and motion are completely smooth in the > production version of VPython. I could possibly change it to add the asteroid objects after the main loop is started until a desired frame rate is achieved. It will still run smoothly on slower computers that way. And display the object count in a corner for comparisons. > I've added this to the contributed section of vpython.org. Thanks! You're welcome, it was fun to figure out how to do it too. Ron > I deleted the unnecessary line that made the mouse cursor visible, since > that's the default and this feature is as yet missing from the beta > version, should someone wish to see the extreme slowness of the rendering. > > Bruce Sherwood > Ron Adam wrote: >> >> Bruce Sherwood wrote: >>> Questions were asked recently about looking outward from the origin >>> (or other location) and rotating the view of the surrounding scene. >>> As an example of this kind of viewing, see look_around.py in the >>> contributed section of vpython.org. >>> >>> Bruce Sherwood >> Here's a fun demo that uses rotating and spin I meant to submit some >> time ago and never did. >> >> Enjoy, >> Ron Adam >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2005. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Visualpython-users mailing list >> Vis...@li... >> https://lists.sourceforge.net/lists/listinfo/visualpython-users > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ |
From:
<fre...@gb...> - 2007-12-30 23:25:58
|
On dimanche 30 d=E9cembre 2007, Bruce Sherwood wrote: > Okay, I've commented the tricky geometry calculations. Thank you very much :o) I'll try to apply this to my panohead.. =2D-=20 Fr=E9d=E9ric http://www.gbiloba.org |
From: Scott D. D. <Sco...@Ac...> - 2007-12-30 21:52:51
|
Bruce Sherwood wrote: > In a test version not yet released I've implemented essentially the > scheme suggested by Scott David Daniels, and it works very well. Thanks! > > I found by timing measurements that a faster scheme with less penalty > for the case of sqrt(array) looks like this: > > def sqrt(x): > if type(x) is float: return mathsqrt(x) > return numpysqrt(x) > > This scheme not only solves the problem but actually yields faster > square roots of scalar arguments than numpy, by about a factor of 3. So > what was conceived as a workaround is actually a performance enhancement. I actually did a bit of timing before I suggested the try/except version. I use subclasses of ints and floats in some of the code I write. A simple example (to make values more obvious): class Float(float): def __repr__(self): return '%s(%s)' % (self.__class__.__name__, float.__repr__(self)) class Meters(Float): pass class Grams(Float): pass ... Then I can make physical constants a little more obvious interactively. My first version was: def sqrt(x): if isinstance(x, (int, long, float)): return mathsqrt(x) else: return numpysqrt(x) I then realized math.sqrt was already doing this check. Since the check is already there, I decided not to slow down the more common scalar case. That was when I switched to the "try: ... except TypeError: ..." form (to use math.sqrt's type checks). I then made sure performance on a short (ten-element) vector was not too severely impacted. If you still want to exact match on types, I'd suggest accepting at least floats and ints, since you'll otherwise get performance reports about how much slower sqrt(4) is than sqrt(4.0). Something more like: def sqrt(x): t = type(x) if t is float or t is int: return mathsqrt(x) else: return numpysqrt(x) --Scott David Daniels Sco...@Ac... |
From: Bruce S. <Bru...@nc...> - 2007-12-30 18:44:33
|
Okay, I've commented the tricky geometry calculations. Bruce Sherwood Frédéric Mantegazza wrote: > On samedi 29 décembre 2007, Bruce Sherwood wrote: > >> Questions were asked recently about looking outward from the origin (or >> other location) and rotating the view of the surrounding scene. As an >> example of this kind of viewing, see look_around.py in the contributed >> section of vpython.org. >> > > I'm not sure to clearly understand how it works. Could you detail your > code, please? > > |
From: Rob S. <sa...@ph...> - 2007-12-30 13:43:08
|
I too recently stumbled upon Johnny Chung Lee's Wii projects. As an alternative when the main page http://www.cs.cmu.edu/~johnny/projects/wii/ fails, You can always try the Google cache, by first doing the search: http://www.google.com/search?q=%22Johnny+Chung+Lee%22 then following the appropriate "Cache" link. For the YouTube videos he posted, consult http://www.youtube.com/profile?user=jcl5m Last week, I played around with GlovePIE http://carl.kenner.googlepages.com/glovepie to see how the Wii Remote interacts with my laptop via Bluetooth. When my I buy my own Wii Remote [since I was trying one from my brother's Wii] and some IR-LEDs, I'm going to play around with some of Johnny Chung Lee's ideas. rob |
From: P H B. <p.h...@bh...> - 2007-12-30 13:05:19
|
Dear Vpython Group I have had some (intermittent) success with the link Bruce supplied http://www.cs.cmu.edu/~johnny/projects/wii/ I entered the above into Google, and clicked "I'm feeling lucky" The first time , this got me through to Johnny Chung Lee's page, but next time, it did not! I am attaching a copy of the page: hope it reaches you Regards Peter P H Borcherds phone +44 121 475 3029 p.h...@bh... |