diff --git a/docs/build/html/_modules/data.html b/docs/build/html/_modules/data.html index f3d0489..8e9130b 100644 --- a/docs/build/html/_modules/data.html +++ b/docs/build/html/_modules/data.html @@ -35,13 +35,13 @@

Source code for data

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-"""Read and write data to or from file.
+"""Read and write data to or from file and manipulate data structures.
 
-:Date: 2019-07-29
+:Date: 2019-10-11
 
 .. module:: data
   :platform: *nix, Windows
-  :synopsis: Handle data files.
+  :synopsis: Handle data files and structures.
 
 .. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
 """
@@ -155,6 +155,34 @@
     length = int(k/n)
     return [lst[i*n:i*n+n] for i in range(length)]
+
[docs]def seq(start, stop=None, step=1): + r"""Create an arithmetic bounded sequence. + + The sequence is one of the following; + + - empty :math:`\{\}=\emptyset`, if start and stop are the same + - degenerate :math:`\{a\}`, if the sequence has only one element. + - left-close and right-open :math:`[a, b)` + + :param start: start of the sequence, the lower bound. If only start + is given than it is interpreted as stop and start will be 0. + :type start: int or float + :param stop: stop of sequence, the upper bound. + :type stop: int or float + :param step: step size, the common difference (constant difference + between consecutive terms). + :type step: int or float + :returns: arithmetic bounded sequence + :rtype: list + """ + if stop is None: + return seq(0, start, step) + n = int(math.ceil((stop - start)/float(step))) + lst = [] + if n > 0: + lst = [start + step*i for i in range(n)] + return lst
+
[docs]def unique_ending(ids, n=1): """From id list get list with unique ending. diff --git a/docs/build/html/_modules/geometry.html b/docs/build/html/_modules/geometry.html index 0e78238..8bfdf1f 100644 --- a/docs/build/html/_modules/geometry.html +++ b/docs/build/html/_modules/geometry.html @@ -37,7 +37,7 @@ # -*- coding: utf-8 -*- """2D geometry objects. -:Date: 2019-08-20 +:Date: 2019-08-28 .. module:: geometry :platform: *nix, Windows @@ -49,6 +49,36 @@ import numpy as np +
[docs]def distance(point1, point2): + """Distance between two points (or length of a straight line). + + :param point1: first point (first end point of straight line) + :type point1: tuple + :param point2: second point (second end point of straight line) + :type point2: tuple + + :returns: distance between the two points + :rtype: float + """ + return math.sqrt((point2[0]-point1[0])**2 + (point2[1]-point1[1])**2)
+ + +
[docs]def angle(point1, point2=None): + """Angle of point or between two points. + + :param point1: (first) point + :type point1: tuple + :param point2: second point (default = None) + :type point2: tuple + + :returns: angle of point or between two points + :rtype: float + """ + if point2 is None: + return math.atan2(point1[1], point1[0]) + return math.atan2(point2[1]-point1[1], point2[0]-point1[0])
+ +
[docs]def translate(vec, *pts): """Translate a point or polygon by a given vector. @@ -316,7 +346,7 @@ if 'global_deformation' in kwargs: lr = [(pts[l-kwargs['index_offset']], pts[r-kwargs['index_offset']]) for l, r in kwargs['inc']] - ang = [math.atan2(r[1]-l[1], r[0]-l[0]) for l, r in lr] + ang = [angle(l, r) for l, r in lr] # system deformation U = kwargs['global_deformation'] if 'rotation_plane' in kwargs and 'xz' == kwargs['rotation_plane']: diff --git a/docs/build/html/_modules/geometry_plot.html b/docs/build/html/_modules/geometry_plot.html index 2a0fc3d..5340452 100644 --- a/docs/build/html/_modules/geometry_plot.html +++ b/docs/build/html/_modules/geometry_plot.html @@ -47,7 +47,9 @@ """ import math import pylab -from geometry import line, interpolate_hermite, rotate_xy, translate_xy +from geometry import ( + distance, angle, line, interpolate_hermite, rotate_xy, translate_xy +) pylab.style.use('dark_background') pylab.rcParams['grid.color'] = 'gray' @@ -109,8 +111,8 @@ for ln in lns: l, r, d = ln - L = math.sqrt((r[0]-l[0])**2 + (r[1]-l[1])**2) - ang = math.atan2(r[1]-l[1], r[0]-l[0]) + L = distance(l, r) + ang = angle(l, r) x, y = interpolate_hermite(d[1], d[2], d[4], d[5], d[0], d[3], scale_x=L, scale_y=factor, samples=samples) x, y = rotate_xy((0, 0), ang, x, y) diff --git a/docs/build/html/data.html b/docs/build/html/data.html index 52cf77e..bbc4ef0 100644 --- a/docs/build/html/data.html +++ b/docs/build/html/data.html @@ -34,10 +34,10 @@

data module

-

Read and write data to or from file.

+

Read and write data to or from file and manipulate data structures.

Date
-

2019-07-29

+

2019-10-11

@@ -125,6 +125,35 @@ array. m = k / n

+
+
+seq(start, stop=None, step=1)[source]
+

Create an arithmetic bounded sequence.

+

The sequence is one of the following;

+
    +
  • empty \(\{\}=\emptyset\), if start and stop are the same

  • +
  • degenerate \(\{a\}\), if the sequence has only one element.

  • +
  • left-close and right-open \([a, b)\)

  • +
+
+
Parameters
+
    +
  • start (int or float) – start of the sequence, the lower bound. If only start +is given than it is interpreted as stop and start will be 0.

  • +
  • stop (int or float) – stop of sequence, the upper bound.

  • +
  • step (int or float) – step size, the common difference (constant difference +between consecutive terms).

  • +
+
+
Returns
+

arithmetic bounded sequence

+
+
Return type
+

list

+
+
+
+
store(file_name, object_data)[source]
diff --git a/docs/build/html/genindex.html b/docs/build/html/genindex.html index 76386de..9eff453 100644 --- a/docs/build/html/genindex.html +++ b/docs/build/html/genindex.html @@ -59,6 +59,10 @@

A

+ - +
@@ -284,6 +290,8 @@