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/cgmath/index.html

123 lines
22 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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 `cgmath` crate."><meta name="keywords" content="rust, rustlang, rust-lang, cgmath"><title>cgmath - 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="../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='../cgmath/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Crate cgmath</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all cgmath'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="#macros">Macros</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: 'cgmath', 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/cgmath/lib.rs.html#16-109' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>cgmath</a></span></h1><div class='docblock'><p>A low-dimensional linear algebra library, targeted at computer graphics.</p>
<h1 id="trait-overview" class="section-header"><a href="#trait-overview">Trait overview</a></h1>
<p>In order to make a clean, composable API, we divide operations into traits
that are roughly based on mathematical properties. The main ones that we
concern ourselves with are listed below:</p>
<ul>
<li><code>VectorSpace</code>: Specifies the main operators for vectors, quaternions, and
matrices.</li>
<li><code>MetricSpace</code>: For types that have a distance function implemented.</li>
<li><code>InnerSpace</code>: For types that have a dot (or inner) product - ie. vectors or
quaternions. This also allows for the definition of operations that are
based on the dot product, like finding the magnitude or normalizing.</li>
<li><code>EuclideanSpace</code>: Points in euclidean space, with an associated space of
displacement vectors.</li>
<li><code>Matrix</code>: Common operations for matrices of arbitrary dimensions.</li>
<li><code>SquareMatrix</code>: A special trait for matrices where the number of columns
equal the number of rows.</li>
</ul>
<p>Other traits are included for practical convenience, for example:</p>
<ul>
<li><code>Array</code>: For contiguous, indexable arrays of elements, specifically
vectors.</li>
<li><code>ElementWise</code>: For element-wise addition, subtraction, multiplication,
division, and remainder operations.</li>
</ul>
<h1 id="the-prelude" class="section-header"><a href="#the-prelude">The prelude</a></h1>
<p>Importing each trait individually can become a chore, so we provide a
<code>prelude</code> module to allow you to import the main trait all at once. For
example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">cgmath</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>;</pre></div>
</div><h2 id='reexports' class='section-header'><a href="#reexports">Re-exports</a></h2>
<table><tr><td><code>pub extern crate <a class="mod" href="../num_traits/index.html" title="mod num_traits">num_traits</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="conv/index.html" title='cgmath::conv mod'>conv</a></td><td class='docblock-short'><p>Constrained conversion functions for assisting in situations where type
inference is difficult.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="prelude/index.html" title='cgmath::prelude mod'>prelude</a></td><td class='docblock-short'><p>This module contains the most common traits used in <code>cgmath</code>. By
glob-importing this module, you can avoid the need to import each trait
individually, while still being selective about what types you import.</p>
</td></tr></table><h2 id='macros' class='section-header'><a href="#macros">Macros</a></h2>
<table><tr class='module-item'><td><a class="macro" href="macro.abs_diff_eq.html" title='cgmath::abs_diff_eq macro'>abs_diff_eq</a></td><td class='docblock-short'><p>Approximate equality of using the absolute difference.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.abs_diff_ne.html" title='cgmath::abs_diff_ne macro'>abs_diff_ne</a></td><td class='docblock-short'><p>Approximate inequality of using the absolute difference.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.assert_abs_diff_eq.html" title='cgmath::assert_abs_diff_eq macro'>assert_abs_diff_eq</a></td><td class='docblock-short'><p>An assertion that delegates to <code>abs_diff_eq!</code>, and panics with a helpful error on failure.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.assert_abs_diff_ne.html" title='cgmath::assert_abs_diff_ne macro'>assert_abs_diff_ne</a></td><td class='docblock-short'><p>An assertion that delegates to <code>abs_diff_ne!</code>, and panics with a helpful error on failure.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.assert_relative_eq.html" title='cgmath::assert_relative_eq macro'>assert_relative_eq</a></td><td class='docblock-short'><p>An assertion that delegates to <code>relative_eq!</code>, and panics with a helpful error on failure.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.assert_relative_ne.html" title='cgmath::assert_relative_ne macro'>assert_relative_ne</a></td><td class='docblock-short'><p>An assertion that delegates to <code>relative_ne!</code>, and panics with a helpful error on failure.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.assert_ulps_eq.html" title='cgmath::assert_ulps_eq macro'>assert_ulps_eq</a></td><td class='docblock-short'><p>An assertion that delegates to <code>ulps_eq!</code>, and panics with a helpful error on failure.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.assert_ulps_ne.html" title='cgmath::assert_ulps_ne macro'>assert_ulps_ne</a></td><td class='docblock-short'><p>An assertion that delegates to <code>ulps_ne!</code>, and panics with a helpful error on failure.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.relative_eq.html" title='cgmath::relative_eq macro'>relative_eq</a></td><td class='docblock-short'><p>Approximate equality using both the absolute difference and relative based comparisons.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.relative_ne.html" title='cgmath::relative_ne macro'>relative_ne</a></td><td class='docblock-short'><p>Approximate inequality using both the absolute difference and relative based comparisons.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.ulps_eq.html" title='cgmath::ulps_eq macro'>ulps_eq</a></td><td class='docblock-short'><p>Approximate equality using both the absolute difference and ULPs (Units in Last Place).</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.ulps_ne.html" title='cgmath::ulps_ne macro'>ulps_ne</a></td><td class='docblock-short'><p>Approximate inequality using both the absolute difference and ULPs (Units in Last Place).</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.AbsDiff.html" title='cgmath::AbsDiff struct'>AbsDiff</a></td><td class='docblock-short'><p>The requisite parameters for testing for approximate equality using a
absolute difference based comparison.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Basis2.html" title='cgmath::Basis2 struct'>Basis2</a></td><td class='docblock-short'><p>A two-dimensional rotation matrix.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Basis3.html" title='cgmath::Basis3 struct'>Basis3</a></td><td class='docblock-short'><p>A three-dimensional rotation matrix.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Decomposed.html" title='cgmath::Decomposed struct'>Decomposed</a></td><td class='docblock-short'><p>A generic transformation consisting of a rotation,
displacement vector and scale amount.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Deg.html" title='cgmath::Deg struct'>Deg</a></td><td class='docblock-short'><p>An angle, in degrees.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Euler.html" title='cgmath::Euler struct'>Euler</a></td><td class='docblock-short'><p>A set of <a href="https://en.wikipedia.org/wiki/Euler_angles">Euler angles</a> representing a rotation in three-dimensional space.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Matrix2.html" title='cgmath::Matrix2 struct'>Matrix2</a></td><td class='docblock-short'><p>A 2 x 2, column major matrix</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Matrix3.html" title='cgmath::Matrix3 struct'>Matrix3</a></td><td class='docblock-short'><p>A 3 x 3, column major matrix</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Matrix4.html" title='cgmath::Matrix4 struct'>Matrix4</a></td><td class='docblock-short'><p>A 4 x 4, column major matrix</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Ortho.html" title='cgmath::Ortho struct'>Ortho</a></td><td class='docblock-short'><p>An orthographic projection with arbitrary left/right/bottom/top distances</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Perspective.html" title='cgmath::Perspective struct'>Perspective</a></td><td class='docblock-short'><p>A perspective projection with arbitrary left/right/bottom/top distances</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.PerspectiveFov.html" title='cgmath::PerspectiveFov struct'>PerspectiveFov</a></td><td class='docblock-short'><p>A perspective projection based on a vertical field-of-view angle.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Point1.html" title='cgmath::Point1 struct'>Point1</a></td><td class='docblock-short'><p>A point in 1-dimensional space.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Point2.html" title='cgmath::Point2 struct'>Point2</a></td><td class='docblock-short'><p>A point in 2-dimensional space.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Point3.html" title='cgmath::Point3 struct'>Point3</a></td><td class='docblock-short'><p>A point in 3-dimensional space.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Quaternion.html" title='cgmath::Quaternion struct'>Quaternion</a></td><td class='docblock-short'><p>A <a href="https://en.wikipedia.org/wiki/Quaternion">quaternion</a> in scalar/vector
form.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Rad.html" title='cgmath::Rad struct'>Rad</a></td><td class='docblock-short'><p>An angle, in radians.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Relative.html" title='cgmath::Relative struct'>Relative</a></td><td class='docblock-short'><p>The requisite parameters for testing for approximate equality using a
relative based comparison.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Ulps.html" title='cgmath::Ulps struct'>Ulps</a></td><td class='docblock-short'><p>The requisite parameters for testing for approximate equality using an ULPs
based comparison.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Vector1.html" title='cgmath::Vector1 struct'>Vector1</a></td><td class='docblock-short'><p>A 1-dimensional vector.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Vector2.html" title='cgmath::Vector2 struct'>Vector2</a></td><td class='docblock-short'><p>A 2-dimensional vector.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Vector3.html" title='cgmath::Vector3 struct'>Vector3</a></td><td class='docblock-short'><p>A 3-dimensional vector.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Vector4.html" title='cgmath::Vector4 struct'>Vector4</a></td><td class='docblock-short'><p>A 4-dimensional vector.</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.AbsDiffEq.html" title='cgmath::AbsDiffEq trait'>AbsDiffEq</a></td><td class='docblock-short'><p>Equality that is defined using the absolute difference of two numbers.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Angle.html" title='cgmath::Angle trait'>Angle</a></td><td class='docblock-short'><p>Angles and their associated trigonometric functions.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Array.html" title='cgmath::Array trait'>Array</a></td><td class='docblock-short'><p>An array containing elements of type <code>Element</code></p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.BaseFloat.html" title='cgmath::BaseFloat trait'>BaseFloat</a></td><td class='docblock-short'><p>Base floating point types</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.BaseNum.html" title='cgmath::BaseNum trait'>BaseNum</a></td><td class='docblock-short'><p>Base numeric types with partial ordering</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Bounded.html" title='cgmath::Bounded trait'>Bounded</a></td><td class='docblock-short'><p>Numbers which have upper and lower bounds</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.ElementWise.html" title='cgmath::ElementWise trait'>ElementWise</a></td><td class='docblock-short'><p>Element-wise arithmetic operations. These are supplied for pragmatic
reasons, but will usually fall outside of traditional algebraic properties.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.EuclideanSpace.html" title='cgmath::EuclideanSpace trait'>EuclideanSpace</a></td><td class='docblock-short'><p>Points in a <a href="https://en.wikipedia.org/wiki/Euclidean_space">Euclidean space</a>
with an associated space of displacement vectors.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.InnerSpace.html" title='cgmath::InnerSpace trait'>InnerSpace</a></td><td class='docblock-short'><p>Vectors that also have a <a href="https://en.wikipedia.org/wiki/Dot_product">dot</a>
(or <a href="https://en.wikipedia.org/wiki/Inner_product_space">inner</a>) product.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Matrix.html" title='cgmath::Matrix trait'>Matrix</a></td><td class='docblock-short'><p>A column-major matrix of arbitrary dimensions.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.MetricSpace.html" title='cgmath::MetricSpace trait'>MetricSpace</a></td><td class='docblock-short'><p>A type with a distance function between values.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.One.html" title='cgmath::One trait'>One</a></td><td class='docblock-short'><p>Defines a multiplicative identity element for <code>Self</code>.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.RelativeEq.html" title='cgmath::RelativeEq trait'>RelativeEq</a></td><td class='docblock-short'><p>Equality comparisons between two numbers using both the absolute difference and
relative based comparisons.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Rotation.html" title='cgmath::Rotation trait'>Rotation</a></td><td class='docblock-short'><p>A trait for a generic rotation. A rotation is a transformation that
creates a circular motion, and preserves at least one point in the space.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Rotation2.html" title='cgmath::Rotation2 trait'>Rotation2</a></td><td class='docblock-short'><p>A two-dimensional rotation.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Rotation3.html" title='cgmath::Rotation3 trait'>Rotation3</a></td><td class='docblock-short'><p>A three-dimensional rotation.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.SquareMatrix.html" title='cgmath::SquareMatrix trait'>SquareMatrix</a></td><td class='docblock-short'><p>A column-major major matrix where the rows and column vectors are of the same dimensions.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Transform.html" title='cgmath::Transform trait'>Transform</a></td><td class='docblock-short'><p>A trait representing an <a href="https://en.wikipedia.org/wiki/Affine_transformation">affine
transformation</a> that
can be applied to points or vectors. An affine transformation is one which</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Transform2.html" title='cgmath::Transform2 trait'>Transform2</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="trait" href="trait.Transform3.html" title='cgmath::Transform3 trait'>Transform3</a></td><td class='docblock-short'></td></tr><tr class='module-item'><td><a class="trait" href="trait.UlpsEq.html" title='cgmath::UlpsEq trait'>UlpsEq</a></td><td class='docblock-short'><p>Equality comparisons between two numbers using both the absolute difference and ULPs
(Units in Last Place) based comparisons.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.VectorSpace.html" title='cgmath::VectorSpace trait'>VectorSpace</a></td><td class='docblock-short'><p>Vectors that can be <a href="http://mathworld.wolfram.com/VectorAddition.html">added</a>
together and <a href="https://en.wikipedia.org/wiki/Scalar_multiplication">multiplied</a>
by scalars.</p>
</td></tr><tr class='module-item'><td><a class="trait" href="trait.Zero.html" title='cgmath::Zero trait'>Zero</a></td><td class='docblock-short'><p>Defines an additive identity element for <code>Self</code>.</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.dot.html" title='cgmath::dot fn'>dot</a></td><td class='docblock-short'><p>Dot product of two vectors.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.frustum.html" title='cgmath::frustum fn'>frustum</a></td><td class='docblock-short'><p>Create a perspective matrix from a view frustum.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.ortho.html" title='cgmath::ortho fn'>ortho</a></td><td class='docblock-short'><p>Create an orthographic projection matrix.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.perspective.html" title='cgmath::perspective fn'>perspective</a></td><td class='docblock-short'><p>Create a perspective projection matrix.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.vec1.html" title='cgmath::vec1 fn'>vec1</a></td><td class='docblock-short'><p>The short constructor.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.vec2.html" title='cgmath::vec2 fn'>vec2</a></td><td class='docblock-short'><p>The short constructor.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.vec3.html" title='cgmath::vec3 fn'>vec3</a></td><td class='docblock-short'><p>The short constructor.</p>
</td></tr><tr class='module-item'><td><a class="fn" href="fn.vec4.html" title='cgmath::vec4 fn'>vec4</a></td><td class='docblock-short'><p>The short constructor.</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 = "cgmath";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>