s3dlib.surface.Surface3DCollection

Contents

Static Methods

coor_convert(xyz[, tocart]) Coordinate transformation.
triangulateBase(rez, baseVcoor, …) Recursively subdivide triangles.
rectangulateBase(rez, baseVcoor, …) Recursively subdivide quadrilaterals.
chull(points, **kargs) Surface3DCollection Convex Hull for a set of 3D points.
implsurf(operation[, drez, domain, name]) Surface3DCollection defined by an implicit function f(x,y,z) = 0.

Geometry Properties/Methods

name Descriptive identifier for the surface geometry.
bounds Dictionary of surface geometric and value ranges.
vertices A 3 x N array of surface vertices.
vertexnormals(**kargs) Unit directions or Vector3DCollection of vertex normals at vertices.
facecenters A 3 x N array of surface face center coordinates.
facenormals(**kargs) Unit directions or Vector3DCollection of face normals at face centers.
edges ColorLine3DCollection of the surface edges from facecolors.
initedges ColorLine3DCollection of the initial surface edges.
area_h2b A 2 x N array of normalized N face areas and shapes.
svd_dict A dictionary of results from a Singular Value Decomposition of the data.
get_transformAxis(**kargs) Line3DCollection of the ‘last’ transformed surface coordinate axis.
normalize_scale() Scaling normalization array and reciprocal.

The following methods will return the calling object (self).
domain([xlim, ylim, zlim]) Set the domain of the surface.
triangulate([rez]) PLANAR subdivision of each face into triangular faces.
evert() Reverse direction of face normals.
transform([rotate, scale, translate]) Linear transformation of the surface object.
clip(operation[, usexyz]) Remove faces from the surface based on position.
clip_alpha(alphaCut[, useval]) Remove faces from the surface based on alpha transparency.
clip_plane(dist, **kargs) Remove faces from the surface based on a clip surface.
clip_normals([direction]) Remove faces from the surface based on a direction relative to face normals.
map_geom_from_op(operation[, returnxyz, name]) Functional transformation of surface vertex coordinates.
map_geom_from_image(fname[, scale, …]) Append surface vertices proportional to image color component values.
map_geom_from_datagrid(datagrid[, scale, …]) Append surface vertices proportional to 2D datagrid surface.
map_geom_from_svd(data[, pc]) Transform surface geometry based on a PCA analysis of a data set.

Color Properties/Methods

cname Descriptive identifier for values indicated by color.
facecolors A N x 4 array of surface face colors.
vlim Range of values associated with color

The following methods will return the calling object (self).
map_color_from_op(operation[, rgb, cname]) Assignment of face color from a function.
map_color_from_image(fname[, viewport]) Assign image color values to surface face colors.
map_cmap_from_op([operation, cmap, cname]) Functional assignment of a color from a color map.
map_cmap_from_datagrid(datagrid[, cmap, …]) Face color assignment using a 2D datagrid surface.
map_cmap_from_normals([cmap, direction, …]) Face color assignment using normals relative to a direction.

Object Creation Methods

__add__(othr) Combine two surface objects into a single surface object.
contourLines(*dist, **kargs) ColorLine3DCollection contour lines on the surface.
contourLineSet([numb]) ColorLine3DCollection of evenly spaced contour lines on the surface.
dispfield_from_op(operation, **kargs) Vector3DCollection of displacement of vertices to a different position.
vectorfield_from_op(operation, **kargs) Vector3DCollection of vectors in u,v,w coordinates at surface vertices.
vectorfield_to_surface(surface, **kargs) Vector3DCollection of vectors from surface to surface vertex coordinates.

Matplotlib 3D Visualization Properties/Methods

The following are used prior to adding the object to the Matplotlib 3D axis.

cBar_ScalarMappable matplotlib.cm.ScalarMappable object for surface values.
set_surface_alpha(alpha[, constant, adjustlw]) Adjust the face color alpha values and linewidth of the surface.
shade([depth, direction, contrast, isAbs, …]) Reduce surface HSV color Value based on face normals.
hilite([height, direction, focus, ax, rview]) Increase surface HSV color Value and reduce Saturation, based on face normals.
fade([depth, elev, azim, ax]) Reduce surface face opacity based on face position relative to the view orientation.

