aquaduct.geom.traces module

diff(trace)[source]

This function calculates the distance between 2 given points.

Parameters

trace – coordinates in numpy array object

Returns

distance between points

tracepoints(start, stop, nr)[source]
Parameters
  • start – coordinates of the first point as a numpy array object

  • stop – coordinates of the second point as a numpy array object

  • nr – number of elements between the first and second point

Returns

two-dimentional numpy array; number of dimentions depends on nr parameter

midpoints(paths)[source]
The function returns a tuple of numpy arrays extended with mid point spanning last and first element(column)

of these arrays.

Parameters

paths – a tuple of 2-dimentional np.arrays that hold 3D coordinates; each element holds one trace, all elements are supposed to make one path divided in to sections

Returns

paths elements with additional mid points as a generator object

length_step_std(trace)[source]

This function calculates sum, mean and standard deviation from all segments of a trace.

Parameters

trace – coordinates of points as numpy array

Returns

a tuple with basics statistics of a trace

vector_one(V)[source]
Parameters

V – a vector in a form of array-like object, tuple or a list

Returns

vector in the same direction but of lenght 1

project_p_on_ab(p, a, b)[source]
Parameters
  • p – a point to be projected on AB line

  • a – beginning of AB line

  • b – end of AB line

Returns

point on AB line being a projection of p

distance_p_to_ab(p, a, b)[source]
Parameters
  • p – a point of interest

  • a – beginning of AB line

  • b – end of AB line

Returns

distance of p to AB line

is_p_above_vp0_plane(p, v, p0)[source]
Parameters
  • p – a point of interest

  • v – vector pointing perpendicularly up from the plane perspective

  • p0 – point on the plane

Returns

>0 if p point is above the plane, 0 if it is on the plane, and <0 if it is below the plane

vector_change_len(V, l)[source]
Parameters
  • V – a vector in a form of array-like object, tuple or a list

  • l (float) – lenght by wich vectro should be increased (decreased if negative)

Returns

vector in the same direction but of altered lenght

vector_norm(V)[source]
Parameters

V – a vector in a form of array-like object, tuple or a list

Returns

normalized length of a vector

triangle_angles(A, B, C)[source]

Parameters are coordinates of points which are tops of triangle. The function calculates angles in a triangle formed by given coordinates.

Parameters
  • A – coordinates of the first point

  • B – coordinates of the second point

  • C – coordinates of the third point

Returns

list of arguments where angle is given in radians , the output is as follow: [BAC,CAB,ABC]

triangle_angles_last(A, B, C)[source]

Parameters are coordinates of points which are tops of triangle. The function calculates the [ABC] angle.

Parameters
  • A – coordinates of the first point [A top]

  • B – coordinates of the second point [B top]

  • C – coordinates of the third point [C top]

Returns

list with one value of ABC angle in radians

triangle_height(A, B, C)[source]

Parameters are coordinates of points which are tops of triangle. The function calculates the ABC triangle height.

Parameters
  • A – coordinates of the first point [A top]

  • B – coordinates of the second point [B top]

  • C – coordinates of the third point [C top]

Returns

one value of ABC triangle height

vectors_angle(A, B)[source]

