add ode solver, tests and update docs

This commit is contained in:
2019-05-26 21:54:58 +02:00
parent 184e80269b
commit d0873a36da
33 changed files with 1821 additions and 396 deletions

View File

@@ -13,6 +13,7 @@
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
@@ -33,32 +34,81 @@
<div class="section" id="module-geometry">
<span id="geometry-module"></span><h1>geometry module<a class="headerlink" href="#module-geometry" title="Permalink to this headline"></a></h1>
<p>2D</p>
<p>&#64;date: 2019-03-21
&#64;author: Daniel Weschke</p>
<dl class="function">
<p>2D geometry objects.</p>
<dl class="field-list simple">
<dt class="field-odd">Date</dt>
<dd class="field-odd"><p>2019-03-21</p>
</dd>
</dl>
<span class="target" id="module-geometry"></span><dl class="function">
<dt id="geometry.cubic">
<code class="descname">cubic</code><span class="sig-paren">(</span><em>point1</em>, <em>angle1</em>, <em>point2</em>, <em>angle2</em>, <em>samples=50</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.cubic" title="Permalink to this definition"></a></dt>
<dd><p>returns
([sample_point1_x, sample_point2_x, …], [sample_points1_y, sample_point2_y, …])</p>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>point1</strong> (<em>tuple</em>) one end point</p></li>
<li><p><strong>angle1</strong> (<em>int</em><em> or </em><em>float</em>) the slope at the one end point</p></li>
<li><p><strong>point2</strong> (<em>tuple</em>) other end point</p></li>
<li><p><strong>angle2</strong> (<em>int</em><em> or </em><em>float</em>) the slope at the other end point</p></li>
<li><p><strong>samples</strong> (<em>int</em>) number of sampling points</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>([sample_point1_x, sample_point2_x, …],
[sample_points1_y, sample_point2_y, …])</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>tuple</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="geometry.cubic_deg">
<code class="descname">cubic_deg</code><span class="sig-paren">(</span><em>point1</em>, <em>angle1</em>, <em>point2</em>, <em>angle2</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.cubic_deg" title="Permalink to this definition"></a></dt>
<dd><p>returns
([sample_point1_x, sample_point2_x, …], [sample_points1_y, sample_point2_y, …])</p>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>point1</strong> (<em>tuple</em>) one end point</p></li>
<li><p><strong>angle1</strong> (<em>int</em><em> or </em><em>float</em>) the slope at the one end point</p></li>
<li><p><strong>point2</strong> (<em>tuple</em>) other end point</p></li>
<li><p><strong>angle2</strong> (<em>int</em><em> or </em><em>float</em>) the slope at the other end point</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>([sample_point1_x, sample_point2_x, …],
[sample_points1_y, sample_point2_y, …])</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>tuple</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#geometry.cubic" title="geometry.cubic"><code class="xref py py-meth docutils literal notranslate"><span class="pre">cubic()</span></code></a></p>
</div>
</dd></dl>
<dl class="function">
<dt id="geometry.line">
<code class="descname">line</code><span class="sig-paren">(</span><em>point1</em>, <em>point2</em>, <em>samples=2</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.line" title="Permalink to this definition"></a></dt>
<dd><p>samples: number of sampling points</p>
<p>y = (y2-y1)/(x2-x1)*(x-x1) + y1</p>
<dl class="simple">
<dt>returns</dt><dd><p>((point1_x, point2_x), (points1_y, point2_y))
or
([sample_point1_x, sample_point2_x, …], [sample_points1_y, sample_point2_y, …])</p>
<dd><div class="math notranslate nohighlight">
\[y = \frac{y_2-y_1}{x_2-x_1}(x-x_1) + y_1\]</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>point1</strong> (<em>tuple</em>) one end point</p></li>
<li><p><strong>point2</strong> (<em>tuple</em>) other end point</p></li>
<li><p><strong>samples</strong> (<em>int</em>) number of sampling points</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>((point1_x, point2_x), (points1_y, point2_y)) or
([sample_point1_x, sample_point2_x, …],
[sample_points1_y, sample_point2_y, …])</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>tuple</p>
</dd>
</dl>
</dd></dl>
@@ -66,26 +116,57 @@ or
<dl class="function">
<dt id="geometry.points">
<code class="descname">points</code><span class="sig-paren">(</span><em>*pts</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.points" title="Permalink to this definition"></a></dt>
<dd><p>returns
((point1_x, point2_x), (point1_y, point2_y), …)</p>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>*pts</strong> points to rearrange</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>((point1_x, point2_x), (point1_y, point2_y), …)</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>tuple</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="geometry.rectangle">
<code class="descname">rectangle</code><span class="sig-paren">(</span><em>width</em>, <em>height</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.rectangle" title="Permalink to this definition"></a></dt>
<dd><p>returns
(point1, point2, point3, point4)</p>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>width</strong> (<em>int</em><em> or </em><em>float</em>) the width of the rectangle</p></li>
<li><p><strong>height</strong> (<em>int</em><em> or </em><em>float</em>) the height of the rectangle</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>(point1, point2, point3, point4)</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>tuple</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="geometry.rotate">
<code class="descname">rotate</code><span class="sig-paren">(</span><em>origin</em>, <em>angle</em>, <em>*pts</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.rotate" title="Permalink to this definition"></a></dt>
<dd><p>Rotate a point or polygon counterclockwise by a given angle around a given origin.</p>
<p>The angle should be given in radians.</p>
<dl class="simple">
<dt>returns</dt><dd><p>(point_x, point_y)
or
(point1, point2, …)</p>
<dd><p>Rotate a point or polygon counterclockwise by a given angle around a given
origin. The angle should be given in radians.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>origin</strong> (<em>tuple</em>) the center of rotation</p></li>
<li><p><strong>angle</strong> (<em>int</em><em> or </em><em>float</em>) the rotation angle</p></li>
<li><p><strong>*pts</strong> points to rotate</p></li>
<li><p><strong>**kwargs</strong> options</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>(point_x, point_y) or (point1, point2, …)</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>tuple</p>
</dd>
</dl>
</dd></dl>
@@ -93,31 +174,66 @@ or
<dl class="function">
<dt id="geometry.rotate_deg">
<code class="descname">rotate_deg</code><span class="sig-paren">(</span><em>origin</em>, <em>angle</em>, <em>*pts</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.rotate_deg" title="Permalink to this definition"></a></dt>
<dd><p>Rotate a point or polygon counterclockwise by a given angle around a given origin.</p>
<p>The angle should be given in degrees.</p>
<dl class="simple">
<dt>returns</dt><dd><p>(point_x, point_y)
or
(point1, point2, …)</p>
<dd><p>Rotate a point or polygon counterclockwise by a given angle around a given
origin. The angle should be given in degrees.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>origin</strong> (<em>tuple</em>) the center of rotation</p></li>
<li><p><strong>angle</strong> (<em>int</em><em> or </em><em>float</em>) the rotation angle</p></li>
<li><p><strong>*pts</strong> points to rotate</p></li>
<li><p><strong>**kwargs</strong> options</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>(point_x, point_y) or (point1, point2, …)</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>tuple</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#geometry.rotate" title="geometry.rotate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">rotate()</span></code></a></p>
</div>
</dd></dl>
<dl class="function">
<dt id="geometry.square">
<code class="descname">square</code><span class="sig-paren">(</span><em>width</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.square" title="Permalink to this definition"></a></dt>
<dd><p>returns
(point1, point2, point3, point4)</p>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>width</strong> (<em>int</em><em> or </em><em>float</em>) the edge size of the square</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>(point1, point2, point3, point4)</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>tuple</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#geometry.rectangle" title="geometry.rectangle"><code class="xref py py-meth docutils literal notranslate"><span class="pre">rectangle()</span></code></a></p>
</div>
</dd></dl>
<dl class="function">
<dt id="geometry.translate">
<code class="descname">translate</code><span class="sig-paren">(</span><em>vec</em>, <em>*pts</em><span class="sig-paren">)</span><a class="headerlink" href="#geometry.translate" title="Permalink to this definition"></a></dt>
<dd><p>Translate a point or polygon by a given vector.</p>
<dl class="simple">
<dt>returns</dt><dd><p>(point_x, point_y)
or
(point1, point2, …)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>vec</strong> (<em>tuple</em>) translation vector</p></li>
<li><p><strong>*pts</strong> points to translate</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>(point_x, point_y) or (point1, point2, …)</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>tuple</p>
</dd>
</dl>
</dd></dl>