Code Documentation

class s3dlib.surface.Surface3DCollection(vertexCoor, faceIndices, name=None, vcolor=None, **kwargs)[source]

Bases: mpl_toolkits.mplot3d.art3d.Poly3DCollection

Base class for 3D surfaces.

3D surface of connected F faces, each face with N number of vertices. The surface has V number of vertices and E number of edges.

Parameters:
  • vertexCoor (V x 3 float array-like) – An array of V number of xyz vertex coordinates.
  • faceIndices (F x N int list or array) – A list or array of F number of faces with N vertex indices. For lists, N may be different for each face.
  • name (string, optional, default: None.) – Descriptive identifier for the geometry.
  • vcolor (V x 3 float array-like, default: None.) – An array of V number of vertex colors. (not implemented, reserved for future development)
Other Parameters:
 

**kwargs – All other arguments are passed on to mpl_toolkits.mplot3d.art3d.Poly3DCollection. Valid argument names include: color, edgecolors, facecolors, linewidths, cmap.

__add__(othr)[source]

Combine two surface objects into a single surface object.

Parameters:othr (Surface3DCollection object) –
Returns:Surface3DCollection object
area_h2b

A 2 x N array of normalized N face areas and shapes.

bounds

Dictionary of surface geometric and value ranges.

Each dictionary value is a 2 float array of minimum and maximum values of the surface. Keys are:

‘xlim’ : x-coordinate

‘ylim’ : y-coordinate

‘zlim’ : z-coordinate

‘r_xy’ : radial distance from the z axis

‘rorg’ : radial distance from the origin

‘vlim’ : value functional assignments.

Values are assigned from the geometry and color mapping methods, including clipping.

cBar_ScalarMappable

matplotlib.cm.ScalarMappable object for surface values.

static chull(points, **kargs)[source]

Surface3DCollection Convex Hull for a set of 3D points.

Parameters:points (N x 3 float array-like) –
Returns:Surface3DCollection object
clip(operation, usexyz=False)[source]

Remove faces from the surface based on position.

Parameters:
  • operation (function object) – Function that takes one argument, a 3xN Numpy array of coordinates. The function returns a bool { True, False } indicating if the face, at the face centered coordinate, is to be retained (True), otherwise, the face is removed from the surface (False).
  • usexyz (bool { True, False }, default: False) – If True, face centers are passed to the operation function in xyz coordinates. If False, face centers are passed in native coordinates.
Returns:

self (surface object)

clip_alpha(alphaCut, useval=False)[source]

Remove faces from the surface based on alpha transparency.

Parameters:
  • alphaCut (scalar) – If the face color alpha is greater than alphaCut, the face is retained, otherwise, the face is removed from the surface.
  • useval (bool { True, False }, default: False) – If True, clipping based on color HSV value. Otherwise, clipping is based on the color alpha value.
Returns:

self (surface object)

clip_normals(direction=None)[source]

Remove faces from the surface based on a direction relative to face normals.

Parameters:direction (array-like or 3Daxis, optional, default: (30,-60)) – The vector direction for viewing (elev,azim) or 3Daxis.
Returns:self (surface object)
clip_plane(dist, **kargs)[source]

Remove faces from the surface based on a clip surface.

Parameters:
  • dist (float) – Distance from the origin to the clip surface, along the direction vector.
  • direction (array-like, optional, default: [0,0,1]) – A xyz vector normal to the intersection plane for a planar clip surface or axial direction of a cylinder for a cylindrical clip surface.
  • coor (integer or string indicating the type of clip surface:) – 0, p, P, xyz,planar - planar (default) 1, c, C, cylinder,pplar,cylindrical - cylinder 2, s, S, sphere,spherical - sphere 3, x, X - y-z plane 4, y, Y - x-z plane 5, z, Z - x-y plane
Returns:

self (surface object)

cname

Descriptive identifier for values indicated by color.

contourLineSet(numb=2, **kargs)[source]

ColorLine3DCollection of evenly spaced contour lines on the surface.

