biquaternion_py package

Submodules

biquaternion_py.biquaternion module

Calculate with BiQuaternions.

This module implements BiQuaternions as a class for general calculations.

Classes:

BiQuaternion

Misc variables:

II JJ KK EE

class biquaternion_py.biquaternion.BiQuaternion(*args)[source]

Bases: Expr

Class implementing Bi-Quaternions.

Bi-Quaternions are represented as $a + II b + JJ c + KK d + EE (w + II x + JJ y + KK z)$.

coeffs

coefficients of the quaternion as a list in the canonical order.

Type:

list

scal

scalar value of the Bi-Quaternion

Type:

sympy.Expr, numeric

i

II value of the Bi-Quaternion

Type:

sympy.Expr, numeric

j

JJ value of the Bi-Quaternion

Type:

sympy.Expr, numeric

k

KK value of the Bi-Quaternion

Type:

sympy.Expr, numeric

eps

dual scalar value of the Bi-Quaternion

Type:

sympy.Expr, numeric

ei

dual II value of the Bi-Quaternion

Type:

sympy.Expr, numeric

ej

dual JJ value of the Bi-Quaternion

Type:

sympy.Expr, numeric

ek

dual KK value of the Bi-Quaternion

Type:

sympy.Expr, numeric

conjugate[source]

Conjugate of this instance of BiQuaternion.

Type:

BiQuaternion

eps_conjugate[source]

Epsilon conjugation of the biquaternion.

Type:

BiQuaternion

quadrance[source]

Quadrance of a quaternion.

Type:

BiQuaternion

inv[source]

Inverse of the biquaternion.

Type:

BiQuaternion

primal[source]

Primal part of the dual quaternion.

Type:

BiQuaternion

dual[source]

Dual part of the dual quaternion.

Type:

BiQuaternion

scalar_part[source]

Scalar part of the dual quaternion.

Type:

BiQuaternion

vector_part[source]

Vector part of the dual quaternion.

Type:

BiQuaternion

__new__(cls, \*args):

Create new instance of the BiQuaternion class.

__mul__(other):

Multiply BiQuaternion with other.

__pos__(self):

Positive of itsself.

__neg__(self):

Negative of itsself.

__add__(other):

Add BiQuaternion to other.

__sub__(other):

Subtract other from BiQuaternion.

__rsub__(other):

Subtract BiQuaternion from other.

__radd__ = __add__
__rmul__ = __mul__
__eq__(other):

Test equality of two biquaternions.

__hash__ = super.__hash__
__repr__():

Convert BiQuaternion to a readable format in shell.

__str__():

Converst BiQuaternion to string.

__pow__(other):

Power function of BiQuaternion.

__invert__():

(Bi)-Quaternion conjugate of the quaternion.

__truediv__(other):

Division of BiQuaternion by other.

__rtruediv__(other):

Divide other by BiQuaternion.

coeff(var, power):

Rewriting of Expr.coeff to work for BiQuaternions

apply_elementwise(func, *args)[source]

Apply a function with specified arguments elementwise.

Parameters:
  • func (function) – Function to be applied elementwise

  • *args (unknown) – Arguments to be passed to the function

Returns:

Biquaternion with function applied to each coefficient individually.

Return type:

BiQuaternion

coeff(var, power=1, right=False, _first=True)[source]

Rewriting of Expr.coeff to work for BiQuaternions.

property coeffs

Coefficients describing an instance of BiQuaternion.

conjugate()[source]

Conjugate of this instance of BiQuaternion.

Conjugation of a quaternion inverts the sign of the non-scalar part of a (bi-)quaternion. This happens in the same fashion as for complex numbers.

default_assumptions = {'algebraic': False, 'commutative': False, 'complex': False, 'composite': False, 'even': False, 'extended_negative': False, 'extended_nonnegative': False, 'extended_nonpositive': False, 'extended_nonzero': False, 'extended_positive': False, 'extended_real': False, 'imaginary': False, 'integer': False, 'irrational': False, 'negative': False, 'noninteger': False, 'nonnegative': False, 'nonpositive': False, 'nonzero': False, 'odd': False, 'positive': False, 'prime': False, 'rational': False, 'real': False, 'transcendental': False, 'zero': False}
dual()[source]

Dual part of the dual quaternion.

Return type:

BiQuaternion

Notes

The dual part of a dual quaternion is defined as the part only containing factors epsilon.

property ei

Value of the eps*II part of the instance of BiQuaternion.

property ej

Value of the eps*JJ part of the instance of BiQuaternion.

property ek

