%PDF- %PDF-
Direktori : /usr/share/doc/imath-devel/html/ |
Current File : //usr/share/doc/imath-devel/html/intro.html |
<!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Overview — Imath Documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/bizstyle.css" type="text/css" /> <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script src="_static/jquery.js"></script> <script src="_static/underscore.js"></script> <script src="_static/doctools.js"></script> <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <script src="_static/bizstyle.js"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Install Options" href="install.html" /> <link rel="prev" title="Imath Technical Documentation" href="index.html" /> <meta name="viewport" content="width=device-width,initial-scale=1.0" /> <!--[if lt IE 9]> <script src="_static/css3-mediaqueries.js"></script> <![endif]--> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="install.html" title="Install Options" accesskey="N">next</a> |</li> <li class="right" > <a href="index.html" title="Imath Technical Documentation" accesskey="P">previous</a> |</li> <li class="nav-item nav-item-0"><a href="index.html">Imath</a> »</li> <li class="nav-item nav-item-this"><a href="">Overview</a></li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="overview"> <h1>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h1> <p>Imath is a basic, light-weight, and efficient C++ representation of 2D and 3D vectors and matrices and other simple but useful mathematical objects, functions, and data types common in computer graphics applications, including the <code class="docutils literal notranslate"><span class="pre">half</span></code> 16-bit floating-point type.</p> <p>Imath also includes optional python bindings for all types and functions, including optimized implementations of vector and matrix arrays.</p> <p>The Imath library emphasizes simplicity, ease of use, correctness and verifiability, performance, and breadth of adoption. Imath is not intended to be a comprehensive linear algebra or numerical analysis package.</p> <p>Imath is not <a class="reference external" href="https://eigen.tuxfamily.org">Eigen</a>! It’s not a full-featured linear algebra package, and it doesn’t represent vectors and matrices of arbitrary dimension. Its greatest utility is as a geometric data representation, primarily for 2D images and 3D scenes and coordinate transformations, along with an accompanying set of utility methods and functions.</p> <div class="section" id="example"> <h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> <p>A basic program:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#include <Imath/ImathVec.h></span> <span class="c1">#include <iostream></span> <span class="nb">int</span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">Imath</span><span class="p">::</span><span class="n">V3f</span> <span class="n">v</span> <span class="p">(</span><span class="mf">3.0</span><span class="p">,</span> <span class="mf">4.0</span><span class="p">,</span> <span class="mf">5.0</span><span class="p">);</span> <span class="n">v</span><span class="o">.</span><span class="n">normalize</span><span class="p">();</span> <span class="n">Imath</span><span class="p">::</span><span class="n">M33f</span> <span class="n">M</span><span class="p">;</span> <span class="n">M</span><span class="o">.</span><span class="n">translate</span> <span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mf">3.0</span><span class="p">);</span> <span class="n">Imath</span><span class="p">::</span><span class="n">V3f</span> <span class="n">p</span> <span class="o">=</span> <span class="n">v</span> <span class="o">*</span> <span class="n">M</span><span class="p">;</span> <span class="n">std</span><span class="p">::</span><span class="n">cout</span> <span class="o"><<</span> <span class="s2">"What's your vector, Victor? "</span> <span class="o"><<</span> <span class="n">p</span> <span class="o"><<</span> <span class="n">std</span><span class="p">::</span><span class="n">endl</span><span class="p">;</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div> </div> </div> <div class="section" id="matrices-are-row-major"> <h2>Matrices Are Row-Major<a class="headerlink" href="#matrices-are-row-major" title="Permalink to this headline">¶</a></h2> <p>Imath stores matrices in row-major layout, originally inspired by compatibility with OpenGL matrices.</p> <p>A matrix described as:</p> <div class="math notranslate nohighlight"> \[\begin{split}\begin{bmatrix} m_{00} & m_{01} & m_{02} & m_{03} \\ m_{10} & m_{11} & m_{12} & m_{13} \\ m_{20} & m_{21} & m_{22} & m_{23} \\ m_{30} & m_{31} & m_{32} & m_{33} \\ \end{bmatrix}\end{split}\]</div> <p>is laid out in memory as:</p> <table class="colwidths-given docutils align-default"> <colgroup> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> <col style="width: 6%" /> </colgroup> <thead> <tr class="row-odd"><th class="head"><p>0</p></th> <th class="head"><p>1</p></th> <th class="head"><p>2</p></th> <th class="head"><p>3</p></th> <th class="head"><p>4</p></th> <th class="head"><p>5</p></th> <th class="head"><p>6</p></th> <th class="head"><p>7</p></th> <th class="head"><p>8</p></th> <th class="head"><p>9</p></th> <th class="head"><p>10</p></th> <th class="head"><p>11</p></th> <th class="head"><p>12</p></th> <th class="head"><p>13</p></th> <th class="head"><p>14</p></th> <th class="head"><p>15</p></th> </tr> </thead> <tbody> <tr class="row-even"><td><p><span class="math notranslate nohighlight">\(m_{00}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{01}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{02}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{03}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{10}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{11}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{12}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{13}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{20}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{21}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{22}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{23}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{30}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{31}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{32}\)</span></p></td> <td><p><span class="math notranslate nohighlight">\(m_{33}\)</span></p></td> </tr> </tbody> </table> <p>A matrix representing a homogeneous transform has a right-hand column of <span class="math notranslate nohighlight">\(\begin{bmatrix} 0 & 0 & 0 & 1\end{bmatrix}\)</span> and the translation component across the bottom row.</p> <p>As a result, it is best to think of Imath vectors as row-vectors, and vector-matrix multiplication with the vector on the left and matrix on the right:</p> <div class="math notranslate nohighlight"> \[\begin{split}\begin{bmatrix} v_{0}' & v_{1}' & v_{2}' & 1' \end{bmatrix} = \begin{bmatrix} v_{0} & v_{1} & v_{2} & 1 \end{bmatrix} \begin{bmatrix} m_{00} & m_{01} & m_{02} & 0 \\ m_{10} & m_{11} & m_{12} & 0 \\ m_{20} & m_{21} & m_{22} & 0 \\ m_{30} & m_{31} & m_{32} & 1 \end{bmatrix}\end{split}\]</div> <p>This further implies that you should interpret local transformations as pre-multiplication:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">M44f</span> <span class="n">M</span><span class="p">;</span> <span class="n">M</span><span class="o">.</span><span class="n">translate</span> <span class="p">(</span><span class="n">tx</span><span class="p">,</span> <span class="n">ty</span><span class="p">,</span> <span class="n">tz</span><span class="p">);</span> <span class="n">m</span><span class="o">.</span><span class="n">rotate</span> <span class="p">(</span><span class="n">r</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> <span class="n">m</span><span class="o">.</span><span class="n">scale</span> <span class="p">(</span><span class="n">s</span><span class="p">);</span> </pre></div> </div> <div class="math notranslate nohighlight"> \[\begin{split}\begin{bmatrix} m_{00} & m_{01} & m_{02} & m_{03} \\ m_{10} & m_{11} & m_{12} & m_{13} \\ m_{20} & m_{21} & m_{22} & m_{23} \\ m_{30} & m_{31} & m_{32} & m_{33} \\ \end{bmatrix} = \begin{bmatrix} s & 0 & 0 & 0 \\ 0 & s & 0 & 0 \\ 0 & 0 & s & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos(r) & \sin(r) & 0 \\ 0 & -\sin(r) & \cos(r) & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ tx & ty & tz & 1 \\ \end{bmatrix}\end{split}\]</div> </div> <div class="section" id="about"> <h2>About<a class="headerlink" href="#about" title="Permalink to this headline">¶</a></h2> <p>Imath originated at Industrial Light & Magic in the late 1990’s and early 2000’s, and it was originally distributed publicly as a component of <a class="reference external" href="https:://github.com/AcademySoftwareFoundation/openexr">OpenEXR</a>. Imath is now a project of the <a class="reference external" href="https://www.aswf.io">Academy Software Foundation</a> and is still maintained by the OpenEXR project.</p> <p>Imath is Version 3 because it was previously distributed as a component of OpenEXR v1 and v2.</p> </div> </div> <div class="clearer"></div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <p class="logo"><a href="index.html"> <img class="logo" src="_static/imath-logo-blue.png" alt="Logo"/> </a></p> <h3><a href="index.html">Table of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Overview</a><ul> <li><a class="reference internal" href="#example">Example</a></li> <li><a class="reference internal" href="#matrices-are-row-major">Matrices Are Row-Major</a></li> <li><a class="reference internal" href="#about">About</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="index.html" title="previous chapter">Imath Technical Documentation</a></p> <h4>Next topic</h4> <p class="topless"><a href="install.html" title="next chapter">Install Options</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/intro.rst.txt" rel="nofollow">Show Source</a></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>$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="install.html" title="Install Options" >next</a> |</li> <li class="right" > <a href="index.html" title="Imath Technical Documentation" >previous</a> |</li> <li class="nav-item nav-item-0"><a href="index.html">Imath</a> »</li> <li class="nav-item nav-item-this"><a href="">Overview</a></li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright 2021, Contributors to the OpenEXR Project. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.4.3. </div> </body> </html>