Parameters:
  • numb (integer) – Number of contour lines intersecting a surface. Numb value must be getter than zero.
  • direction (array-like, optional, default: [0,0,1]) – A xyz vector normal to the intersection planes for planar contours or axial direction of cylinders for cylindrical contours.
  • name (string identifier (default None)) –
  • color (color (default is the surface colors)) –
  • coor (integer or string indicating the type of contour surface:) – 0, p, P, xyz,planar - planar (default, planar & polar) 1, c, C, cylinder,pplar,cylindrical - cylinder (default, cylindrical) 2, s, S, sphere,spherical - sphere (default, spherical) 3, x, X - y-z plane 4, y, Y - x-z plane 5, z, Z - x-y plane
Returns:

self (line object)

contourLines(*dist, **kargs)[source]

ColorLine3DCollection contour lines on the surface.

Parameters:
  • dist (floats) – Distances from the origin to the surface of intersection, along the direction vector.
  • direction (array-like, optional, default: [0,0,1]) – A xyz vector normal to the intersection planes for planar contours or axial direction of cylinders for cylindrical contours.
  • name (string identifier (default None)) –
  • color (color (default is the surface colors)) –
  • coor (integer or string indicating the type of contour surface:) – 0, p, P, xyz,planar - planar (default, planar & polar) 1, c, C, cylinder,pplar,cylindrical - cylinder (default, cylindrical) 2, s, S, sphere,spherical - sphere (default, spherical) 3, x, X - y-z plane 4, y, Y - x-z plane 5, z, Z - x-y plane
Returns:

self (line object)

static coor_convert(xyz, tocart=False)[source]

Coordinate transformation.

To be overriddden by any subclass not in Cartesian coordinates.

dispfield_from_op(operation, **kargs)[source]

Vector3DCollection of displacement of vertices to a different position.

Parameters:
  • operation (function object) – Function that takes one coordinate argument, a 3xN Numpy array. The function returns a 3xN array of vectors.
  • returnxyz (bool { True, False }, optional, default: False) – By default, native coordinates are returned by the operation function. If set True, the operation returns xyz Cartesian coordinates.
  • useBase (bool { True, False }, optional, default: False) – When set False, vertices of the surface, prior to any geometric mapping or transforms, are passed to the operation function. Otherwise, when True, the current surface vertices are passed.
  • scale (number, optional, default: 1.) –
  • color (str or float list of length 3 or 4.) – RGB or RGBA color, either a Matplotlib format string or a list of color values in range [0,1].
  • width (number, optional, default: 1) – Line width of the vector.
  • alr (scalar, optional, default: 0.25) – Axis length ratio, head size to vector magnitude.
Returns:

Vector3DCollection object

domain(xlim=None, ylim=None, zlim=None)[source]

Set the domain of the surface.

Used for setting the domain of the base.

Parameters:ylim, zlim (xlim,) – Minimum and maximum values of the arrays are used to scale and translate the surface from an intial domains of [ -1, 1 ] If set to None, the domains are unchanged.
Returns:self (surface object)
edges

ColorLine3DCollection of the surface edges from facecolors.

evert()[source]

Reverse direction of face normals.

facecenters

A 3 x N array of surface face center coordinates.

facecolors

A N x 4 array of surface face colors.

facenormals(**kargs)[source]

Unit directions or Vector3DCollection of face normals at face centers.

Parameters:
  • scale (number, optional) – If not spectified, scaled proportional to the mean edge length of surface base faces.
  • v3d (boolean, optional, default: True) – If True, Vector3DCollection is returned, else a N x 3 array of unit vector face normals is returned if False.
  • color (str or float list of length 3 or 4.) – RGB or RGBA color, either a Matplotlib format string or a list of color values in range [0,1].
  • width (number, optional, default: 1) – Line width of the vector.
  • alr (scalar, optional, default: 0.25) – Axis length ratio, head size to vector magnitude.
Returns:

Vector3DCollection object or array of unit direction vectors

fade(depth=0, elev=None, azim=None, ax=None)[source]

Reduce surface face opacity based on face position relative to the view orientation.

