wulfric.geometry.absolute_to_relative#
- wulfric.geometry.absolute_to_relative(vector, basis)[source]#
Computes relative coordinates of the vector with respect to the basis.
\[\boldsymbol{v} = v^1 \boldsymbol{e_1} + v^2 \boldsymbol{e_2} + v^3 \boldsymbol{e_3}\]First scalar products of the vector with the basis vectors are computed
\[\begin{split}\begin{matrix} \boldsymbol{v} \cdot \boldsymbol{e_1} = v^1\, \boldsymbol{e_1} \cdot \boldsymbol{e_1} + v^2\, \boldsymbol{e_2} \cdot \boldsymbol{e_1} + v^3\, \boldsymbol{e_3} \cdot \boldsymbol{e_1} \\ \boldsymbol{v} \cdot \boldsymbol{e_2} = v^1\, \boldsymbol{e_1} \cdot \boldsymbol{e_2} + v^2\, \boldsymbol{e_2} \cdot \boldsymbol{e_2} + v^3\, \boldsymbol{e_3} \cdot \boldsymbol{e_2} \\ \boldsymbol{v} \cdot \boldsymbol{e_3} = v^1\, \boldsymbol{e_1} \cdot \boldsymbol{e_3} + v^2\, \boldsymbol{e_2} \cdot \boldsymbol{e_3} + v^3\, \boldsymbol{e_3} \cdot \boldsymbol{e_3} \end{matrix}\end{split}\]Then, system of linear equations for \(v^1\), \(v^2\), \(v^3\) is solved.
- Parameters:
- vector(3,) array-like
Absolute coordinates of a vector.
- basis(3, 3) array-like
Basis vectors. Rows are interpreted as vectors. Columns are interpreted as coordinates.
- Returns:
- relative(3,) numpy.ndarray
Relative coordinates of the
vectorwith respect to thebasis. \((v^1, v^2, v^3)\).
Examples
>>> import wulfric as wulf >>> wulf.geometry.absolute_to_relative([1, 0, 0], [[0, 1, 1], [1, 0, 1], [1, 1, 0]]) array([-0.5, 0.5, 0.5]) >>> wulf.geometry.absolute_to_relative([1, 0, 2.3241], [[0, 1, 1], [1, 0, 1], [1, 1, 0]]) array([ 0.66205, 1.66205, -0.66205])