Package gavo :: Package utils :: Module mathtricks
[frames] | no frames]

Module mathtricks

source code

Math-related helper functions.

Classes
  getHexToBin
returns a dictionary mapping hex chars to their binary expansions.
  Matrix3
A quick and easy 3d matrix.
Functions
 
findMinimum(f, left, right, minInterval=3e-08)
returns an estimate for the minimum of the single-argument function f on (left,right).
source code
 
toBinary(anInt, desiredLength=None)
returns anInt as a string with its binary digits, MSB first.
source code
 
getRotX(angle)
returns a 3-rotation matrix for rotating angle radians around x.
source code
 
getRotZ(angle)
returns a 3-rotation matrix for rotating angle radians around z.
source code
 
spherToCart(theta, phi)
returns a 3-cartesian unit vector pointing to longitude theta, latitude phi.
source code
 
cartToSpher(unitvector)
returns spherical coordinates for a 3-unit vector.
source code
 
spherDist(vec1, vec2)
returns the spherical distance (in radian) between the unit vectors vec1 and vec2.
source code
Variables
  DEG = 0.0174532925199
  ARCSEC = 4.8481368111e-06
  __package__ = 'gavo.utils'
Function Details

findMinimum(f, left, right, minInterval=3e-08)

source code 

returns an estimate for the minimum of the single-argument function f on (left,right).

minInterval is a fourth of the smallest test interval considered.

For constant functions, a value close to left will be returned.

This function should only be used on functions having exactly one minimum in the interval.

toBinary(anInt, desiredLength=None)

source code 

returns anInt as a string with its binary digits, MSB first.

If desiredLength is given and the binary expansion is shorter, the value will be padded with zeros.

>>> toBinary(349)
'101011101'
>>> toBinary(349, 10)
'0101011101'

spherToCart(theta, phi)

source code 

returns a 3-cartesian unit vector pointing to longitude theta, latitude phi.

The angles are in rad.

cartToSpher(unitvector)

source code 

returns spherical coordinates for a 3-unit vector.

We do not check if unitvector actually *is* a unit vector. The returned angles are in rad.