Parameters:
  • depth (scalar, optional, default: 0) – Minimum opacity to 1 for face opacity from back to front face center position. Depth value ranges from 0 to 1.
  • elev (scalar, optional, default: 30) – Elevation of the axes view.
  • azim (scalar, optional, default: -60) – Azimuth of the axes view.
  • ax (Matplotlib 3D axes.) – If not None, elev and azim are taken from the ax.
Returns:

self (surface object)

get_transformAxis(**kargs)[source]

Line3DCollection of the ‘last’ transformed surface coordinate axis.

Parameters:
  • lenmult (scalar or 3D array, optional, default: 1) – Scalar multiplier of the three coordinate axis.
  • width (scalar, optional, default: 1.5) – Line width of the coordinate axis.
  • color (a Color or 3D array of Colors, optional, default: ['r','g','b']) –
  • negaxis (boolean, optional, default: False) – If True, include the negative axis, otherwise axis start at origin.
Returns:

Line3DCollection object

hilite(height=1, direction=None, focus=None, ax=None, rview=False)[source]

Increase surface HSV color Value and reduce Saturation, based on face normals.

The dot product of face normals with the illumination direction is used to adjust face HSV color value and saturation. Faces having normals with a negative component in the direction of illumination are not affected. The reduction of color saturation is proportional to the increase in color value.

Parameters:
  • height (scalar, optional, default: 1) – Maximum color value of highlighted surface faces. Height value ranges from 0 to 1.
  • direction (array-like, optional, default: (1,0,1)) – A xyz vector pointing to the illumination source.
  • focus (scalar, optional, default: 1) – Highlighting focus adjustment from low to high with a value of 1 for quadratic variations with the normal direction. Focus value ranges from 0.1 to 3.
  • ax (Matplotlib 3D axes.) –
  • rview (boolean, default: False) –
    If True, direction is relative to the view,
    otherwise, relative to the axes.
Returns:

self (surface object)

static implsurf(operation, drez=2.0, domain=1, name=None, **kwargs)[source]

Surface3DCollection defined by an implicit function f(x,y,z) = 0.

Parameters:
  • operation (function object) – Implicit function that takes one argument, a 3xN Numpy array of x,y,z coordinates. The function returns a single scalar value. The value of zero defines the implicit surface.
  • drez (Float, optional, default: 2.0) – Multiplier for the number of subdivisions within the domain. Frez values range from 1 to 10. Function evaluation will be the order of frez cubed.
  • domain (a number, list or array, default: 1) – The domain of the function evaluation. For a number, n, the x,y,z axes domains will be [-n,n]. For a 1-dimensional 2-element list, [a,b] will be assigned the domain for all 3 axes. Using a list of list (array), as [ [a,b],[c,d],[e,f] ], the domain is assigned individually for each of the three coordinate axes.
Returns:

Surface3DCollection object

initedges

ColorLine3DCollection of the initial surface edges. ONLY available for surfaces where the number of face edges differ among faces.

map_cmap_from_datagrid(datagrid, cmap=None, viewport=None, cname=None)[source]

Face color assignment using a 2D datagrid surface.

Datagrid values are normalized in the range 0 to 1.

This method is not available for composite surfaces. The entire datagrid domain is applied to the geometric operation.

Parameters:
  • datagrid (2D float array) –
  • cmap (str or Colormap, optional) – A Colormap instance or registered colormap name. If not assigned, the surface Colormap is used. The colormap maps the datagrid values to colors.
  • viewport (4D array-like, optional, default: None) – Viewport defines the subdomain of the surface onto which the datagrid is mapped. The subdomain is set by normalized native surface coordinates in a 4D array. The entire surface is colored for the default of None.
  • cname (string, optional, default: None.) – Descriptive identifier for values indicated by color.
Returns:

self (surface object)

map_cmap_from_normals(cmap=None, direction=None, cname=None, isAbs=False)[source]

Face color assignment using normals relative to a direction.

The dot product of face normals with the direction is used to assign face colors from a colormap.

