s3dlib.surface.SphericalSurface

class s3dlib.surface.SphericalSurface(rez=0, basetype=None, minrad=None, name=None, **kwargs)[source]

Bases: s3dlib.surface.Surface3DCollection

Spherical 3D surface in spherical coordinates.

Methods are inherited from the Surface3DCollection. Spherical surface geometries are created in this subclass.

Create spherical surface of unit radius.

Parameters:
  • rez (integer, optional, default: 0) – Number of recursive subdivisions of the triangulated base faces. Rez values range from 0 to 7.
  • basetype ({'tetra','octa','icosa','cube','dodeca', 'octa_s','cube_s','octa_c','cube_c'}, optional, default: 'icosa') – Starting surface geometries from which the surface is constructed using recursive subdivisions of the triangular faces. All basetypes are based on the five platonic solids.
  • minrad (scalar, optional, default: 0.01) – For basetypes ‘octa_c’ and ‘cube_c, the minimum distance from the z-axis of any vertex coordinate.
  • name (string, optional, default: None.) – Descriptive identifier for the geometry.
Raises:

ValueError – If rez is not an integer in range 0 to 7. If basetype is not recognized for this surface constructor.

Other Parameters:
 

**kwargs – All other parameters are passed on to ‘s3dlib.surface.Surface3DCollection’.

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

Transformation between spherical and Cartesian coordinates. The azimuthal coordinate is in radians with domain 0 to 2pi. The polar angle is in radians with domain 0 to pi.

Parameters:
  • xyz (3xN array) – N number of vectors in either spherical or cartesian coordinates,
  • tocart ({ True, False }, default: False) – If True, input is spherical and output is cartesian. If False, input is cartesian and output is spherical.
Returns:

list (3xN array) – Transformed coordinates.

domain(radius=None)[source]

Set the domain of the spherical surface.

Used for setting the radius of the base sphere.

Parameters:radius (number, default : 1) – Radius of the spherical surface. If set to None, the radius is unchanged.
Returns:self (SphericalSurface object)
static get_cube()[source]

Numpy arrays of cube vertices (8,3) and face vertex indices 6,5) and edge vertex indices (12,2)

static get_dodecahedron()[source]

Numpy arrays of dodecahedron vertices (20,3) and face vertex indices (12,5) and edge vertex indices (30,2)

classmethod grid(nlat, nlng, basetype='d', minrad=None, name=None, **kwargs)[source]

SphericalSurface with latitude and longitude faces.

Parameters:
  • nlat (integer, required.) – Number of latitude subdivisions. Minimum value is 2
  • nlng (integer, required.) – Number of longitude subdivisions. Minimum value is 3.
  • basetype ({'d','s','q','w','r','x'}, optional, default: 'd') – Starting surface geometries from which the surface is constructed indicating face shape and if split.
  • minrad (scalar, optional, default: 0.01) – The minimum distance from the z-axis of any vertex coordinate. Use is dependent on basetype.
  • name (string, optional, default: None.) – Descriptive identifier.
Raises:

ValueError – If nlat is not an integer greater or equal to 2. If nlng is not an integer greater or equal to 3.

Other Parameters:
 

**kwargs – All other parameters are passed on to ‘s3dlib.surface.Surface3DCollection’.

Returns:

surface (SphericalSurface object.)

static platonic(rez=0, basetype=None, name=None, **kwargs)[source]

Platonic Solid surfaces.

Parameters:
  • rez (integer, optional, default: 0) – Number of recursive subdivisions of the triangulated base faces. Rez values range from 0 to 7.
  • basetype ({'tetra','octa','icosa','cube','dodeca'}, optional, default: 'icosa') – Starting surface geometries from which the surface is constructed using recursive subdivisions of the triangular faces.
  • name (string, optional, default: None.) – Descriptive identifier for the geometry.
Returns:

SphericalSurface object

Other Parameters:
 

**kwargs – All other parameters are passed on to ‘s3dlib.surface.SphericalSurface’.

classmethod pntsurf(rtp_points, name=None, **kargs)[source]

SphericalSurface from points in spherical coordinates.

Parameters:
  • rtp_points (array, required.) – An N X 3 array of N spherical coordinate points.
  • name (string, optional, default: None.) – Descriptive identifier for the point surface.
Returns:

surface (SphericalSurface object)

static rand(rez=0, seed=None, name=None, kind=None, **kargs)[source]

SphericalSurface with random triangular faces.

Parameters:
  • rez (number, optional, default: 0) – Number of ‘recursive’ subdivisions of the triangulated base faces. Rez values range from 0 to 7.
  • seed (integer, optional, default: None) – An initialization seed for random generation.
  • name (string, optional, default: None.) – Descriptive identifier for the geometry.
  • kind (string, optional, default: None) – (reserved, not implemented)
Raises:

ValueError – If rez is not an integer in range 0 to 7. If basetype is not recognized for this surface constructor.

Other Parameters:
 

**kwargs – All other parameters are passed on to ‘s3dlib.surface.Surface3DCollection’.

Returns:

surface (SphericalSurface object.)