pymchelper.flair.common.bmath module¶
-
class
pymchelper.flair.common.bmath.
Matrix
(rows=4, cols=-1, type=0)[source]¶ Bases:
list
Matrix 4x4 used for vector transformations
-
O
= [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]¶
-
U
= [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]¶
-
determinant
(eps=1e-15)¶ determinant of square matrix using Gauss method
-
inverse
()¶ Inverse matrix in place
-
rotate
(angle, axis)[source]¶ Add rotation elements to the matrix around one axis Axis X=0, Y=1, Z=2, or an arbitrary one given by vector axis
-
static
translate
(x, y=0.0, z=0.0)[source]¶ m = Matrix.translate(x,y,z|vector) @return a translation matrix
-
transpose
()¶ @return transpose matrix
-
-
class
pymchelper.flair.common.bmath.
Quaternion
(a, b=None, c=None, d=None)[source]¶ Bases:
list
-
normalize
()¶ normalize quaternion
-
-
class
pymchelper.flair.common.bmath.
Vector
(x=3, *args)[source]¶ Bases:
list
Vector class
-
O
= [0, 0, 0]¶
-
X
= [1, 0, 0]¶
-
Y
= [0, 1, 0]¶
-
Z
= [0, 0, 1]¶
-
normalize
()¶ Normalize vector and return length
-
-
pymchelper.flair.common.bmath.
eigenvalues
(M, eps=1e-15, check=False)[source]¶ Return eigen values and eigen vectors of a symmetric matrix
-
pymchelper.flair.common.bmath.
format_number
(number, length=10, useExp=False, useD=False)[source]¶ Format a number to fit in the minimum space given by length
-
pymchelper.flair.common.bmath.
frange
(start, stop, step)[source]¶ range(start,stop,step) for floating point numbers
-
pymchelper.flair.common.bmath.
limit
(min_, num, max_)[source]¶ limit a number within a specific range :param min_: :param num: :param max_: :return:
-
pymchelper.flair.common.bmath.
linear
(X, Y)[source]¶ Solve linear regression y = ax + b @return a,b,r
-
pymchelper.flair.common.bmath.
polar
(x, y, deg=False)[source]¶ - Convert from rectangular (x,y) to polar (r,w)
- r = sqrt(x^2 + y^2) w = arctan(y/x) = [-pi,pi] = [-180,180]
-
pymchelper.flair.common.bmath.
polyderiv
(a)[source]¶ - p’(x) = polyderiv(a)
- = b[0] + b[1]x + b[2]x^2 +…+ b[n-2]x^{n-2} + b[n-1]x^{n-1}
where b[i] = (i+1)a[i+1]
-
pymchelper.flair.common.bmath.
polyeval
(a, x)[source]¶ - p(x) = polyeval(a, x)
- = a[0] + a[1]x + a[2]x^2 +…+ a[n-1]x^{n-1} + a[n]x^n = a[0] + x(a[1] + x(a[2] +…+ x(a[n-1] + a[n]x)…)
-
pymchelper.flair.common.bmath.
polyreduce
(a, root)[source]¶ Given x = r is a root of n’th degree polynomial p(x) = (x-r)q(x), divide p(x) by linear factor (x-r) using the same algorithm as polynomial evaluation. Then, return the (n-1)’th degree quotient q(x) = polyreduce(a, r)
= c[0] + c[1]x + c[2]x^2 +…+ c[n-2]x^{n-2} + c[n-1]x^{n-1}
-
pymchelper.flair.common.bmath.
rect
(r, w, deg=False)[source]¶ - Convert from polar (r,w) to rectangular (x,y)
- x = r cos(w) y = r sin(w)