Parameters:
  • cmap (str or Colormap, optional) – A Colormap instance or registered colormap name. If not assigned, the surface Colormap is used. The colormap maps the dot product values to colors.
  • direction (list of size 3, optional, default: [1,0,1]) – A 3D vector in xyz Cartesian coordinates designating the direction of the illumination source. If assigned the Axes3D, will use the view direction.
  • cname (string, optional, default: None.) – Descriptive identifier for values indicated by color.
  • isAbs (boolean, optional, default: False) – If set True, the absolute value of the dot product between face normals and illumination direction is used.
Returns:

self (surface object)

map_cmap_from_op(operation=None, cmap=None, cname=None)[source]

Functional assignment of a color from a color map.

Face coordinates are used to calculate a scalar which is then used to assign face colors from a colormap.

Parameters:
  • operation (function object, default : None) – Function that takes one argument, a 3xN Numpy array of native coordinates. The function returns a Numpy array of scalar values. If function is None, function will map in the z-direction or r-direction, dependent on the native coordinates.
  • cmap (str or Colormap, optional) – A Colormap instance or registered colormap name. If not assigned, the surface Colormap is used. The colormap maps the function return values to colors.
  • cname (string, optional, default: None or op function name.) – Descriptive identifier for values indicated by color.
Returns:

self (surface object)

map_color_from_image(fname, viewport=None)[source]

Assign image color values to surface face colors.

This method is not available for composite surfaces. The entire image domain is applied to the coloring operation.

Parameters:
  • fname (str or file-like) – The image file to read: a filename, a URL or a file-like object opened in read-binary mode. Currently restricted to PNG format.
  • viewport (4D array-like, optional, default: None) – Viewport defines the subdomain of the surface onto which the image is mapped. The subdomain is set by normalized native surface coordinates in a 4D array. The entire surface is colored for the default of None.
Returns:

self (surface object)

map_color_from_op(operation, rgb=True, cname=None)[source]

Assignment of face color from a function.

Face colors are assigned from a function of face coordinates.

Parameters:
  • operation (function object) – Function that takes one argument, a 3xN Numpy array of native coordinates. The function returns a 3xN color value.
  • rgb (bool {True, False}, optional, default: True) – By default, RGB color values are returned by the operation function. If set False, the operation returns HSV color values.
  • cname (string, optional, default: None or op function name.) – Descriptive identifier for values indicated by color.
Returns:

self (surface object)

map_geom_from_datagrid(datagrid, scale=1.0, viewport=None, name=None)[source]

Append surface vertices proportional to 2D datagrid surface.

Datagrid values are normalized in the range 0 to 1.

This method is not available for composite surfaces. The entire datagrid domain is applied to the geometric operation.

Parameters:
  • datagrid (2D array) –
  • scale (number, optional, default: 1) –
  • viewport (4D array-like, optional, default: None) – Viewport defines the subdomain of the surface onto which the datagrid is mapped. The subdomain is set by normalized native surface coordinates in a 4D array. The entire surface is geometrically mapped for the default of None.
  • name (string, optional, default: None) – Descriptive identifier for the geometry.
Returns:

self (surface object)

map_geom_from_image(fname, scale=1.0, viewport=None, cref='v', hzero=0, name=None)[source]

Append surface vertices proportional to image color component values.

For planar and polar coordinates, the z-coordinate is appended. For cylindrical and spherical coordinates, the r-coordinate is appended.

This method is not available for composite surfaces. The entire image domain is applied to the geometric operation.

Parameters:
  • fname (str or file-like) – The image file to read: a filename, a URL or a file-like object opened in read-binary mode. Currently restricted to PNG format.
  • scale (number) –
  • cref ({'r','g','b','h','s','v'}, optional, default: 'v') – Sets which color tuple value to use for geometry mapping. Note: only the first character of the string is evaluated.
  • hzero (number or None, optional, default: 0) – Argument is used if cref is set to ‘h’. The hzero magnitude indicates the Hue value for a zero coordinate diplacement. The hzero sign (positive or negative), indicates the direction of increasing value in the appended coordinate with hue value. Range of hzero is [-1,1].
  • viewport (4D array-like, optional, default: None) – Viewport defines the subdomain of the surface onto which the image is mapped. The subdomain is set by normalized native surface coordinates in a 4D array. The entire surface is geometrically mapped for the default of None.
  • name (string, optional, default: None) – Descriptive identifier for the geometry.
