Files
phy/bevy_math/common_traits/trait.NormedVectorSpace.html
Orion Kindel 0ce894e6b0 doc
2025-03-18 10:30:23 -05:00

26 lines
13 KiB
HTML

<!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="A type that supports the operations of a normed vector space; i.e. a norm operation in addition to those of `VectorSpace`. Specifically, the implementor must guarantee that the following relationships hold, within the limitations of floating point arithmetic:"><title>NormedVectorSpace in bevy_math::common_traits - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="bevy_math" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://bevyengine.org/assets/icon.png"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../bevy_math/index.html"><img src="https://bevyengine.org/assets/icon.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../bevy_math/index.html"><img src="https://bevyengine.org/assets/icon.png" alt="logo"></a><h2><a href="../../bevy_math/index.html">bevy_<wbr>math</a><span class="version">0.15.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Normed<wbr>Vector<wbr>Space</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.norm" title="norm">norm</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.distance" title="distance">distance</a></li><li><a href="#method.distance_squared" title="distance_squared">distance_squared</a></li><li><a href="#method.norm_squared" title="norm_squared">norm_squared</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-NormedVectorSpace-for-f32" title="f32">f32</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In bevy_<wbr>math::<wbr>common_<wbr>traits</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">bevy_math</a>::<wbr><a href="index.html">common_traits</a></span><h1>Trait <span class="trait">NormedVectorSpace</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/bevy_math/common_traits.rs.html#84-107">Source</a> </span></div><pre class="rust item-decl"><code>pub trait NormedVectorSpace: <a class="trait" href="trait.VectorSpace.html" title="trait bevy_math::common_traits::VectorSpace">VectorSpace</a> {
// Required method
fn <a href="#tymethod.norm" class="fn">norm</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a>;
// Provided methods
fn <a href="#method.norm_squared" class="fn">norm_squared</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.distance" class="fn">distance</a>(self, rhs: Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.distance_squared" class="fn">distance_squared</a>(self, rhs: Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a> { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type that supports the operations of a normed vector space; i.e. a norm operation in addition
to those of <a href="trait.VectorSpace.html" title="trait bevy_math::common_traits::VectorSpace"><code>VectorSpace</code></a>. Specifically, the implementor must guarantee that the following
relationships hold, within the limitations of floating point arithmetic:</p>
<ul>
<li>(Nonnegativity) For all <code>v: Self</code>, <code>v.norm() &gt;= 0.0</code>.</li>
<li>(Positive definiteness) For all <code>v: Self</code>, <code>v.norm() == 0.0</code> implies <code>v == Self::ZERO</code>.</li>
<li>(Absolute homogeneity) For all <code>c: f32</code>, <code>v: Self</code>, <code>(v * c).norm() == v.norm() * c.abs()</code>.</li>
<li>(Triangle inequality) For all <code>v, w: Self</code>, <code>(v + w).norm() &lt;= v.norm() + w.norm()</code>.</li>
</ul>
<p>Note that, because implementing types use floating point arithmetic, they are not required to actually
implement <code>PartialEq</code> or <code>Eq</code>.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.norm" class="method"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#86">Source</a><h4 class="code-header">fn <a href="#tymethod.norm" class="fn">norm</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a></h4></section></summary><div class="docblock"><p>The size of this element. The return value should always be nonnegative.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.norm_squared" class="method"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#91-93">Source</a><h4 class="code-header">fn <a href="#method.norm_squared" class="fn">norm_squared</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a></h4></section></summary><div class="docblock"><p>The squared norm of this element. Computing this is often faster than computing
<a href="trait.NormedVectorSpace.html#tymethod.norm" title="method bevy_math::common_traits::NormedVectorSpace::norm"><code>NormedVectorSpace::norm</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.distance" class="method"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#97-99">Source</a><h4 class="code-header">fn <a href="#method.distance" class="fn">distance</a>(self, rhs: Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a></h4></section></summary><div class="docblock"><p>The distance between this element and another, as determined by the norm.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.distance_squared" class="method"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#104-106">Source</a><h4 class="code-header">fn <a href="#method.distance_squared" class="fn">distance_squared</a>(self, rhs: Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a></h4></section></summary><div class="docblock"><p>The squared distance between this element and another, as determined by the norm. Note that
this is often faster to compute in practice than <a href="trait.NormedVectorSpace.html#method.distance" title="method bevy_math::common_traits::NormedVectorSpace::distance"><code>NormedVectorSpace::distance</code></a>.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.0/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-NormedVectorSpace-for-f32" class="impl"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#157-167">Source</a><a href="#impl-NormedVectorSpace-for-f32" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.NormedVectorSpace.html" title="trait bevy_math::common_traits::NormedVectorSpace">NormedVectorSpace</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a></h3></section></summary><div class="impl-items"><section id="method.norm" class="method trait-impl"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#159-161">Source</a><a href="#method.norm" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.norm" class="fn">norm</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a></h4></section><section id="method.norm_squared-1" class="method trait-impl"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#164-166">Source</a><a href="#method.norm_squared-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.norm_squared" class="fn">norm_squared</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-NormedVectorSpace-for-Vec2" class="impl"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#145-155">Source</a><a href="#impl-NormedVectorSpace-for-Vec2" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.NormedVectorSpace.html" title="trait bevy_math::common_traits::NormedVectorSpace">NormedVectorSpace</a> for <a class="struct" href="../struct.Vec2.html" title="struct bevy_math::Vec2">Vec2</a></h3></section><section id="impl-NormedVectorSpace-for-Vec3" class="impl"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#121-131">Source</a><a href="#impl-NormedVectorSpace-for-Vec3" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.NormedVectorSpace.html" title="trait bevy_math::common_traits::NormedVectorSpace">NormedVectorSpace</a> for <a class="struct" href="../struct.Vec3.html" title="struct bevy_math::Vec3">Vec3</a></h3></section><section id="impl-NormedVectorSpace-for-Vec3A" class="impl"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#133-143">Source</a><a href="#impl-NormedVectorSpace-for-Vec3A" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.NormedVectorSpace.html" title="trait bevy_math::common_traits::NormedVectorSpace">NormedVectorSpace</a> for <a class="struct" href="../struct.Vec3A.html" title="struct bevy_math::Vec3A">Vec3A</a></h3></section><section id="impl-NormedVectorSpace-for-Vec4" class="impl"><a class="src rightside" href="../../src/bevy_math/common_traits.rs.html#109-119">Source</a><a href="#impl-NormedVectorSpace-for-Vec4" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.NormedVectorSpace.html" title="trait bevy_math::common_traits::NormedVectorSpace">NormedVectorSpace</a> for <a class="struct" href="../struct.Vec4.html" title="struct bevy_math::Vec4">Vec4</a></h3></section></div><script src="../../trait.impl/bevy_math/common_traits/trait.NormedVectorSpace.js" data-ignore-extern-crates="glam,std" async></script></section></div></main></body></html>