gavo.utils.mathtricks module¶
Math-related helper functions.
-
class
gavo.utils.mathtricks.
Matrix3
(row1, row2, row3)[source]¶ Bases:
object
A quick and easy 3d matrix.
This is just so we don’t depend on numpy for trivial stuff. The components are stored in a tuple of rows.
-
indices
= [0, 1, 2]¶
-
-
gavo.utils.mathtricks.
cartToSpher
(unitvector)[source]¶ 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.
-
gavo.utils.mathtricks.
findMinimum
(f, left, right, minInterval=3e-08)[source]¶ 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.
-
class
gavo.utils.mathtricks.
getHexToBin
(arg)[source]¶ Bases:
gavo.utils.codetricks.CachedResource
returns a dictionary mapping hex chars to their binary expansions.
-
gavo.utils.mathtricks.
getRotX
(angle)[source]¶ returns a 3-rotation matrix for rotating angle radians around x.
-
gavo.utils.mathtricks.
getRotZ
(angle)[source]¶ returns a 3-rotation matrix for rotating angle radians around z.
-
gavo.utils.mathtricks.
roundO2M
(num)[source]¶ returns a plausible rounding of num.
This will round up the last couple of digits. For now, this will only do cardinals. >>> roundO2M(0) 0 >>> roundO2M(2.5) 2 >>> roundO2M(15) 20 >>> roundO2M(9900) 10000 >>> roundO2M(8321) 8400 >>> roundO2M(3.2349302e9) 3300000000
-
gavo.utils.mathtricks.
spherDist
(vec1, vec2)[source]¶ returns the spherical distance (in radian) between the unit vectors vec1 and vec2.