Value of the eps*KK part of the instance of BiQuaternion.

property eps

Value of the eps part of the instance of BiQuaternion.

eps_conjugate()[source]

Epsilon conjugation of the biquaternion.

Epsilon conjugation inverts the sign of the dual part of a quaternion

property i

Value of the II part of the instance of BiQuaternion.

inv()[source]

Inverse of the biquaternion.

is_algebraic = False
is_commutative: bool | None = False
is_complex = False
is_composite = False
is_even = False
is_extended_negative = False
is_extended_nonnegative = False
is_extended_nonpositive = False
is_extended_nonzero = False
is_extended_positive = False
is_extended_real: bool | None = False
is_imaginary = False
is_integer = False
is_irrational = False
is_negative: bool | None = False
is_noninteger = False
is_nonnegative = False
is_nonpositive = False
is_nonzero = False
is_odd = False
is_positive = False
is_prime = False
is_rational = False
is_real: bool | None = False
is_transcendental = False
is_zero: bool | None = False
property j

Value of the JJ part of the instance of BiQuaternion.

property k

Value of the KK part of the instance of BiQuaternion.

norm()[source]

Extra mapping of quadrance to the term norm, which is commonly used.

primal()[source]

Primal part of the dual quaternion.

Return type:

BiQuaternion

Notes

The primal part of a dual quaternion is defined as the part not containing a factor epsilon.

quadrance()[source]

Quadrance of a quaternion.

The quadrance of a biquaternion is its norm. It is defined as the product of a biquaternion and its conjugate.

property scal

Value of the scalar part of the instance of BiQuaternion.

scalar_part()[source]

Scalar part of the dual quaternion.

Return type:

BiQuaternion

Notes

The scalar part of a dual quaternion is defined as the part only not containing any of the numbers i, j, or k

vector_part()[source]

Vector part of the dual quaternion.

Return type:

BiQuaternion

Notes

The dual part of a dual quaternion is defined as the part only containing the numbers i, j, k.

biquaternion_py.biquaternion.define_algebra(i_square=-1, j_square=-1, e_square=0)[source]

Define the algebra.

Parameters:
  • i_square (float) – value of II**2

  • j_square (float) – value of JJ**2

  • e_square (float) – value of EE**2

Return type:

None

Notes

The algebra of bi-quaternions is fully defined by the following conditions: .. math:: i^2 = a, j^2 = b, e^2 = c,\ ij = k, ji = -k,\ ei = ie, ej = je, ek = ke All objects commute with elements of the chosen base field. Mostly this is \(\mathbb{R}\) or \(\mathbb{C}\).

biquaternion_py.lines module

Module for line creation, representation and manipulation.

biquaternion_py.lines.act_on_line(quaternion, lin)[source]

Let a BiQuaternion act on a line.

biquaternion_py.lines.line_to_pluecker(direction, point)[source]

Generate Pluecker coordinates for a line with given direction through a point.

biquaternion_py.lines.pluecker_to_quat(coord)[source]

Generate BiQuaternion reperesentation of a line with specified Pluecker coordinates.

biquaternion_py.lines.quat_to_pluecker(quat)[source]

Generate pluecker coordinates from a given BiQuaternion.

biquaternion_py.poly_tools module

Extra functions for polynomials.

biquaternion_py.poly_tools.factorize_bq_poly(poly, domain=None)[source]

Factorize Biquaternion polynomial into linear factors.

Parameters:
  • poly (Poly) – Polynomial which to factorize

  • domain (string, optional) – Domain over which to calculate the irreducible factors. (Default None lets sympy decide which domain to use.)

Returns:

  • factors (array of Poly) – Array of linear factors of poly associated to the order of the factors

  • given by irreducible_factors.

biquaternion_py.poly_tools.factorize_from_list(poly, factors)[source]

Factorize polynomial given a list of factors of the norm polynomial.

Parameters:
  • poly (Poly) – Polynomial which to factorize

  • factors (array of Poly) – Array of irreducible factors of the norm polynomial of poly

Returns:

out – Array of linear factors of Poly corresponding to the order of factors

Return type:

array of Poly

biquaternion_py.poly_tools.gcd_conj_pd(poly)[source]

Real gcd of c, primal*dual.conjugate(), primal.conjugate()*dual.

Parameters:
  • poly (Poly) – Polynomial of which to find the gcd of maximal real poly factor of the

  • part (primal) –

  • primal*dual.conjugate()

  • primal.conjugate()*dual

Returns:

gcd

Return type:

Poly

biquaternion_py.poly_tools.irreducible_factors(poly, domain=None)[source]

