From: Bruce S. <Bru...@nc...> - 2011-02-21 02:21:21
|
At vpython.org are installers for VPython 5.50 which include a powerful new "extrusion" object developed by Kadir Haldenbilen and me. The basic idea is that you prepare a 2D shape which you then extrude along a path that is like the pos attribute of a curve object: extrusion(pos=...., shape=....) Libraries of common shapes and paths are provided (rectangle, circle, arc, star, etc.). Included are tools for creating complex gears, and shapes made from text. The 2D shape can be prepared using "constructive geometry" supported by the Polygon module (which is imported by VPython and included with the Windows and Mac installers). Polygon objects consist of closed contours (lists of points in the xy plane), and these objects can be combined. For example, if R is a Polygon object representing a rectangle, and C is a Polygon object representing a circle that lies within the boundary of the rectangle, then R-C is a 2D shape consisting of a rectangle with a hole in it, which can be extruded along a path by using the extrusion object. If the circle lies partly outside the rectangle, R-C is a rectangle with a portion of a circle cut out of the edge. The implementation of the extrusion object is quite fast and efficient, so that not only is it easy to create quite complex objects, but it is also feasible to make the object change dynamically by altering the path, the scale factors along the path, the amount of twist along the path, or even the extruded shape. After installing VPython 5.50, you are encouraged to run the new example program extrusion_overview.py which is an interactive tutorial on the extrusion object and also an interesting demonstration of the tutorial possibilities of VPython. Kadir Haldenbilen has contributed new example programs electric_motor.py (the program which produced the attached image), differential_gear.py, conch.py, medusa.py, and extruded_columns.py that illustrate some uses of the new extrusion object. He has also contributed some useful new materials: shiny, chrome, blazed, silver, bricks, ice, glass, and BlueMarble (earth with clouds), and the example program material_test.py has been revised to display all the materials now available. The text object now uses the extrusion object for its display, but the extrusion object does not make the text object obsolete, because the text object emphasizes text-related information such as line widths, etc. The shapes.text() routine supplies the necessary information to the text object, and this additional information can be used by you should you wish to do so. The curve object has been updated to permit using paths obtained from the new paths library. For the benefit of Linux users who might not have installed the Polygon, FontTools, and ttfquery modules that are needed by the 3D text object and by the new extrusion object, the imports have been rearranged in such a way that if you don’t have the necessary modules installed you can still run VPython, but without being able to use text and extrusion objects. A long-standing bug has been fixed in keyboard handling on the Mac, in which each keypress generated two events, the first one correct and the second one garbage. The tutorial program extrusion_overview.py made it clear that the default font height of 13 of label text was not actually consistent across Windows, Mac, and Linux. The text has been adjusted so that labels look quite similar on all platforms. Bruce Sherwood |