dipy logo

Site Navigation

NIPY Community

Previous topic

dipy.core.rng

dipy.core.sphere

class dipy.core.sphere.Sphere(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None)

Points on the unit sphere.

The sphere can be constructed using one of three conventions:

Sphere(x, y, z)
Sphere(xyz=xyz)
Sphere(theta=theta, phi=phi)
Parameters :

x, y, z : 1-D array_like

Vertices as x-y-z coordinates.

theta, phi : 1-D array_like

Vertices as spherical coordinates. Theta and phi are the inclination and azimuth angles respectively.

xyz : (N, 3) ndarray

Vertices as x-y-z coordinates.

faces : (N, 3) ndarray

Indices into vertices that form triangular faces. If unspecified, the faces are computed using a Delaunay triangulation.

edges : (N, 2) ndarray

Edges between vertices. If unspecified, the edges are derived from the faces.

Methods

edges
faces
subdivide
vertices
subdivide(n=1)

Subdivides each face of the sphere into four new faces.

New vertices are created at a, b, and c. Then each face [x, y, z] is divided into faces [x, a, c], [y, a, b], [z, b, c], and [a, b, c].

   y
   /               /               a/____
/\    /            /  \  /             /____\/____          x      c     z
Parameters :

n : int, optional

The number of subdivisions to preform.

Returns :

new_sphere : Sphere

The subdivided sphere.

class dipy.core.sphere.HemiSphere(x=None, y=None, z=None, theta=None, phi=None, xyz=None, faces=None, edges=None, tol=1e-05)

Points on the unit sphere.

A HemiSphere is similar to a Sphere but it takes antipodal symmetry into account. Antipodal symmetry means that point v on a HemiSphere is the same as the point -v. Duplicate points are discarded when constructing a HemiSphere (including antipodal duplicates). edges and faces are remapped to the remaining points as closely as possible.

The HemiSphere can be constructed using one of three conventions:

HemiSphere(x, y, z)
HemiSphere(xyz=xyz)
HemiSphere(theta=theta, phi=phi)
Parameters :

x, y, z : 1-D array_like

Vertices as x-y-z coordinates.

theta, phi : 1-D array_like

Vertices as spherical coordinates. Theta and phi are the inclination and azimuth angles respectively.

xyz : (N, 3) ndarray

Vertices as x-y-z coordinates.

faces : (N, 3) ndarray

Indices into vertices that form triangular faces. If unspecified, the faces are computed using a Delaunay triangulation.

edges : (N, 2) ndarray

Edges between vertices. If unspecified, the edges are derived from the faces.

tol : float

Angle in degrees. Vertices that are less than tol degrees apart are treated as duplicates.

See also

Sphere

Methods

edges
faces
from_sphere
mirror
subdivide
vertices
classmethod from_sphere(klass, sphere, tol=1e-05)

Create instance from a Sphere

mirror()

Create a full Sphere from a HemiSphere

subdivide(n=1)

Create a more subdivided HemiSphere

See Sphere.subdivide for full documentation.

dipy.core.sphere.faces_from_sphere_vertices(vertices)

Triangulate a set of vertices on the sphere.

Parameters :

vertices : (M, 3) ndarray

XYZ coordinates of vertices on the sphere.

Returns :

faces : (N, 3) ndarray

Indices into vertices; forms triangular faces.

dipy.core.sphere.unique_edges(faces, return_mapping=False)

Extract all unique edges from given triangular faces.

Parameters :

faces : (N, 3) ndarray

Vertex indices forming triangular faces.

return_mapping : bool

If true, a mapping to the edges of each face is returned.

Returns :

edges : (N, 2) ndarray

Unique edges.

mapping : (N, 3)

For each face, [x, y, z], a mapping to it’s edges [a, b, c].

   y
   /               /               a/    
/                  /                   /__________          x      c     z