8.1.10 Non-affine transformations

cylindrical( dir=[0,1,2],scale=[1.,1.,1.])
Converts from cylindrical to cartesian after scaling.

dir specifies which coordinates are interpreted as resp. distance(r), angle(theta) and height(z). Default order is [r,theta,z].
scale will scale the coordinate values prior to the transformation. (scale is given in order r,theta,z). The resulting angle is interpreted in degrees.

toCylindrical( dir=[0,1,2])
Converts from cartesian to cylindrical coordinates.

dir specifies which coordinates axes are parallel to respectively the cylindrical axes distance(r), angle(theta) and height(z). Default order is [x,y,z]. The angle value is given in degrees.

spherical( dir=[0,1,2],scale=[1.,1.,1.],colat=False)
Converts from spherical to cartesian after scaling.

dir specifies which coordinates are interpreted as longitude(theta), latitude(phi) and distance(r).
scale will scale the coordinate values prior to the transformation.
Angles are then interpreted in degrees.
Latitude, i.e. the elevation angle, is measured from equator in direction of north pole(90). South pole is -90. If colat=True, the third coordinate is the colatitude (90-lat) instead. That choice may facilitate the creation of spherical domes.

toSpherical( dir=[0,1,2])
Converts from cartesian to spherical coordinates.

dir specifies which coordinates axes are parallel to respectively the spherical axes distance(r), longitude(theta) and colatitude(phi). Colatitude is 90 degrees - latitude, i.e. the elevation angle measured from north pole(0) to south pole(180). Default order is [0,1,2], thus the equator plane is the (x,y)-plane. The returned angle values are given in degrees.

bump1( dir,a,func,dist)
Return a Formex with a one-dimensional bump.

dir specifies the axis of the modified coordinates.
a is the point that forces the bumping.
dist specifies the direction in which the distance is measured.
func is a function that calculates the bump intensity from distance. func(0) should be different from 0.

bump2( dir,a,func)
Return a Formex with a two-dimensional bump.

dir specifies the axis of the modified coordinates.
a is the point that forces the bumping.
func is a function that calculates the bump intensity from distance. func(0) should be different from 0.

bump( dir,a,func,dist=None)
Return a Formex with a bump.

A bump is a modification of a set of coordinates by a non-matching point. It can produce various effects, but one of the most common uses is to force a surface to be indented by some point.

dir specifies the axis of the modified coordinates.
a is the point that forces the bumping.
func is a function that calculates the bump intensity from distance. func(0) should be different from 0.
dist is the direction in which the distance is measured : this can be one of the axes, or a list of one or more axes. If only 1 axis is specified, the effect is like function bump1(). If 2 axes are specified, the effect is like bump2. This function can take 3 axes however. Default value is the set of 3 axes minus the direction of modification. This function is then equivalent to bump2().

map( func)
Return a Formex mapped by a 3-D function.

This is one of the versatile mapping functions.
func is a numerical function which takes three arguments and produces a list of three output values. The coordinates [x,y,z] will be replaced by func(x,y,z). The function must be applicable to arrays, so it should only include numerical operations and functions understood by the numpy module.

This method is one of several mapping methods. See also map1() and mapd().
Example: E.map(lambda x,y,z: [2*x,3*y,4*z]) is equivalent with E.scale([2,3,4]).

map1( dir,func)
Return a Formex where coordinate i is mapped by a 1-D function.

func is a numerical function which takes one argument and produces one result. The coordinate dir will be replaced by func(coord[dir]). The function must be applicable on arrays, so it should only include numerical operations and functions understood by the numpy module. This method is one of several mapping methods. See also map() and mapd().

mapd( dir,func,point,dist=None)
Maps one coordinate by a function of the distance to a point.

func is a numerical function which takes one argument and produces one result. The coordinate dir will be replaced by func(d), where d is calculated as the distance to point. The function must be applicable on arrays, so it should only include numerical operations and functions understood by the numpy module. By default, the distance d is calculated in 3-D, but one can specify a limited set of axes to calculate a 2-D or 1-D distance.

This method is one of several mapping methods. See also map() and map1().
Example: E.mapd(2,lambda d:sqrt(10**2-d**2),f.center(),[0,1]) maps E on a sphere with radius 10.

replace( i,j,other=None)
Replace the coordinates along the axes i by those along j.

i and j are lists of axis numbers.
replace ([0,1,2],[1,2,0]) will roll the axes by 1.
replace ([0,1],[1,0]) will swap axes 0 and 1.
An optionally third argument may specify another Formex to take the coordinates from. It should have the same dimensions.

swapaxes( i,j)
Swap coordinate axes i and j. Beware! This is different from numpy's swapaxes() method, which swaps array axesof the ndarray object!

rollAxes( n=1)
Roll the coordinate axes over the given amount.

Default is 1, thus axis 0 becomes the new 1 axis, 1 becomes 2 and 2 becomes 0.

projectOnSphere( radius,center=[0.,0.,0.])
Project the points of the Formex on a sphere with given center and radius.

circulize( angle)
Transform a linear sector into a circular one.

A sector of the (0,1) plane with given angle, starting from the 0 axis, is transformed as follows: points on the sector borders remain in place. Points inside the sector are projected from the center on the circle through the intersection points of the sector border axes and the line through the point and perpendicular to the bisector of the angle.

circulize1( )
Transforms the first octant of the 0-1 plane into 1/6 of a circle.

Points on the 0-axis keep their position. Lines parallel to the 1-axis are transformed into circular arcs. The bisector of the first quadrant is transformed in a straight line at an angle Pi/6. This function is especially suited to create circular domains where all bars have nearly same length. See the Diamatic example.

shrink( factor)
Shrinks each element with respect to its own center.

Each element is scaled with the given factor in a local coordinate system with origin at the element center. The element center is the mean of all its nodes. The shrink operation is typically used (with a factor around 0.9) in wireframe draw mode to show all elements disconnected. A factor above 1.0 will grow the elements.