Returns:

self (surface object)

map_geom_from_op(operation, returnxyz=False, name=None)[source]

Functional transformation of surface vertex coordinates.

This method is not available for composite surfaces.

Parameters:
  • operation (function object) – Coordinate mapping function that takes one argument, a 3xN Numpy array of native coordinates. The function returns a 3xN array of coordinates.
  • returnxyz (bool { True, False }, optional, default: False) – By default, native coordinates are returned by the operation function. If set True, the operation returns xyz Cartesian coordinates.
  • name (string, optional, default: None or op function name.) – Descriptive identifier for the geometry.
Returns:

self (surface object)

map_geom_from_svd(data, pc=None)[source]

Transform surface geometry based on a PCA analysis of a data set. Result values contained in the surface property svd_dict.

Parameters:
  • data (N x 3 array of x,y,z data coordinates.) –
  • pc (scalar, optional, default: None) – Sets the minimum size of the surface based on the relative number of data. Value range from 0 to 1, with 1 for 100%. If None, one standard deviation of the data sets the surface size.
Returns:

self (surface object)

name

Descriptive identifier for the surface geometry.

normalize_scale()[source]

Scaling normalization array and reciprocal.

static rectangulateBase(rez, baseVcoor, baseFaceVertexIndices, midVectFunc)[source]

Recursively subdivide quadrilaterals.

Each recursion subdivides each quadrilateral by four.

Parameters:
  • rez (integer, optional, default: 0) – Number of recursive subdivisions of the rectangle base faces. Rez values range from 0 to 7.
  • baseVcoor (V x 3 float array) – An array of ‘v’ number of xyz vertex coordinates.
  • baseFaceVertextIndices (F x 4 int array) – An array of ‘F’ number of face vertex indices.
  • midVectFunc (function object) – A function that takes two xyz coordinate (list of 4) representing a surface face edge. Returns one xyz coordinate at the bisection of the edge, mapped on the surface.
Returns:

  • indexObj (a dictionary of vertex indices, for a surface) – of F faces, E edges and V vertices. ‘face’ : F x 4 int array ‘edge’ : E x 2 int array
  • vertCoor (V x 3 float array) – An array of V number of xyz vertex coordinates.

set_surface_alpha(alpha, constant=False, adjustlw=True)[source]

Adjust the face color alpha values and linewidth of the surface.

Parameters:
  • alpha (scalar) – Alpha is in the range 0 to 1.
  • constant (bool { True, False }, optional, False) – If False, face color values are multiplied by alpha. If True, all face colors alpha channels are assigned to alpha.
  • adjustlw (bool { True, False }, optional, True) – If True, the surface linewidth will be set to make the edges visually transparent with the faces for Matplotlib rendering.
Returns:

self (surface object)

shade(depth=0, direction=None, contrast=None, isAbs=False, ax=None, rview=False)[source]

Reduce surface HSV color Value based on face normals.

The dot product of face normals with the illumination direction is used to adjust face HSV color value.

Parameters:
  • depth (scalar, optional, default: 0) – Minimum color value of shaded surface faces. Depth value ranges from 0 to 1.
  • direction (array-like, optional, default: (1,0,1)) – A xyz vector pointing to the illumination source.
  • contrast (scalar, optional, default: 1) – Shading contrast adjustment from low to high with a value of 1 for linear variations with the normal direction. Contrast value ranges from 0.1 to 3.
  • isAbs (bool, optional, default: False) – If True, the absolute value of the dot product is is used to determine color value.
  • ax (Matplotlib 3D axes.) –
  • rview (boolean, default: False) –
    If True, direction is relative to the view,
    otherwise, relative to the axes.
Returns:

self (surface object)

svd_dict

A dictionary of results from a Singular Value Decomposition of the data.

Keys are:

‘disarr’ : array of N floats, normalized to the surface size.

‘sigma’ : standard deviation

‘trans’ : [rotation matrix, scaling, translation]

Values are assigned using the map_geom_from_svd method. The dictionary is None if the method has not been called by the surface object.

