s3dlib.surface Functions

Contents

Geometry Functions

eulerRot(theta, phi[, psi, useXconv, inrad]) Rotation matrix from Euler angles, X or Y convention.
axisRot(alpha, direction[, inrad]) Rotation matrix from rotation about a directional axis
vectRot(xDirection, in_planeDirection) Rotations matrix from two vectors
density_function(vals[, bins, scale, xbnd, …]) 2D histogram density, Data_density = f(x,y) from a x,y dataset.
frame_to_value(x, *valList, **kargs) Y = f(x) from a collection of linear segment functions f(x)
get_surfgeom_from_obj(file, **kargs) Create surface from obj formatted ‘file’.
save_surfgeom_to_obj(file, surface) Export ‘surface’ geometry to obj formatted file.

Matplotlib 3D Visualization Functions

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

rtv(direction[, elev, azim]) Transform direction vector ‘relative to view’ axis viewing angles.
elev_azim_2vector(elev, azim[, inrad]) Unit vector in the terms of angular position.
auto_scale(axes, *obj3d, **kargs) Scale Axes3d using object bounds.
setupAxis(axes, **kargs) Add XYZ origin coordinate axis Vector3DCollection to the axes.
standardAxis(axes, **kargs) Add XYZ origin coordinate axis Vector3DCollection and set the axis viewing angle, projection type and clear planes.

Code Documentation

s3dlib.surface.eulerRot(theta, phi, psi=0, useXconv=True, inrad=False)[source]

Rotation matrix from Euler angles, X or Y convention.

s3dlib.surface.axisRot(alpha, direction, inrad=False)[source]

Rotation matrix from rotation about a directional axis

s3dlib.surface.vectRot(xDirection, in_planeDirection)[source]

Rotations matrix from two vectors

s3dlib.surface.density_function(vals, bins=(10, 10), scale=True, xbnd=True, ybnd=True, kind='linear')[source]

2D histogram density, Data_density = f(x,y) from a x,y dataset.

Parameters:
  • vals (2 X N array of x,y data values.) –
  • bins ([int,int], the number of bins for each dimension.) –
  • scale (bool or number, default: True) – If True, normalize values to the average. If False, scale is 1, the density value of data per bin area. When numerical, multiplier for the density value.
  • xbnd (bool, default : True) – If True, x values are extended for density of zero. For cyclic mapping, this should be set to False.
  • ybnd (bool, default : True) – If True, y values are extended for density of zero. For cyclic mapping, this should be set to False.
  • kind ({‘linear’, ‘cubic’, ‘quintic’}, default: 'linear') – The kind of spline interpolation to use.
Returns:

A function f(x,y)

s3dlib.surface.frame_to_value(x, *valList, **kargs)[source]

Y = f(x) from a collection of linear segment functions f(x)

Parameters:
  • x (float value between 0 and 1.) –
  • valList (list of values, evenly spaced along x. For multiple lists, all must be the same length.) –
  • stepped (boolean, default is False.) – If True, function evaluate to a constant of the first value between valList values. If False, function is linear between valList values. For True, number of linear segments is the valList length. For False, number of linear segments is one less than valList length.
Returns:

List of values of size valList arguments number.

s3dlib.surface.get_surfgeom_from_obj(file, **kargs)[source]

Create surface from obj formatted ‘file’. kargs passed to instantiate surface in constructor. ‘Proof of concept’ for future versions.

s3dlib.surface.save_surfgeom_to_obj(file, surface)[source]

Export ‘surface’ geometry to obj formatted file. ‘Proof of concept’ for future versions.

s3dlib.surface.rtv(direction, elev=None, azim=None)[source]

Transform direction vector ‘relative to view’ axis viewing angles.

s3dlib.surface.elev_azim_2vector(elev, azim, inrad=False)[source]

Unit vector in the terms of angular position.

s3dlib.surface.auto_scale(axes, *obj3d, **kargs)[source]

Scale Axes3d using object bounds.

Parameters:
  • axes (Matplotlib 3D axes.) –
  • obj3d (positional arguments of s3dlib objects) –
  • uscale (scaling in the range (0.5,2.5)) – if neither uscale or rscale are defined - . Each axes ranges are independently . set by sizes of input objects. if both uscale and rscale are defined - . uscale will be ignored. if defined using an int or float - . Each axes ranges have the same scalar . length, set by the values of the objects. . Out of range values will set the scaling . to the minimum or maximum. else - scaling is one.
  • rscale (scaling in the range (0.5,2.5)) – if neither uscale or rscale are defined - . Each axes ranges are independently . set by sizes of input objects. if both uscale and rscale are defined - . uscale will be ignored. if defined using an int or float - . Each axes ranges have the same minimum . and maximum, set by the values of the . objects radial extent from the origin. . Out of range values will set the scaling . to the maximum. else - scaling is one.
Returns:

axes, which has been scaled

s3dlib.surface.setupAxis(axes, **kargs)[source]

Add XYZ origin coordinate axis Vector3DCollection to the axes.

Parameters:
  • axes (Matplotlib 3D axes object.) –
  • length (coordinate axis length (single or 3-value list), default: 1.5) –
  • color (axis color (single or 3-value list), default: 'black') –
  • offset (axis vector offset from the origin (single or 3-value list), default: 0) –
  • labels (axis label (single or 3-value list), default: ['X','Y','Z']) –
  • pad (label padding from the vector axis head (single or 3-value list), default: 0.15) –
  • width (axis line widths, default: 2) –
  • negaxis (show negative axis line, default: False) –
  • alr (axis length ratio, head size to axis length, default: 0.2) –
Returns:

axes

s3dlib.surface.standardAxis(axes, **kargs)[source]

Add XYZ origin coordinate axis Vector3DCollection and set the axis viewing angle, projection type and clear planes.

Parameters:
  • axes (Matplotlib 3D axes object.) –
  • kargs (identical to those for setupAxis function.) –
Returns:

axes