This function calculates the angle between two given vectors (starting from the [0,0,0] to the given coordinates.

Parameters
  • A – coordinates of the first point which is the end of the vector

  • B – coordinates of the second point which is the end of the vector

Returns

the angle between vectors in question (in radians)

vectors_angle_alt(A, B)[source]

This function calculates the angle between two given vectors (starting from the [0,0,0] to the given coordinates

  • alternative method.

Parameters
  • A – coordinates of the first point which is the end of the vector

  • B – coordinates of the second point which is the end of the vector

Returns

the angle between vectors in question (in radians)

vectors_angle_alt_anorm(A, B, A_norm)[source]
This function calculates the angle between two given vectors (starting from the [0,0,0] to the given coordinates
  • alternative method with additional A_norm holding norm of A.

Parameters
  • A – coordinates of the first point which is the end of the vector

  • B – coordinates of the second point which is the end of the vector

  • A_norm – additional parameter holding normalized of vector A

Returns

the angle between vectors in question (in radians)

vectors_angle_anorm(A, B, A_norm)[source]
This function calculates the angle between two given vectors (starting from the [0,0,0] to the given coordinates

using additional A_norm holding norm of A.

Parameters
  • A – coordinates of the first point which is the end of the vector

  • B – coordinates of the second point which is the end of the vector

  • A_norm – additional parameter holding normalized of vector A

Returns

the angle between vectors in question (in radians)

triangle_area(A, B, C)[source]

Parameters are coordinates of points which are tops of triangle. The function calculates the ABC triangle area with Heron’s formula.

Parameters
  • A – coordinates of the first point [A top]

  • B – coordinates of the second point [B top]

  • C – coordinates of the third point [C top]

Returns

area

Return type

float

square_area(A, B, C, D)[source]

Parameters are coordinates of points which are tops of square. The function estimates the ABCD square area by calculating areas of triangles that make up the square.

Parameters
  • A – coordinates of the first point [A top]

  • B – coordinates of the second point [B top]

  • C – coordinates of the third point [C top]

  • D – coordinates of the fourth point [D top]

Returns

area

Return type

float

class LinearizeRecursive[source]

Bases: object

Base class for linearization methods classes.

It implements recursive algorithm.

here(coords, depth=0)[source]

Core of recursive linearization argorithm.

It checks if the first, the last and the middle point are linear according to the criterion. The middle point is a selected point that is in the middle of length of the paths made by input coordinates.

If these points are linear their indices are returned. Otherwise, coordinates are split into two parts. First part spans points from the first point to the middle point (inclusive) and the second part spans points from the middle (inclusive) to the last point. Next, these two parts are submitted recursively to here().

Results of these recursive calls are joined, redundant indices are removed and sorted result is returned.

Parameters
  • coords (numpy.ndarray) – Input coordinates.

  • depth (int) – Depth of recurence.

Returns

Indices of coords points that can be used instead of all points in visulatization.

Return type

list of int

class VectorLinearize(treshold=0.05236)[source]

Bases: object

Base class for linearization methods classes.

It implements vector linearization criterion.

is_linear_core(coords, depth=None)[source]

Method checks if input coordinates are linear according to the threshold and depth.

It begins with calculation of the threshold. If depth is None it is set to 1. Current threshold is calculated with following simple equation:

\[threshold_{current} = threshold_{initial} * (2 - 0.9^{depth})\]

Next, in a loop over all points but the first and the last the angle is calculated between two vectors. The first one made by the point and the first point, and the second vector made by the last and the first point. If any of the calculated angles is bigger the the treshold methods returns False; otherwise method returns True.

Parameters
  • coords (numpy.ndarray) – Coordinates for which linearization criterion is checked.

  • depth (int) – Depth of recurence.

Returns

True if input coordinates are linear and False otherwise.

Return type

bool

is_linear(coords, depth=None, **kwargs)[source]

For more detail see is_linear_core() which is used as the criterion of linearity in this method.

Parameters
  • coords (numpy.ndarray) – Coordinates for which linearization criterion is checked.

  • depth (int) – Depth of recurence.

Returns

True if input coordinates are linear and False otherwise. Criterion is checked for coordinates in normal and reverse order.

Return type

bool

class LinearizeRecursiveVector(treshold=0.05236)[source]

Bases: aquaduct.geom.traces.LinearizeRecursive, aquaduct.geom.traces.VectorLinearize

Class provides recursive linearization of coordinates with LinearizeRecursive algorithm and the criterion of linearity implemented by VectorLinearize. This is default method.

class LinearizeRecursiveTriangle(threshold=0.01)[source]

Bases: aquaduct.geom.traces.LinearizeRecursive, aquaduct.geom.traces.TriangleLinearize

Class provides recursive linearization of coordinates with LinearizeRecursive algorithm and the criterion of linearity implemented by TriangleLinearize.

class LinearizeHobbitVector(treshold=0.05236)[source]

Bases: aquaduct.geom.traces.LinearizeHobbit, aquaduct.geom.traces.VectorLinearize

Class provides recursive linearization of coordinates with LinearizeHobbit algorithm and the criterion of linearity implemented by VectorLinearize.

class LinearizeHobbitTriangle(threshold=0.01)[source]

Bases: aquaduct.geom.traces.LinearizeHobbit, aquaduct.geom.traces.TriangleLinearize

Class provides recursive linearization of coordinates with LinearizeHobbit algorithm and the criterion of linearity implemented by TriangleLinearize.

class LinearizeOneWayVector(treshold=0.05236)[source]

Bases: aquaduct.geom.traces.LinearizeOneWay, aquaduct.geom.traces.VectorLinearize

Class provides recursive linearization of coordinates with LinearizeOneWay algorithm and the criterion of linearity implemented by VectorLinearize.

class LinearizeOneWayTriangle(threshold=0.01)[source]

Bases: aquaduct.geom.traces.LinearizeOneWay, aquaduct.geom.traces.TriangleLinearize

Class provides recursive linearization of coordinates with LinearizeOneWay algorithm and the criterion of linearity implemented by TriangleLinearize.