transform(rotate=None, scale=1.0, translate=[0, 0, 0])[source]

Linear transformation of the surface object.

Parameters:
  • rotate (array-like, optional, default: None) – A 3 by 3 rotation matrix.
  • scale (3D array or scalar, optional, default: 1.0) – Multipliers of the object coordinates, in xyz coordinates. If a single scalar, three multipliers are the same value.
  • translate (array-like, optional, default: [0,0,0]) – A xyz translation vector of object origin.
Returns:

self (surface object)

triangulate(rez=0)[source]

PLANAR subdivision of each face into triangular faces.

Parameters:rez (integer, optional, default: 0) – Number of recursive subdivisions of the base faces into triangular faces, four faces per rez. Rez values range from 0 to 7. For surfaces with 4 vertices per face, each face is first subdivided into two faces, then recursion proceeds. For surfaces with 5 vertices per face, each face is first subdivided into three faces, then recursion proceeds.
Returns:self (surface object)
static triangulateBase(rez, baseVcoor, baseFaceVertexIndices, midVectFunc)[source]

Recursively subdivide triangles.

Each recursion subdivides each triangle by four.

Parameters:
  • rez (integer, optional, default: 0) – Number of recursive subdivisions of the triangulated base faces. Rez values range from 0 to 7.
  • baseVcoor (V x 3 float array) – An array of ‘v’ number of xyz vertex coordinates.
  • baseFaceVertextIndices (F x 3 int array) – An array of ‘F’ number of face vertex indices.
  • midVectFunc (function object) – A function that takes two xyz coordinate (list of 3) representing a surface face edge. Returns one xyz coordinate at the bisection of the edge, mapped on the surface.
Returns:

  • indexObj (a dictionary of vertex indices, for a surface) – of F faces, E edges and V vertices. ‘face’ : F x 3 int array ‘edge’ : E x 2 int array
  • vertCoor (V x 3 float array) – An array of V number of xyz vertex coordinates.

vectorfield_from_op(operation, **kargs)[source]

Vector3DCollection of vectors in u,v,w coordinates at surface vertices.

Parameters:
  • operation (function object) – Function that takes one coordinate argument, a 3xN Numpy array of native coordinates. The function returns a 3xN array of vectors.
  • scale (number, optional, default: 1.) –
  • color (str or float list of length 3 or 4.) – RGB or RGBA color, either a Matplotlib format string or a list of color values in range [0,1].
  • width (number, optional, default: 1) – Line width of the vector.
  • alr (scalar, optional, default: 0.25) – Axis length ratio, head size to vector magnitude.
Returns:

Vector3DCollection object

vectorfield_to_surface(surface, **kargs)[source]

Vector3DCollection of vectors from surface to surface vertex coordinates.

Parameters:
  • surface (surface object) – Surface that matches the calling surface vectors. Should be the same basetype and rez for surface subclasses.
  • scale (number, optional, default: 1.) –
  • color (str or float list of length 3 or 4.) – RGB or RGBA color, either a Matplotlib format string or a list of color values in range [0,1].
  • width (number, optional, default: 1) – Line width of the vector.
  • alr (scalar, optional, default: 0.25) – Axis length ratio, head size to vector magnitude.
Raises:

ValueError – Mismatched surfaces based on the number of vertices.

Returns:

Vector3DCollection object

vertexnormals(**kargs)[source]

Unit directions or Vector3DCollection of vertex normals at vertices.

Parameters:
  • scale (number, optional) – If not spectified, scaled proportional to the mean edge length of surface base faces.
  • v3d (boolean, optional, default: True) – If True, Vector3DCollection is returned, else a N x 3 array of unit vector vertex normals is returned if False.
  • color (str or float list of length 3 or 4.) – RGB or RGBA color, either a Matplotlib format string or a list of color values in range [0,1].
  • width (number, optional, default: 1) – Line width of the vector.
  • alr (scalar, optional, default: 0.25) – Axis length ratio, head size to vector magnitude.
Returns:

Vector3DCollection object or array of unit direction vectors

vertices

A 3 x N array of surface vertices.

vlim

Range of values associated with color