Calculate the irreducible factors of a polynomial.

Parameters:
  • poly (Poly) – Polynomial of which to calculate the irreducible factors.

  • domain (string, optional) – Domain over which to calculate the irreducible factors. (Default None lets sympy decide which domain to use.)

Returns:

out – List of irreducible factors.

Return type:

array of Poly

Notes

If the irreducible factors are not calculated correctly this might be an issue of sympy assuming to much about the domain. Chaning this to “QQ” or “RR”

biquaternion_py.poly_tools.is_poly_reduced(poly)[source]

Check if polynomial is reduced.

Parameters:

poly (Poly) – Polynomial which to check for reducedness.

Returns:

True if the polynomial is reduced.

Return type:

bool

Notes

A polynomial is called reduced, if the primal and dual part have no common real factor. [1]

[1]

Z. Li, J. Schicho, H.-P. Schröcker, The rational motion of minimal dual quaternion degree with prescribed trajectory, Computer Aided Geometric Design, Volume 41, 2016, Pages 1-9, ISSN 0167-8396, https://doi.org/10.1016/j.cagd.2015.10.002.

biquaternion_py.poly_tools.max_real_poly_fact(poly)[source]

Calculate maximal real polynomial factor of the BiQuaternionpolynomial poly.

Parameters:

poly (Poly) – Polynomial of which to find the maximal real factor.

Returns:

gcd – Maximal real factor of poly

Return type:

Poly

biquaternion_py.poly_tools.split_lin_factor(poly, norm)[source]

Split off linear factor with norm norm from poly.

Parameters:
  • poly (Poly) – Polynomial of which to split of a linear factor

  • norm (Poly) – Norm of the linear factor to split off

Returns:

  • quot (Poly) – Quotient of the polynomial left division of poly by norm

  • lin_fact (Poly) – Linearfactor that was split off corresponding to norm

biquaternion_py.polynomials module

Implementation of polynomial class and associated functions.

class biquaternion_py.polynomials.Poly(*args)[source]

Bases: Expr

Class implementing arbitrary polynomials.

all_coeffs()[source]

Compute all coefficients in ascending order of all variables in given order as nested list.

all_indet_coeffs(indet)[source]

Compute all coefficients with respect to var.

Parameters:

indet (sympy.Symbol) – Variable with respect which to compute all coefficients.

Returns:

List of coefficients for powers of indet in ascending order.

Return type:

list of BiQuaternions

coeff(var, power=1, right=False, _first=True)[source]

Coefficient of polynomial with respect to var**(power).

conjugate()[source]

Returns the complex conjugate of ‘self’.

default_assumptions = {}
deg(var)[source]
dual()[source]
eps_conjugate()[source]
eval(vals, right=True)[source]

Evaluate polynomial for variables set as in val.

Parameters:
  • vals (list) – List of values which the indeterminates should take.

  • right (bool (optional, defaulf = True)) – Should polynomial be evaluated assuming variables are left,

  • coefficients. (or right of) –

Return type:

type(val)

property indets
lcoeff(var)[source]

Leading coefficient of polynomial with respect to var.

norm()[source]
property poly
primal()[source]
terms()[source]
biquaternion_py.polynomials.poly_div(poly_1, poly_2, var, right=True)[source]

Polynomial division with remainder of poly_1 and poly_2 with respect to var.

Parameters:
  • poly_1 (Poly) – Polynomial which should be divided.

  • poly_2 (Poly) – Polynomial by which should be divided.

  • var (sympy.Symbol) – Variable with respect to which to divide.

  • right ((optional, default = True) bool) – Should right division be used.

Returns:

  • quotient (Poly) – Result of division

  • remainder (Poly) – Remainder of division

Notes

This function produces polynomials quotient and remainder such that poly_1 = poly_2 * quotient + remainder for right = True poly_1 = quotient * poly_2 + remainder for right = False

biquaternion_py.random_gen module

Module for generation of random objects

biquaternion_py.random_gen.rand_bq(maximum=10)[source]

Random biquaternion with rational coefficients.

biquaternion_py.random_gen.rand_line(maximum=10)[source]

Random line with rational coefficients

biquaternion_py.random_gen.rand_quat(maximum=10)[source]

Random quaternion with rational coefficients.

biquaternion_py.random_gen.rand_rational(maximum=10)[source]

Generate random rational number up to n

Parameters:

maximum (int (optional)) –

Maximum of random number generated

(Default value = 10)

Returns:

Random rational number in Range maximum

Return type:

(float)

Module contents