Generic utility functions to
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the OS provides them (UNIX-like do).
Returns: | number of seconds since the Epoch |
---|---|
Return type: | float |
Read section from settings file at filename.
Parameters: |
|
---|---|
Returns: | settings section dictionary |
Return type: | dict |
Example:
>>> read_settings('test.cfg', 'mySection')
{'a_key': 1.1111, 'another_key': False}
Write mapped_values at section in settings file at filename.
Parameters: |
|
---|
Example:
>>> write_settings('test.cfg', 'mySection', {'a_key': 1.1111, 'another_key': False})
Bases: object
An homogeneous transform.
It is a composition of rotation and translation. Mathematically it can be expressed as
where R is the 3x3 submatrix describing rotation and T is the 3x1 submatrix describing translation.
source: http://en.wikipedia.org/wiki/Denavit%E2%80%93Hartenberg_parameters#Denavit-Hartenberg_matrix
Constructor.
With empty arguments it’s just a 4x4 identity matrix.
Parameters: |
|
---|
Get the rotation component (matrix).
Parameters: | as_numpy – whether to return a numpy object or a tuple |
---|---|
Returns: | 3x3 rotation matrix |
Return type: | tuple of tuples or numpy.ndarray |
Return the angle around the vertical axis with respect to the X+ axis, i.e. the angular orientation inherent of a rotation matrix rot, constrained to the plane aligned with the horizon (XZ, since the vertical axis is Y).
Return the inclination (as pitch and roll) inherent of rotation matrix rot, with respect to the plane (XZ, since the vertical axis is Y). pitch is the rotation around Z and roll around Y.
Examples:
>>> rot = calc_rotation_matrix((1.0, 0.0, 0.0), pi/6)
>>> pitch, roll = gemut.calc_inclination(rot)
0.0, pi/6
>>> rot = calc_rotation_matrix((0.0, 1.0, 0.0), whatever)
>>> pitch, roll = gemut.calc_inclination(rot)
0.0, 0.0
>>> rot = calc_rotation_matrix((0.0, 0.0, 1.0), pi/6)
>>> pitch, roll = gemut.calc_inclination(rot)
pi/6, 0.0
Return the row-major 3x3 rotation matrix defining a rotation of magnitude angle around axis.
Formula is the same as the one presented here (as of 2011.12.01): http://goo.gl/RkW80
The returned matrix format is length-9 tuple.
Return the 3-vector vector transformed into the local coordinate system of ODE body ‘body’
Return an OpenGL compatible (column-major, 4x4 homogeneous) transformation matrix from ODE compatible (row-major, 3x3) rotation matrix rotation and position vector position.
The returned matrix format is length-9 tuple.
Return the 3-1-3 Euler angles phi, theta and psi (using the x-convention) corresponding to the rotation matrix rot, which is a tuple of three 3-element tuples, where each one is a row (what is called row-major order).
Using the x-convention, the 3-1-3 Euler angles phi, theta and psi (around the Z, X and again the Z-axis) can be obtained as follows:
Functions to perform operations over vectors and matrices; deal with homogeneous transforms; convert angles and other structures.
Calculate the vectorial substraction vel1 - vel0 divided by time step. If any of the vectors is None, then None is returned.
vel1 is the velocity measured time_step seconds after vel0.
Return the cross product of 3-dimension vector1 and vector2.
Efficient dot-product operation between two vectors of the same size. source: http://docs.python.org/library/itertools.html
Return tuple_9 as a 3-tuple of 3-tuples.
Parameters: | tuple_9 – tuple of 9 elements |
---|---|
Returns: | tuple_9 formatted as tuple of tuples |
Convert matrix_ to a tuple.
Example:
>>> matrix_as_tuple(((1, 2), (3, 4)))
(1, 2, 3, 4)
Parameters: | matrix (tuple) – nested tuples |
---|---|
Returns: | matrix_ flattened as a tuple |
Return type: | tuple |
Return the matrix multiplication of matrix1 and matrix2.
Parameters: |
|
---|---|
Returns: | LxN matrix, product of matrix1 and matrix2 |
Return type: | tuple of tuples |
Convert Numpy 2D array (i.e. matrix) to a tuple of tuples.
source: http://stackoverflow.com/a/10016379/556413
Example:
>>> arr = numpy.array(((2, 2), (2, -2)))
>>> np_matrix_to_tuple(arr)
((2, 2), (2, -2))
Parameters: | array (numpy.ndarray) – 2D array (i.e. matrix) |
---|---|
Returns: | matrix as tuple of tuples |
Return projection of 3-dimension vector onto unit 3-dimension unit_vector.
Return the rotation of 3-dimension vector by 3x3 (row major) matrix rot.
Return the global revision id that identifies the working copy.
To obtain the value it runs the command hg identify --id, whose short form is hg id -i.
>>> get_hg_changeset()
1a4b04cf687a
>>> get_hg_changeset()
1a4b04cf687a+
Note
When there are outstanding (i.e. uncommitted) changes in the working copy, a + character will be appended to the current revision id.
Return a numeric identifier of the latest changeset of the current repository based on its timestamp.
To obtain the value it runs the command hg tip --template '{date}'
>> get_hg_tip_timestamp() ‘20130328021918’
Based on: django.utils.get_git_changeset @ commit 9098504, and http://hgbook.red-bean.com/read/customizing-the-output-of-mercurial.html
Django’s license is included at docs/Django BSD-LICENSE.txt
Return a PEP 386-compliant version number from version.
Parameters: |
|
---|---|
Returns: | version as a string |
Return type: | str |
>>> get_version(version=(0, 4, 0, 'alpha', 0))
0.4.dev20130401011455
>>> get_version(version=(0, 4, 0, 'alpha', 1))
0.4a1
>>> get_version(version=(0, 4, 1, 'alpha', 0))
0.4.1.dev20130401011455
>>> get_version(version=(0, 4, 1, 'alpha', 1))
0.4.1a1
>>> get_version(version=(0, 4, 0, 'beta', 0))
0.4b0
>>> get_version(version=(0, 4, 0, 'rc', 0))
0.4c0
>>> get_version(version=(0, 4, 0, 'final', 0))
0.4
>>> get_version(version=(0, 4, 0, 'final', 1))
0.4
>>> get_version(version=(0, 4, 1, 'final', 0))
0.4.1
>>> get_version(version=(0, 4, 0, 'alpha', 0), length='medium')
0.4.dev
>>> get_version(version=(0, 4, 0, 'alpha', 0), length='short')
0.4
Based on: django.utils.version @ commit 9098504. Django’s license is included at docs/Django BSD-LICENSE.txt