You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Trac3r-rust/doc/nalgebra/index.html

126 lines
23 KiB

5 years ago
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `nalgebra` crate."><meta name="keywords" content="rust, rustlang, rust-lang, nalgebra"><title>nalgebra - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="http://nalgebra.org/img/favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../nalgebra/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Crate nalgebra</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all nalgebra's items</p></a><div class="block items"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'nalgebra', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/nalgebra/lib.rs.html#1-728' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>nalgebra</a></span></h1><div class='docblock'><h1 id="nalgebra" class="section-header"><a href="#nalgebra">nalgebra</a></h1>
<p><strong>nalgebra</strong> is a linear algebra library written for Rust targeting:</p>
<ul>
<li>General-purpose linear algebra (still lacks a lot of features…)</li>
<li>RealField time computer graphics.</li>
<li>RealField time computer physics.</li>
</ul>
<h2 id="using-nalgebra" class="section-header"><a href="#using-nalgebra">Using <strong>nalgebra</strong></a></h2>
<p>You will need the last stable build of the <a href="http://www.rust-lang.org">rust compiler</a>
and the official package manager: <a href="https://github.com/rust-lang/cargo">cargo</a>.</p>
<p>Simply add the following to your <code>Cargo.toml</code> file:</p>
<div class='information'><div class='tooltip ignore'><span class='tooltiptext'>This example is not tested</span></div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore">
[<span class="ident">dependencies</span>]
<span class="ident">nalgebra</span> <span class="op">=</span> <span class="string">&quot;0.18&quot;</span></pre></div>
<p>Most useful functionalities of <strong>nalgebra</strong> are grouped in the root module <code>nalgebra::</code>.</p>
<p>However, the recommended way to use <strong>nalgebra</strong> is to import types and traits
explicitly, and call free-functions using the <code>na::</code> prefix:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#[<span class="ident">macro_use</span>]</span>
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">approx</span>; <span class="comment">// For the macro relative_eq!</span>
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">nalgebra</span> <span class="kw">as</span> <span class="ident">na</span>;
<span class="kw">use</span> <span class="ident">na</span>::{<span class="ident">Vector3</span>, <span class="ident">Rotation3</span>};
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="kw">let</span> <span class="ident">axis</span> <span class="op">=</span> <span class="ident">Vector3</span>::<span class="ident">x_axis</span>();
<span class="kw">let</span> <span class="ident">angle</span> <span class="op">=</span> <span class="number">1.57</span>;
<span class="kw">let</span> <span class="ident">b</span> <span class="op">=</span> <span class="ident">Rotation3</span>::<span class="ident">from_axis_angle</span>(<span class="kw-2">&amp;</span><span class="ident">axis</span>, <span class="ident">angle</span>);
<span class="macro">relative_eq</span><span class="macro">!</span>(<span class="ident">b</span>.<span class="ident">axis</span>().<span class="ident">unwrap</span>(), <span class="ident">axis</span>);
<span class="macro">relative_eq</span><span class="macro">!</span>(<span class="ident">b</span>.<span class="ident">angle</span>(), <span class="ident">angle</span>);
}</pre></div>
<h2 id="features" class="section-header"><a href="#features">Features</a></h2>
<p><strong>nalgebra</strong> is meant to be a general-purpose, low-dimensional, linear algebra library, with
an optimized set of tools for computer graphics and physics. Those features include:</p>
<ul>
<li>A single parametrizable type <code>Matrix</code> for vectors, (square or rectangular) matrices, and slices
with dimensions known either at compile-time (using type-level integers) or at runtime.</li>
<li>Matrices and vectors with compile-time sizes are statically allocated while dynamic ones are
allocated on the heap.</li>
<li>Convenient aliases for low-dimensional matrices and vectors: <code>Vector1</code> to <code>Vector6</code> and
<code>Matrix1x1</code> to <code>Matrix6x6</code>, including rectangular matrices like <code>Matrix2x5</code>.</li>
<li>Points sizes known at compile time, and convenience aliases:: <code>Point1</code> to <code>Point6</code>.</li>
<li>Translation (seen as a transformation that composes by multiplication): <code>Translation2</code>,
<code>Translation3</code>.</li>
<li>Rotation matrices: <code>Rotation2</code>, <code>Rotation3</code>.</li>
<li>Quaternions: <code>Quaternion</code>, <code>UnitQuaternion</code> (for 3D rotation).</li>
<li>Unit complex numbers can be used for 2D rotation: <code>UnitComplex</code>.</li>
<li>Algebraic entities with a norm equal to one: <code>Unit&lt;T&gt;</code>, e.g., <code>Unit&lt;Vector3&lt;f32&gt;&gt;</code>.</li>
<li>Isometries (translation rotation): <code>Isometry2</code>, <code>Isometry3</code></li>
<li>Similarity transformations (translation rotation uniform scale): <code>Similarity2</code>, <code>Similarity3</code>.</li>
<li>Affine transformations stored as an homogeneous matrix: <code>Affine2</code>, <code>Affine3</code>.</li>
<li>Projective (i.e. invertible) transformations stored as an homogeneous matrix: <code>Projective2</code>,
<code>Projective3</code>.</li>
<li>General transformations that does not have to be invertible, stored as an homogeneous matrix:
<code>Transform2</code>, <code>Transform3</code>.</li>
<li>3D projections for computer graphics: <code>Perspective3</code>, <code>Orthographic3</code>.</li>
<li>Matrix factorizations: <code>Cholesky</code>, <code>QR</code>, <code>LU</code>, <code>FullPivLU</code>, <code>SVD</code>, <code>Schur</code>, <code>Hessenberg</code>, <code>SymmetricEigen</code>.</li>
<li>Insertion and removal of rows of columns of a matrix.</li>
<li>Implements traits from the <a href="https://crates.io/crates/alga">alga</a> crate for
generic programming.</li>
</ul>
</div><h2 id='reexports' class='section-header'><a href="#reexports">Re-exports</a></h2>
<table><tr><td><code>pub use <a class="mod" href="../nalgebra/base/index.html" title="mod nalgebra::base">base</a> as core;</code></td></tr><tr><td><code>pub use crate::<a class="mod" href="../nalgebra/base/index.html" title="mod nalgebra::base">base</a>::*;</code></td></tr><tr><td><code>pub use crate::<a class="mod" href="../nalgebra/geometry/index.html" title="mod nalgebra::geometry">geometry</a>::*;</code></td></tr><tr><td><code>pub use crate::<a class="mod" href="../nalgebra/linalg/index.html" title="mod nalgebra::linalg">linalg</a>::*;</code></td></tr></table><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
<table><tr class='module-item'><td><a class="mod" href="base/index.html" title='nalgebra::base mod'>base</a></td><td class='docblock-short'><p>[Reexported at the root of this crate.] Data structures for vector and matrix computations.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="geometry/index.html" title='nalgebra::geometry mod'>geometry</a></td><td class='docblock-short'><p>[Reexported at the root of this crate.] Data structures for points and usual transformations
(rotations, isometries, etc.)</p>
</td></tr><tr class='module-item'><td><a class="mod" href="linalg/index.html" title='nalgebra::linalg mod'>linalg</a></td><td class='docblock-short'><p>[Reexported at the root of this crate.] Factorization of real matrices.</p>
</td></tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.Complex.html" title='nalgebra::Complex struct'>Complex</a></td><td class='docblock-short'><p>A complex number in Cartesian form.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Id.html" title='nalgebra::Id struct'>Id</a></td><td class='docblock-short'><p>The universal identity element wrt. a given operator, usually noted <code>Id</code> with a
context-dependent subscript.</p>
</td></tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table><tr class='module-item'><td><a class="trait" href="trait.ComplexField.html" title='nalgebra::ComplexField trait'>ComplexField</a></td><td class='docblock-short'><p>Trait shared by all complex fields and its subfields (like real numbers).</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Real.html" title='nalgebra::Real trait'>Real</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>The field of reals. This has been renamed to <code>RealField</code>.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.RealField.html" title='nalgebra::RealField trait'>RealField</a></td><td class='docblock-short'><p>Trait shared by all reals.</p>
</td></tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table><tr class='module-item'><td><a class="fn" href="fn.abs.html" title='nalgebra::abs fn'>abs</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>The absolute value of <code>a</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.angle.html" title='nalgebra::angle fn'>angle</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Computes the smallest angle between two vectors.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.center.html" title='nalgebra::center fn'>center</a></td><td class='docblock-short'><p>The center of two points.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.clamp.html" title='nalgebra::clamp fn'>clamp</a></td><td class='docblock-short'><p>Returns a reference to the input value clamped to the interval <code>[min, max]</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.convert.html" title='nalgebra::convert fn'>convert</a></td><td class='docblock-short'><p>Converts an object from one type to an equivalent or more general one.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.convert_ref.html" title='nalgebra::convert_ref fn'>convert_ref</a></td><td class='docblock-short'><p>Converts an object from one type to an equivalent or more general one.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.convert_ref_unchecked.html" title='nalgebra::convert_ref_unchecked fn'>convert_ref_unchecked</a><a title='unsafe function' href='#'><sup></sup></a></td><td class='docblock-short'><p>Use with care! Same as <a href="fn.try_convert.html"><code>try_convert</code></a> but
without any property checks.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.convert_unchecked.html" title='nalgebra::convert_unchecked fn'>convert_unchecked</a><a title='unsafe function' href='#'><sup></sup></a></td><td class='docblock-short'><p>Use with care! Same as <a href="fn.try_convert.html"><code>try_convert</code></a> but
without any property checks.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.dimension.html" title='nalgebra::dimension fn'>dimension</a></td><td class='docblock-short'><p>The dimension of the given algebraic entity seen as a vector space.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.distance.html" title='nalgebra::distance fn'>distance</a></td><td class='docblock-short'><p>The distance between two points.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.distance_squared.html" title='nalgebra::distance_squared fn'>distance_squared</a></td><td class='docblock-short'><p>The squared distance between two points.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.dot.html" title='nalgebra::dot fn'>dot</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Computes the dot product of two vectors.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.id.html" title='nalgebra::id fn'>id</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Gets the ubiquitous multiplicative identity element.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.inf.html" title='nalgebra::inf fn'>inf</a></td><td class='docblock-short'><p>Returns the infimum of <code>a</code> and <code>b</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.inf_sup.html" title='nalgebra::inf_sup fn'>inf_sup</a></td><td class='docblock-short'><p>Returns simultaneously the infimum and supremum of <code>a</code> and <code>b</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.inverse.html" title='nalgebra::inverse fn'>inverse</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Computes the multiplicative inverse of an (always invertible) algebraic entity.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.is_convertible.html" title='nalgebra::is_convertible fn'>is_convertible</a></td><td class='docblock-short'><p>Indicates if <a href="fn.try_convert.html"><code>try_convert</code></a> will succeed without
actually performing the conversion.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.magnitude.html" title='nalgebra::magnitude fn'>magnitude</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>A synonym for <a href="fn.norm.html"><code>norm</code></a>, aka length.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.magnitude_squared.html" title='nalgebra::magnitude_squared fn'>magnitude_squared</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>A synonym for <a href="fn.norm_squared.html"><code>norm_squared</code></a>,
aka length squared.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.max.html" title='nalgebra::max fn'>max</a></td><td class='docblock-short'><p>Same as <code>cmp::max</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.min.html" title='nalgebra::min fn'>min</a></td><td class='docblock-short'><p>Same as <code>cmp::min</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.norm.html" title='nalgebra::norm fn'>norm</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Computes the L2 (Euclidean) norm of a vector.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.norm_squared.html" title='nalgebra::norm_squared fn'>norm_squared</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Computes the squared L2 (Euclidean) norm of the vector <code>v</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.normalize.html" title='nalgebra::normalize fn'>normalize</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Computes the normalized version of the vector <code>v</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.one.html" title='nalgebra::one fn'>one</a></td><td class='docblock-short'><p>Gets the multiplicative identity element.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.origin.html" title='nalgebra::origin fn'>origin</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Gets the origin of the given point.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partial_clamp.html" title='nalgebra::partial_clamp fn'>partial_clamp</a></td><td class='docblock-short'><p>Clamp <code>value</code> between <code>min</code> and <code>max</code>. Returns <code>None</code> if <code>value</code> is not comparable to
<code>min</code> or <code>max</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partial_cmp.html" title='nalgebra::partial_cmp fn'>partial_cmp</a></td><td class='docblock-short'><p>Compare <code>a</code> and <code>b</code> using a partial ordering relation.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partial_ge.html" title='nalgebra::partial_ge fn'>partial_ge</a></td><td class='docblock-short'><p>Returns <code>true</code> iff <code>a</code> and <code>b</code> are comparable and <code>a &gt;= b</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partial_gt.html" title='nalgebra::partial_gt fn'>partial_gt</a></td><td class='docblock-short'><p>Returns <code>true</code> iff <code>a</code> and <code>b</code> are comparable and <code>a &gt; b</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partial_le.html" title='nalgebra::partial_le fn'>partial_le</a></td><td class='docblock-short'><p>Returns <code>true</code> iff <code>a</code> and <code>b</code> are comparable and <code>a &lt;= b</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partial_lt.html" title='nalgebra::partial_lt fn'>partial_lt</a></td><td class='docblock-short'><p>Returns <code>true</code> iff <code>a</code> and <code>b</code> are comparable and <code>a &lt; b</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partial_max.html" title='nalgebra::partial_max fn'>partial_max</a></td><td class='docblock-short'><p>Return the maximum of <code>a</code> and <code>b</code> if they are comparable.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partial_min.html" title='nalgebra::partial_min fn'>partial_min</a></td><td class='docblock-short'><p>Return the minimum of <code>a</code> and <code>b</code> if they are comparable.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partial_sort2.html" title='nalgebra::partial_sort2 fn'>partial_sort2</a></td><td class='docblock-short'><p>Sorts two values in increasing order using a partial ordering.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.sup.html" title='nalgebra::sup fn'>sup</a></td><td class='docblock-short'><p>Returns the supremum of <code>a</code> and <code>b</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.try_convert.html" title='nalgebra::try_convert fn'>try_convert</a></td><td class='docblock-short'><p>Attempts to convert an object to a more specific one.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.try_convert_ref.html" title='nalgebra::try_convert_ref fn'>try_convert_ref</a></td><td class='docblock-short'><p>Attempts to convert an object to a more specific one.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.try_inverse.html" title='nalgebra::try_inverse fn'>try_inverse</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Tries to gets an inverted copy of a square matrix.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.try_normalize.html" title='nalgebra::try_normalize fn'>try_normalize</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Computes the normalized version of the vector <code>v</code> or returns <code>None</code> if its norm is smaller than <code>min_norm</code>.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.wrap.html" title='nalgebra::wrap fn'>wrap</a></td><td class='docblock-short'><p>Wraps <code>val</code> into the range <code>[min, max]</code> using modular arithmetics.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.zero.html" title='nalgebra::zero fn'>zero</a></td><td class='docblock-short'><p>Gets the additive identity element.</p>
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "nalgebra";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>