Geometry

Geometrical operations from primitive mathematical routines like rotation and translation to complex motion description by a spline-based Trajectory class. BoundingBox used to constraint physical bodies is defined here as well.

All the transformation operations are in the backward form, which means if the order of operations is: A = trans_1 B = trans_2 C = trams_3, then in the forward form of the resulting transformation matrix would be T = ABC yielding x’ = ABCx = Tx. Backward form means that we calculate the matrix in the form T^{-1} = C^{-1}B^{-1}A^{-1} = (ABC)^{-1}. Thus, we can easily obtain x = T^{-1}x’.

class syris.geometry.BoundingBox(points)

Class representing a graphical object’s bounding box.

get_max(axis=0)

Get maximum along the specified axis.

get_min(axis=0)

Get minimum along the specified axis.

get_projected_points(axis)

Get the points projection by releasing the specified axis.

merge(other)

Merge with other bounding box.

overlaps(other)

Determine if the bounding box XY-projection overlaps XY-projection of other bounding box.

property points

The object border points.

property roi

Return range of interest defined by the bounding box as (y_0, x_0, y_1, x_1).

class syris.geometry.Trajectory(control_points, pixel_size=None, furthest_point=None, time_dist=None, velocity=None, num_points=None)

Class representing object’s trajectory.

Trajectory is a spline interpolated from a set of points.

bind(pixel_size=None, furthest_point=None)

Bind the trajectory to a pixel_size to make sure two positions are not more than pixel_size apart between two time points. furthest_point is the furthest point from a body center used to compute rotational displacement and it can be None.

property bound

Return True if the trajectory is currently bound.

property control_points

Control points used by the trajectory.

property furthest_point

Furthest point for which the trajectory is interpolated.

get_direction(abs_time, norm=True)

Get direction of the trajectory at the time abs_time. It is the derivative of the trajectory at abs_time. If norm is True, the direction vector will be normalized.

get_distances(u=None, u_0=None)

Get the distances from the trajectory beginning to every consecutive point defined by the parameter.

get_maximum_dt(distance=None)

Get the maximum time difference which moves the object no more than distance. If distance is None the pixel size this trajectory is bound to is used. Consider both rotational and translational displacement.

get_maximum_du(distance=None)

Get the maximum parameter difference which moves the object no more than distance. If distance is None the pixel size this trajectory is bound to is used. Consider both rotational and translational displacement.

get_next_time(t_0)

Get time from t_0 when the trajectory will have travelled more than pixel size.

get_parameter(abs_time)

Get the spline parameter from the time abs_time.

get_point(abs_time)

Get a point on the trajectory at the time abs_time.

property length

Trajectory length.

property pixel_size

Pixel size for which the trajectory is interpolated.

property points

Return interpolated points.

property stationary

Return True if the trajectory is stationary.

property time

Total time needed to travel the whole trajectory.

property time_tck

The tck tuple of scipy.interpolate.splrep() for time-distance spline.

property times

Return the time points for which the distance is defined.

exception syris.geometry.TrajectoryError

Exceptions related to trajectory.

syris.geometry.angle(vec_0, vec_1)

Angle between vectors vec_0 and vec_1. The vectors might be 2D with 0 dimension specifying (x, y, z) components.

syris.geometry.closest(values, min_value)

Get the minimum greater value min_value from values.

syris.geometry.derivative_fit(tck, u, max_distance)

Reinterpolate curve in a way that all the f’ * du are smaller than max_distance. The original spline is given by tck and parameter u.

syris.geometry.get_rotation_displacement(d_0, d_1, length)

Return the displacement of a sphere with radius length caused by rotation around vectors d_0 and d_1. The displacement is returned for every axis (x, y, z).

syris.geometry.interpolate_1d(x_0, y_0, size)

Interpolate function y = f(x) with x_0, y_0 as control points and return the interpolated x_1 and y_1 arrays of size.

syris.geometry.is_normalized(vector)

Test whether a vector is normalized.

syris.geometry.length(vector)

Get length of a vector.

syris.geometry.make_points(x_ends, y_ends, z_ends)

Make 3D points out of minima and maxima given by x_ends, y_ends and z_ends.

syris.geometry.maximum_derivative_parameter(tck, u, max_distance)

Get the maximum possible du, for which holds that dx < max_distance.

syris.geometry.normalize(vector)

Normalize a vector.

syris.geometry.overlap(interval_0, interval_1)

Check if intervals interval_0 and interval_1 overlap.

syris.geometry.reinterpolate(tck, u, n)

Arc length reinterpolation of a spline given by tck and parameter u to have n data points.

syris.geometry.rotate(phi, axis, shift=None)

Rotate the object by phi around vector axis, where shift is the translation which takes place before the rotation and -shift takes place afterward, resulting in the transformation TRT^-1. Rotation around an arbitrary point in space can be modeled in this way. The angle is _always_ rescaled to radians.

syris.geometry.scale(scale_vec)

Scale the object by scaling coefficients (kx, ky, kz) given by sc_vec.

syris.geometry.transform_vector(trans_matrix, vector)

Transform vector by the transformation matrix trans_matrix with dimensions (4,3) width x height.

syris.geometry.translate(vec)

Translate the object by a vector vec. The vector is _always_ transformed into meters.