Package geometry :: Module spheres
[hide private]
[frames] | no frames]

Module spheres

source code

Functions [hide private]
 
any_distant_direction(s)
Returns a direction distant from both *s* and *-s*.
source code
 
any_orthogonal_direction(s)
Returns any axis orthogonal to *s* (not necessarily random).
source code
 
assert_orthogonal(s, v)
Checks that two vectors are orthogonal.
source code
 
default_axis()
Returns the axis to use when any will do.
source code
 
default_axis_orthogonal()
Returns an axis orthogonal to the one returned by :py:func:`default_axis`.
source code
 
directions(X)
Checks that every column has unit length.
source code
 
distances_from(S, s)
Returns the geodesic distances on the sphere from a set of points *S* to a given point *s*.
source code
 
distribution_radius(S)
Returns the radius of the given directions distribution.
source code
 
geodesic_distance_on_sphere(s1, s2)
Returns the geodesic distance between two points on the sphere.
source code
 
normalize_pi(x)
Normalizes the entries in *x* in the interval :math:`[-pi,pi)`.
source code
 
normalize_pi_scalar(x)
:param x: :type x: ``float``
source code
 
project_vectors_onto_sphere(S, atol=1e-07)
:param S: :type S: ``array[KxN],K>=2``
source code
 
random_direction(ndim=3)
Generates a random direction in :math:`\sphere^{\ndim-1}`.
source code
 
random_directions(N, ndim=3)
Returns a set of random directions.
source code
 
random_directions_bounded(ndim, radius, num_points, center=None)
Returns a random distribution of points in :math:`\sphere^{\ndim-1}`.
source code
 
random_orthogonal_direction(s)
Returns a random axis orthogonal to *s* (only implemented for circle and sphere).
source code
 
slerp(s1, s2, t)
Spherical interpolation between two points on a hypersphere.
source code
 
sorted_directions(S, num_around=15)
Rearranges the directions in *S* in a better order for visualization.
source code
 
sphere_area(r=1)
Returns the area of a sphere of the given radius.
source code
 
spherical_cap_area(cap_radius)
Returns the area of a spherical cap on the unit sphere of the given radius.
source code
 
spherical_cap_with_area(cap_area)
Returns the radius of a spherical cap of the given area.
source code
 
unit_length(x)
Checks that the value is a 1D vector with unit length in the 2 norm.
source code
Variables [hide private]
  __package__ = 'geometry'
Function Details [hide private]

any_distant_direction(s)

source code 

Returns a direction distant from both *s* and *-s*.

:param s: :type s: ``direction``

:rtype: ``direction``

any_orthogonal_direction(s)

source code 

Returns any axis orthogonal to *s* (not necessarily random).

:param s: :type s: ``direction``

:rtype: ``direction``

assert_orthogonal(s, v)

source code 

Checks that two vectors are orthogonal.

:param s: :type s: ``array[K],K>=2``

:param v: :type v: ``array[K]``

default_axis()

source code 

       Returns the axis to use when any will do. 
       
       For example, the identity is represented by
       a rotation of 0 degrees around *any* axis. If an *(axis,angle)*
       representation is requested, the axis will be given by
       *default_axis()*. 
   


:rtype:  ``direction``

default_axis_orthogonal()

source code 

       Returns an axis orthogonal to the one returned 
       by :py:func:`default_axis`. 
       
       Use this when you need a couple of arbitrary orthogonal axes.
   


:rtype:  ``direction``

directions(X)

source code 

Checks that every column has unit length.

:param X: :type X: ``array[KxN],K>0,N>0``

distances_from(S, s)

source code 

       Returns the geodesic distances on the sphere from a set of
       points *S* to a given point *s*. 
       
   


:param s: 
:type s:  ``direction``

:param S: 
:type S:  ``array[3xK],directions``

:rtype:  ``array[K](>=0,<=pi)``

distribution_radius(S)

source code 

       Returns the radius of the given directions distribution.
       
       The radius is defined as the minimum *r* such that there exists a 
       point *s* in *S* such that all distances are within *r* from *s*. 
       
       .. math:: \textsf{radius} = \min \{ r | \exists s : 
                 \forall x \in S : d(s,x) <= r \}
   


:param S: 
:type S:  ``directions``

:rtype:  ``float,>=0,<=pi``

geodesic_distance_on_sphere(s1, s2)

source code 

Returns the geodesic distance between two points on the sphere.

:param s2: :type s2: ``array[K],unit_length``

:param s1: :type s1: ``array[K],unit_length``

:rtype: ``float,>=0,<=pi``

normalize_pi(x)

source code 

Normalizes the entries in *x* in the interval :math:`[-pi,pi)`.

:param x: :type x: ``array[N]``

:rtype: ``array[N](>=-pi,<pi)``

normalize_pi_scalar(x)

source code 

:param x: :type x: ``float``

:rtype: ``>=-pi,<pi``

project_vectors_onto_sphere(S, atol=1e-07)

source code 

:param S: :type S: ``array[KxN],K>=2``

:rtype: ``array[KxN]``

random_direction(ndim=3)

source code 

       Generates a random direction in :math:`\sphere^{\ndim-1}`. 
   
       Currently only implemented for 2D and 3D.
   


:param ndim: 
:type ndim:  ``(2|3),K``

:rtype:  ``array[K],unit_length``

random_directions(N, ndim=3)

source code 

Returns a set of random directions.

:param ndim: :type ndim: ``2|3``

:param N: :type N: ``int,>0,N``

:rtype: ``array[3xN]``

random_directions_bounded(ndim, radius, num_points, center=None)

source code 

       Returns a random distribution of points in :math:`\sphere^{\ndim-1}`.
       within a certain radius from the point *center*. 
       
       The points will be distributed uniformly in that area of the sphere.
       If *center* is not passed, it will be a random direction. 
   


:param ndim: 
:type ndim:  ``(2|3),K``

:param num_points: 
:type num_points:  ``int,>0``

:param radius: 
:type radius:  ``number,>0,<=pi``

:param center: 
:type center:  ``None|array[K],unit_length``

:rtype:  ``array[KxN],directions``

random_orthogonal_direction(s)

source code 

       Returns a random axis orthogonal to *s* 
       (only implemented for circle and sphere). 
   


:param s: 
:type s:  ``array[K],unit_length,(K=2|K=3)``

:rtype:  ``array[K],unit_length``

slerp(s1, s2, t)

source code 

Spherical interpolation between two points on a hypersphere.

:param s2: :type s2: ``array[K],unit_length``

:param s1: :type s1: ``array[K],unit_length``

:param t: :type t: ``number,>=0,<=1``

sorted_directions(S, num_around=15)

source code 

       Rearranges the directions in *S* in a better order for visualization.
   
       In 2D, sorts the directions using their angle. 
       
       In 3D, it tries to do a pleasant elicoidal arrangement 
       with **num_around** spires.
       
   


:param S: 
:type S:  ``array[KxN],(K=2|K=3),directions``

:rtype:  ``array[KxN],directions``

spherical_cap_area(cap_radius)

source code 

Returns the area of a spherical cap on the unit sphere of the given radius.

See figure at http://mathworld.wolfram.com/SphericalCap.html

spherical_cap_with_area(cap_area)

source code 

Returns the radius of a spherical cap of the given area.

See http://www.springerlink.com/content/3521h167300g7v62/

unit_length(x)

source code 

Checks that the value is a 1D vector with unit length in the 2 norm.

:param x: :type x: ``array[N],N>0``