670 lines
37 KiB
HTML
670 lines
37 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<title>mathematics module — pylib 2019.5.19 documentation</title>
|
||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
|
||
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
|
||
<script type="text/javascript" src="_static/jquery.js"></script>
|
||
<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" />
|
||
|
||
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
|
||
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
|
||
|
||
</head><body>
|
||
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
|
||
|
||
<div class="body" role="main">
|
||
|
||
<div class="section" id="module-mathematics">
|
||
<span id="mathematics-module"></span><h1>mathematics module<a class="headerlink" href="#module-mathematics" title="Permalink to this headline">¶</a></h1>
|
||
<p>Mathematical functions and objects.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Date</dt>
|
||
<dd class="field-odd"><p>2019-12-12</p>
|
||
</dd>
|
||
</dl>
|
||
<span class="target" id="module-mathematics"></span><dl class="function">
|
||
<dt id="mathematics.lcm">
|
||
<code class="sig-name descname">lcm</code><span class="sig-paren">(</span><em class="sig-param">a</em>, <em class="sig-param">b</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#lcm"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.lcm" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Compute the lowest common multiple of a and b</p>
|
||
</dd></dl>
|
||
|
||
<dl class="class">
|
||
<dt id="mathematics.matrix">
|
||
<em class="property">class </em><code class="sig-name descname">matrix</code><a class="reference internal" href="_modules/mathematics.html#matrix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p>
|
||
<p>Use/create matrix like list of lists</p>
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.rotate_x">
|
||
<code class="sig-name descname">rotate_x</code><span class="sig-paren">(</span><em class="sig-param">theta</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.rotate_x"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.rotate_x" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Rotation about the x dirction.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}
|
||
xx & xy & xz & t_x \\
|
||
yx' & yy' & yz' & t_y' \\
|
||
zx' & zy' & zz' & t_z' \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
1 & 0 & 0 & 0 \\
|
||
0 & \cos \theta & -\sin \theta & 0 \\
|
||
0 & \sin \theta & \cos \theta & 0 \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix}
|
||
\begin{bmatrix}
|
||
xx & xy & xz & t_x \\
|
||
yx & yy & yz & t_y \\
|
||
zx & zy & zz & t_z \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.rotate_y">
|
||
<code class="sig-name descname">rotate_y</code><span class="sig-paren">(</span><em class="sig-param">theta</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.rotate_y"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.rotate_y" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Rotation about the y dirction.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}
|
||
xx' & xy' & xz' & t_x' \\
|
||
yx & yy & yz & t_y \\
|
||
zx' & zy' & zz' & t_z' \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
\cos \theta & 0 & \sin \theta & 0 \\
|
||
0 & 1 & 0 & 0 \\
|
||
-\sin \theta & 0 & \cos \theta & 0 \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix}
|
||
\begin{bmatrix}
|
||
xx & xy & xz & t_x \\
|
||
yx & yy & yz & t_y \\
|
||
zx & zy & zz & t_z \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.rotate_z">
|
||
<code class="sig-name descname">rotate_z</code><span class="sig-paren">(</span><em class="sig-param">theta</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.rotate_z"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.rotate_z" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Rotation about the z dirction.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}
|
||
xx' & xy' & xz' & t_x' \\
|
||
yx' & yy' & yz' & t_y' \\
|
||
zx & zy & zz & t_z \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
\cos \theta & -\sin \theta & 0 & 0 \\
|
||
\sin \theta & \cos \theta & 0 & 0 \\
|
||
0 & 0 & 1 & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}
|
||
xx & xy & xz & t_x \\
|
||
yx & yy & yz & t_y \\
|
||
zx & zy & zz & t_z \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.rx">
|
||
<em class="property">static </em><code class="sig-name descname">rx</code><span class="sig-paren">(</span><em class="sig-param">theta</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.rx"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.rx" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Rotation matrix about the x direction.</p>
|
||
<p>Rotates the coordinate system of vectors</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}R_{x}(\theta) =
|
||
\begin{bmatrix}
|
||
1 & 0 & 0 & 0 \\
|
||
0 & \cos \theta & -\sin \theta & 0 \\
|
||
0 & \sin \theta & \cos \theta & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.ry">
|
||
<em class="property">static </em><code class="sig-name descname">ry</code><span class="sig-paren">(</span><em class="sig-param">theta</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.ry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.ry" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Rotation matrix about the y direction.</p>
|
||
<p>Rotates the coordinate system of vectors</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}R_{y}(\theta) =
|
||
\begin{bmatrix}
|
||
\cos \theta & 0 & \sin \theta & 0 \\
|
||
0 & 1 & 0 & 0 \\
|
||
-\sin \theta & 0 & \cos \theta & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.rz">
|
||
<em class="property">static </em><code class="sig-name descname">rz</code><span class="sig-paren">(</span><em class="sig-param">theta</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.rz"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.rz" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Rotation matrix about the z direction.</p>
|
||
<p>Rotates the coordinate system of vectors</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}R_{z}(\theta) =
|
||
\begin{bmatrix}
|
||
\cos \theta & -\sin \theta & 0 & 0 \\
|
||
\sin \theta & \cos \theta & 0 & 0 \\
|
||
0 & 0 & 1 & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}\end{split}\]</div>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Example</dt>
|
||
<dd class="field-odd"><p></p></dd>
|
||
</dl>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}R_{z}(\theta) \begin{bmatrix}1 \\ 0 \\ 0 \\ 1\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
\cos 90° & -\sin 90° & 0 & 0 \\
|
||
\sin 90° & \cos 90° & 0 & 0 \\
|
||
0 & 0 & 1 & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}1 \\ 0 \\ 0 \\ 1\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
0 & -1 & 0 & 0 \\
|
||
1 & 0 & 0 & 0 \\
|
||
0 & 0 & 1 & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}1 \\ 0 \\ 0 \\ 1\end{bmatrix} =
|
||
\begin{bmatrix}0 \\ 1 \\ 0 \\ 1\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.s">
|
||
<em class="property">static </em><code class="sig-name descname">s</code><span class="sig-paren">(</span><em class="sig-param">sx</em>, <em class="sig-param">sy=None</em>, <em class="sig-param">sz=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.s"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.s" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Scaling matrix</p>
|
||
<p>uniform scaling if sx=sy=sz=s.
|
||
Note that scaling happens around the origin, so objects not
|
||
centered at the origin will have their centers move. To avoid this,
|
||
either scale the object when it’s located at the origin, or
|
||
perform a translation afterwards to move the object back to where
|
||
it should be.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}S =
|
||
\begin{bmatrix}
|
||
s_x & 0 & 0 & 0 \\
|
||
0 & s_y & 0 & 0 \\
|
||
0 & 0 & s_z & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.scale">
|
||
<code class="sig-name descname">scale</code><span class="sig-paren">(</span><em class="sig-param">sx</em>, <em class="sig-param">sy=None</em>, <em class="sig-param">sz=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.scale"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.scale" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Scaling</p>
|
||
<p>uniform scaling if sx=sy=sz=s.
|
||
Note that scaling happens around the origin, so objects not
|
||
centered at the origin will have their centers move. To avoid this,
|
||
either scale the object when it’s located at the origin, or
|
||
perform a translation afterwards to move the object back to where
|
||
it should be.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}
|
||
xx' & xy' & xz' & t_x' \\
|
||
yx' & yy' & yz' & t_y' \\
|
||
zx' & zy' & zz' & t_z' \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
s_x & 0 & 0 & 0 \\
|
||
0 & s_y & 0 & 0 \\
|
||
0 & 0 & s_z & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}
|
||
xx & xy & xz & t_x \\
|
||
yx & yy & yz & t_y \\
|
||
zx & zy & zz & t_z \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.t">
|
||
<em class="property">static </em><code class="sig-name descname">t</code><span class="sig-paren">(</span><em class="sig-param">tx</em>, <em class="sig-param">ty</em>, <em class="sig-param">tz</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.t"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.t" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Translation matrix</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}T =
|
||
\begin{bmatrix}
|
||
1 & 0 & 0 & t_x \\
|
||
0 & 1 & 0 & t_y \\
|
||
0 & 0 & 1 & t_z \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.matrix.translate">
|
||
<code class="sig-name descname">translate</code><span class="sig-paren">(</span><em class="sig-param">tx</em>, <em class="sig-param">ty</em>, <em class="sig-param">tz</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#matrix.translate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.matrix.translate" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Translation</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}
|
||
xx & xy & xz & t_x' \\
|
||
yx & yy & yz & t_y' \\
|
||
zx & zy & zz & t_z' \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
1 & 0 & 0 & t_x \\
|
||
0 & 1 & 0 & t_y \\
|
||
0 & 0 & 1 & t_z \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}
|
||
xx & xy & xz & t_x \\
|
||
yx & yy & yz & t_y \\
|
||
zx & zy & zz & t_z \\
|
||
0 & 0 & 0 & h
|
||
\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="class">
|
||
<dt id="mathematics.vector">
|
||
<em class="property">class </em><code class="sig-name descname">vector</code><a class="reference internal" href="_modules/mathematics.html#vector"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p>
|
||
<p>Use/create vector like lists</p>
|
||
<ul class="simple">
|
||
<li><p>size -> len(a)</p></li>
|
||
<li><p>abs -> abs(a)</p></li>
|
||
<li><p>dot -> a * b</p></li>
|
||
<li><p>outer -> a @ b</p></li>
|
||
</ul>
|
||
<p>use super constructor</p>
|
||
<p>use super __iter__</p>
|
||
<p>use super __setitem__</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">v</span> <span class="o">=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">])</span>
|
||
<span class="gp">>>> </span><span class="n">v</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">]</span>
|
||
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||
<span class="go">[1, 2, 3, 1, 2]</span>
|
||
<span class="gp">>>> </span><span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">vector</span><span class="p">)</span>
|
||
<span class="go">True</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>use super __lt__(a, b)</p>
|
||
<p>use super __le__(a, b)</p>
|
||
<p>use super __eq__(a, b)</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">v</span> <span class="o">=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">])</span>
|
||
<span class="gp">>>> </span><span class="n">v2</span> <span class="o">=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">])</span>
|
||
<span class="gp">>>> </span><span class="n">v</span> <span class="o">==</span> <span class="n">v2</span>
|
||
<span class="go">True</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>use super __ne__(a, b)</p>
|
||
<p>use super __ge__(a, b)</p>
|
||
<p>use super __gt__(a, b)</p>
|
||
<p>use super __contains__</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="mi">2</span> <span class="ow">in</span> <span class="n">vector</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
|
||
<span class="go">True</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>__isub__</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">v</span> <span class="o">=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
|
||
<span class="gp">>>> </span><span class="n">v</span> <span class="o">-=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
|
||
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||
<span class="go">[-2, -1, 0]</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>__imul__</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">v</span> <span class="o">=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
|
||
<span class="gp">>>> </span><span class="n">v</span> <span class="o">*=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
|
||
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||
<span class="go">18</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>__imatmul__</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">m</span> <span class="o">=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
|
||
<span class="gp">>>> </span><span class="n">m</span> <span class="o">*=</span> <span class="n">vector</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
|
||
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||
<span class="go">[[3, 3, 3], [6, 6, 6], [9, 9, 9]]</span>
|
||
</pre></div>
|
||
</div>
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.abs">
|
||
<em class="property">static </em><code class="sig-name descname">abs</code><span class="sig-paren">(</span><em class="sig-param">a</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.abs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.abs" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Return modulus parts of a complex vector</p>
|
||
<dl class="field-list simple">
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.ang">
|
||
<em class="property">static </em><code class="sig-name descname">ang</code><span class="sig-paren">(</span><em class="sig-param">a</em>, <em class="sig-param">b</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.ang"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.ang" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.arg">
|
||
<em class="property">static </em><code class="sig-name descname">arg</code><span class="sig-paren">(</span><em class="sig-param">a</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.arg"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.arg" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Return phase parts of a complex vector</p>
|
||
<dl class="field-list simple">
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.ch_cs">
|
||
<code class="sig-name descname">ch_cs</code><span class="sig-paren">(</span><em class="sig-param">cs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.ch_cs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.ch_cs" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Transform this vector from its defined coordinate system to a
|
||
new coordinate system, defined by the given coordinate system (u,
|
||
v and w direction vectors).</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}x' \\ y' \\ z' \\ h'\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
u_x & u_y & u_z & 0 \\
|
||
v_x & v_y & v_z & 0 \\
|
||
w_x & w_y & w_z & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}x \\ y \\ z \\ h\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.conjugate">
|
||
<em class="property">static </em><code class="sig-name descname">conjugate</code><span class="sig-paren">(</span><em class="sig-param">a</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.conjugate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.conjugate" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>New vector object</p>
|
||
<dl class="field-list simple">
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.cross">
|
||
<em class="property">static </em><code class="sig-name descname">cross</code><span class="sig-paren">(</span><em class="sig-param">a</em>, <em class="sig-param">b</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.cross"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.cross" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Cross product</p>
|
||
<dl class="field-list simple">
|
||
</dl>
|
||
<p>c is orthogonal to both a and b.
|
||
The direction of c can be found with the right-hand rule.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\vec{c} = \vec{a} \times \vec{b}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.full">
|
||
<em class="property">static </em><code class="sig-name descname">full</code><span class="sig-paren">(</span><em class="sig-param">length</em>, <em class="sig-param">fill_value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.full"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.full" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Returns a vector of length m or matrix of size m rows, n
|
||
columns filled with v.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>length</strong> (<em>int</em>) – length of the vector, e. g. 3</p></li>
|
||
<li><p><strong>fill_value</strong> – Fill value</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Type fill_value</dt>
|
||
<dd class="field-even"><p>scalar</p>
|
||
</dd>
|
||
<dt class="field-odd">Example</dt>
|
||
<dd class="field-odd"><p></p></dd>
|
||
</dl>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">v</span> <span class="o">=</span> <span class="n">vector</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||
<span class="go">[7, 7, 7]</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.im">
|
||
<em class="property">static </em><code class="sig-name descname">im</code><span class="sig-paren">(</span><em class="sig-param">a</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.im"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.im" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Return the imaginary parts of a complex vector</p>
|
||
<dl class="field-list simple">
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.normalize">
|
||
<em class="property">static </em><code class="sig-name descname">normalize</code><span class="sig-paren">(</span><em class="sig-param">a</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.normalize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.normalize" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Normalize a vector (i. e. the vector has a length of 1)</p>
|
||
<dl class="field-list simple">
|
||
</dl>
|
||
<div class="math notranslate nohighlight">
|
||
\[\vec{e}_a = \frac{\vec{a}}{|\vec{a}|}\]</div>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><code class="xref py py-meth docutils literal notranslate"><span class="pre">norm()</span></code> for a norm (magnitude) of a vector</p>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.ones">
|
||
<em class="property">static </em><code class="sig-name descname">ones</code><span class="sig-paren">(</span><em class="sig-param">length</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.ones"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.ones" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Returns a vector of length m or matrix of size rows, n
|
||
columns filled with ones.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>length</strong> (<em>int</em>) – lhape of the vector, e. g. 3</p>
|
||
</dd>
|
||
<dt class="field-even">Example</dt>
|
||
<dd class="field-even"><p></p></dd>
|
||
</dl>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">v</span> <span class="o">=</span> <span class="n">ones</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||
<span class="go">[1.0, 1.0, 1.0]</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.random">
|
||
<em class="property">static </em><code class="sig-name descname">random</code><span class="sig-paren">(</span><em class="sig-param">shape</em>, <em class="sig-param">lmin=0.0</em>, <em class="sig-param">lmax=1.0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.random"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.random" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Returns a random vector of length n or matrix of size m rows, n
|
||
columns filled with random numbers.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Example</dt>
|
||
<dd class="field-odd"><p></p></dd>
|
||
</dl>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">v</span> <span class="o">=</span> <span class="n">random</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||
<span class="go">[0.9172905912930438, 0.8908124278322492, 0.5256002790725927]</span>
|
||
<span class="gp">>>> </span><span class="n">v</span> <span class="o">=</span> <span class="n">random</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||
<span class="go">[1.2563665665080803, 1.9270454509964547, 1.2381672401270487]</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.re">
|
||
<em class="property">static </em><code class="sig-name descname">re</code><span class="sig-paren">(</span><em class="sig-param">a</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.re"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.re" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Return the real parts of a complex vector</p>
|
||
<dl class="field-list simple">
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.rotate_x">
|
||
<code class="sig-name descname">rotate_x</code><span class="sig-paren">(</span><em class="sig-param">theta</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.rotate_x"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.rotate_x" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Rotation about the x dirction.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}x' \\ y' \\ z' \\ h'\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
1 & 0 & 0 & 0 \\
|
||
0 & \cos \theta & -\sin \theta & 0 \\
|
||
0 & \sin \theta & \cos \theta & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}x \\ y \\ z \\ h\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.rotate_y">
|
||
<code class="sig-name descname">rotate_y</code><span class="sig-paren">(</span><em class="sig-param">theta</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.rotate_y"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.rotate_y" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Rotation about the y dirction.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}x' \\ y' \\ z' \\ h'\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
\cos \theta & 0 & \sin \theta & 0 \\
|
||
0 & 1 & 0 & 0 \\
|
||
-\sin \theta & 0 & \cos \theta & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}x \\ y \\ z \\ h\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.rotate_z">
|
||
<code class="sig-name descname">rotate_z</code><span class="sig-paren">(</span><em class="sig-param">theta</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.rotate_z"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.rotate_z" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Rotation about the z dirction.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}x' \\ y' \\ z' \\ h'\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
\cos \theta & -\sin \theta & 0 & 0 \\
|
||
\sin \theta & \cos \theta & 0 & 0 \\
|
||
0 & 0 & 1 & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}x \\ y \\ z \\ h\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.scale">
|
||
<code class="sig-name descname">scale</code><span class="sig-paren">(</span><em class="sig-param">sx</em>, <em class="sig-param">sy=None</em>, <em class="sig-param">sz=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.scale"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.scale" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Scaling</p>
|
||
<p>uniform scaling if sx=sy=sz=s.
|
||
Note that scaling happens around the origin, so objects not
|
||
centered at the origin will have their centers move. To avoid this,
|
||
either scale the object when it’s located at the origin, or
|
||
perform a translation afterwards to move the object back to where
|
||
it should be.</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}x' \\ y' \\ z' \\ h'\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
s_x & 0 & 0 & 0 \\
|
||
0 & s_y & 0 & 0 \\
|
||
0 & 0 & s_z & 0 \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}x \\ y \\ z \\ h\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.translate">
|
||
<code class="sig-name descname">translate</code><span class="sig-paren">(</span><em class="sig-param">tx</em>, <em class="sig-param">ty</em>, <em class="sig-param">tz</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.translate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.translate" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Translation</p>
|
||
<div class="math notranslate nohighlight">
|
||
\[\begin{split}\begin{bmatrix}x' \\ y' \\ z' \\ h'\end{bmatrix} =
|
||
\begin{bmatrix}
|
||
1 & 0 & 0 & t_x \\
|
||
0 & 1 & 0 & t_y \\
|
||
0 & 0 & 1 & t_z \\
|
||
0 & 0 & 0 & 1
|
||
\end{bmatrix}
|
||
\begin{bmatrix}x \\ y \\ z \\ h\end{bmatrix}\end{split}\]</div>
|
||
</dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.xyz">
|
||
<code class="sig-name descname">xyz</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.xyz"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.xyz" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="method">
|
||
<dt id="mathematics.vector.zeros">
|
||
<em class="property">static </em><code class="sig-name descname">zeros</code><span class="sig-paren">(</span><em class="sig-param">length</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/mathematics.html#vector.zeros"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mathematics.vector.zeros" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Returns a zero vector of length m or matrix of size rows, n
|
||
columns filled with zeros.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>length</strong> (<em>int</em>) – length of the vector, e. g. 3</p>
|
||
</dd>
|
||
<dt class="field-even">Example</dt>
|
||
<dd class="field-even"><p></p></dd>
|
||
</dl>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">v</span> <span class="o">=</span> <span class="n">zeros</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="nb">print</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
|
||
<span class="go">[0.0, 0.0, 0.0]</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<h1 class="logo"><a href="index.html">pylib</a></h1>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3>Navigation</h3>
|
||
|
||
<div class="relations">
|
||
<h3>Related Topics</h3>
|
||
<ul>
|
||
<li><a href="index.html">Documentation overview</a><ul>
|
||
</ul></li>
|
||
</ul>
|
||
</div>
|
||
<div id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="footer">
|
||
©2019, Daniel Weschke.
|
||
|
||
|
|
||
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.1</a>
|
||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
||
|
||
|
|
||
<a href="_sources/mathematics.rst.txt"
|
||
rel="nofollow">Page source</a>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
</body>
|
||
</html> |