This module defines a generic Geometry superclass which adds all the possibilities of coordinate transformations offered by the Coords class to the derived classes.
Classes defined in module geometry
A generic geometry object allowing transformation of coords sets.
The Geometry class is a generic parent class for all geometric classes, intended to make the Coords transformations available without explicit declaration. This class is not intended to be used directly, only through derived classes. Examples of derived classes are Formex, Mesh, Curve.
There is no initialization to be done when constructing a new instance of this class. The class just defines a set of methods which operate on the attribute coords, which should be a Coords object. Most of the transformation methods of the Coords class are thus exported through the Geometry class to its derived classes, and when called, will get executed on the coords attribute. The derived class constructor should make sure that the coords attribute exists, has the proper type and contains the coordinates of all the points that should get transformed under a Coords transformation.
Derived classes can (and in most cases should) declare a method _set_coords(coords) returning an object that is identical to the original, except for its coords being replaced by new ones with the same array shape.
The Geometry class provides two possible default implementations:
When using the first method, a statement like `B = A.scale(0.5)` will result in both A and B pointing to the same scaled object, while with the second method, A would still be the untransformed object. Since the latter is in line with the design philosophy of pyFormex, it is set as the default _set_coords method. Most derived classes that are part of pyFormex however override this default and implement a more efficient copy method.
The following Geometry methods return the value of the same method applied on the coords attribute. Refer to the correponding coords.Coords method for their precise arguments.
x(), y(), z(), bbox(), center(), centroid(), sizes(), dsize(), bsphere(), distanceFromPlane(), distanceFromLine(), distanceFromPoint(), directionalSize(), directionalWidth(), directionalExtremes(), __str__().
The following Coords transformation methods can be directly applied to a Geometry object or a derived class object. The return value is a new object identical to the original, except for the coordinates, which will have been transformed by the specified method. Refer to the correponding coords.Coords method in for the precise arguments of these methods:
scale(), translate(), centered(), rotate(), shear(), reflect(), affine(), position(), cylindrical(), hyperCylindrical(), toCylindrical(), spherical(), superSpherical(), toSpherical(), bump(), bump1(), bump2(), flare(), map(), map1(), mapd(), replace(), swapAxes(), rollAxes(), projectOnPlane(), projectOnSphere(), projectOnCylinder(), isopar(), transformCS(), addNoise(), rot(), trl().
Return a deep copy of the object.
Apply ‘scale’ transformation to the Geometry object.
See coords.Coords.scale() for details.
Return a scaled copy of the Formex with given size in all directions.
If a direction has zero size, it is not rescaled.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Apply ‘centered’ transformation to the Geometry object.
See coords.Coords.centered() for details.
Apply ‘align’ transformation to the Geometry object.
See coords.Coords.align() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘shear’ transformation to the Geometry object.
See coords.Coords.shear() for details.
Apply ‘reflect’ transformation to the Geometry object.
See coords.Coords.reflect() for details.
Apply ‘affine’ transformation to the Geometry object.
See coords.Coords.affine() for details.
Apply ‘position’ transformation to the Geometry object.
See coords.Coords.position() for details.
Apply ‘cylindrical’ transformation to the Geometry object.
See coords.Coords.cylindrical() for details.
Apply ‘hyperCylindrical’ transformation to the Geometry object.
See coords.Coords.hyperCylindrical() for details.
Apply ‘toCylindrical’ transformation to the Geometry object.
See coords.Coords.toCylindrical() for details.
Apply ‘spherical’ transformation to the Geometry object.
See coords.Coords.spherical() for details.
Apply ‘superSpherical’ transformation to the Geometry object.
See coords.Coords.superSpherical() for details.
Apply ‘egg’ transformation to the Geometry object.
See coords.Coords.egg() for details.
Apply ‘toSpherical’ transformation to the Geometry object.
See coords.Coords.toSpherical() for details.
Apply ‘bump’ transformation to the Geometry object.
See coords.Coords.bump() for details.
Apply ‘bump1’ transformation to the Geometry object.
See coords.Coords.bump1() for details.
Apply ‘bump2’ transformation to the Geometry object.
See coords.Coords.bump2() for details.
Apply ‘flare’ transformation to the Geometry object.
See coords.Coords.flare() for details.
Apply ‘map’ transformation to the Geometry object.
See coords.Coords.map() for details.
Apply ‘map1’ transformation to the Geometry object.
See coords.Coords.map1() for details.
Apply ‘mapd’ transformation to the Geometry object.
See coords.Coords.mapd() for details.
Apply ‘replace’ transformation to the Geometry object.
See coords.Coords.replace() for details.
Apply ‘swapAxes’ transformation to the Geometry object.
See coords.Coords.swapAxes() for details.
Apply ‘rollAxes’ transformation to the Geometry object.
See coords.Coords.rollAxes() for details.
Apply ‘projectOnPlane’ transformation to the Geometry object.
See coords.Coords.projectOnPlane() for details.
Apply ‘projectOnSphere’ transformation to the Geometry object.
See coords.Coords.projectOnSphere() for details.
Apply ‘projectOnCylinder’ transformation to the Geometry object.
See coords.Coords.projectOnCylinder() for details.
Apply ‘isopar’ transformation to the Geometry object.
See coords.Coords.isopar() for details.
Apply ‘transformCS’ transformation to the Geometry object.
See coords.Coords.transformCS() for details.
Apply ‘addNoise’ transformation to the Geometry object.
See coords.Coords.addNoise() for details.
Apply ‘rotate’ transformation to the Geometry object.
See coords.Coords.rotate() for details.
Apply ‘translate’ transformation to the Geometry object.
See coords.Coords.translate() for details.
Write a Geometry to a .pgf file.
If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.
Functions defined in module geometry