mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-31 17:22:27 +08:00
Documentation for 341ed50da8
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.9.1"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.2"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: math/vector_cross_product.cpp File Reference</title>
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -17,9 +17,9 @@
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="../../search/search.js"></script>
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
|
||||
jax: ["input/TeX","output/HTML-CSS"],
|
||||
MathJax.Hub.Config({
|
||||
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
|
||||
jax: ["input/TeX","output/HTML-CSS"],
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
|
||||
@@ -32,8 +32,7 @@
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">Algorithms_in_C++
|
||||
 <span id="projectnumber">1.0.0</span>
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
</td>
|
||||
@@ -42,21 +41,22 @@
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.1 -->
|
||||
<!-- Generated by Doxygen 1.9.2 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||||
var searchBox = new SearchBox("searchBox", "../../search",false,'Search','.html');
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript" src="../../menudata.js"></script>
|
||||
<script type="text/javascript" src="../../menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() {
|
||||
initMenu('../../',true,false,'search.php','Search');
|
||||
$(document).ready(function() { init_search(); });
|
||||
});
|
||||
/* @license-end */</script>
|
||||
/* @license-end */
|
||||
</script>
|
||||
<div id="main-nav"></div>
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
@@ -70,7 +70,7 @@ $(function() {
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(document).ready(function(){initNavTree('df/d66/vector__cross__product_8cpp.html','../../'); initResizable(); });
|
||||
/* @license-end */
|
||||
</script>
|
||||
@@ -93,12 +93,11 @@ $(document).ready(function(){initNavTree('df/d66/vector__cross__product_8cpp.htm
|
||||
<div class="summary">
|
||||
<a href="#namespaces">Namespaces</a> |
|
||||
<a href="#func-members">Functions</a> </div>
|
||||
<div class="headertitle">
|
||||
<div class="title">vector_cross_product.cpp File Reference</div> </div>
|
||||
<div class="headertitle"><div class="title">vector_cross_product.cpp File Reference</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
|
||||
<p>Calculates the <a href="https://en.wikipedia.org/wiki/Cross_product">Cross Product</a> and the magnitude of two mathematical 3D vectors.
|
||||
<p>Calculates the <a href="https://en.wikipedia.org/wiki/Cross_product" target="_blank">Cross Product</a> and the magnitude of two mathematical 3D vectors.
|
||||
<a href="#details">More...</a></p>
|
||||
<div class="textblock"><code>#include <iostream></code><br />
|
||||
<code>#include <array></code><br />
|
||||
@@ -111,20 +110,20 @@ Include dependency graph for vector_cross_product.cpp:</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="namespaces"></a>
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
|
||||
Namespaces</h2></td></tr>
|
||||
<tr class="memitem:dd/d47/namespacemath"><td class="memItemLeft" align="right" valign="top">  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d47/namespacemath.html">math</a></td></tr>
|
||||
<tr class="memitem:dd/d47/namespacemath"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d47/namespacemath.html">math</a></td></tr>
|
||||
<tr class="memdesc:dd/d47/namespacemath"><td class="mdescLeft"> </td><td class="mdescRight">for IO operations <br /></td></tr>
|
||||
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:d4/d91/namespacevector__cross"><td class="memItemLeft" align="right" valign="top">  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d91/namespacevector__cross.html">vector_cross</a></td></tr>
|
||||
<tr class="memitem:d4/d91/namespacevector__cross"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d91/namespacevector__cross.html">vector_cross</a></td></tr>
|
||||
<tr class="memdesc:d4/d91/namespacevector__cross"><td class="mdescLeft"> </td><td class="mdescRight">Functions for Vector Cross Product algorithms. <br /></td></tr>
|
||||
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table><table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></td></tr>
|
||||
<tr class="memitem:abed307975124243d63fe2e118254defe"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< double, 3 > </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d66/vector__cross__product_8cpp.html#abed307975124243d63fe2e118254defe">math::vector_cross::cross</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< double, 3 > &A, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< double, 3 > &B)</td></tr>
|
||||
<tr class="memdesc:abed307975124243d63fe2e118254defe"><td class="mdescLeft"> </td><td class="mdescRight">Function to calculate the cross product of the passed arrays containing the direction ratios of the two mathematical vectors. <a href="../../df/d66/vector__cross__product_8cpp.html#abed307975124243d63fe2e118254defe">More...</a><br /></td></tr>
|
||||
<tr class="separator:abed307975124243d63fe2e118254defe"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a225732399c5c076976eae5b180a9f8c9"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< double, 3 > </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d66/vector__cross__product_8cpp.html#a225732399c5c076976eae5b180a9f8c9">math::vector_cross::cross</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< double, 3 > &A, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< double, 3 > &B)</td></tr>
|
||||
<tr class="memdesc:a225732399c5c076976eae5b180a9f8c9"><td class="mdescLeft"> </td><td class="mdescRight">Function to calculate the cross product of the passed arrays containing the direction ratios of the two mathematical vectors. <a href="../../df/d66/vector__cross__product_8cpp.html#a225732399c5c076976eae5b180a9f8c9">More...</a><br /></td></tr>
|
||||
<tr class="separator:a225732399c5c076976eae5b180a9f8c9"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a4b2a9757a87c18e1642d72410ecfaba8"><td class="memItemLeft" align="right" valign="top">double </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8">math::vector_cross::mag</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< double, 3 > &vec)</td></tr>
|
||||
<tr class="memdesc:a4b2a9757a87c18e1642d72410ecfaba8"><td class="mdescLeft"> </td><td class="mdescRight">Calculates the magnitude of the mathematical vector from it's direction ratios. <a href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8">More...</a><br /></td></tr>
|
||||
<tr class="separator:a4b2a9757a87c18e1642d72410ecfaba8"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
@@ -136,29 +135,29 @@ Functions</h2></td></tr>
|
||||
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>Calculates the <a href="https://en.wikipedia.org/wiki/Cross_product">Cross Product</a> and the magnitude of two mathematical 3D vectors. </p>
|
||||
<p>Cross Product of two vectors gives a vector. Direction Ratios of a vector are the numeric parts of the given vector. They are the tree parts of the vector which determine the magnitude (value) of the vector. The method of finding a cross product is the same as finding the determinant of an order 3 matrix consisting of the first row with unit vectors of magnitude 1, the second row with the direction ratios of the first vector and the third row with the direction ratios of the second vector. The magnitude of a vector is it's value expressed as a number. Let the direction ratios of the first vector, P be: a, b, c Let the direction ratios of the second vector, Q be: x, y, z Therefore the calculation for the cross product can be arranged as:</p>
|
||||
<div class="textblock"><p >Calculates the <a href="https://en.wikipedia.org/wiki/Cross_product" target="_blank">Cross Product</a> and the magnitude of two mathematical 3D vectors. </p>
|
||||
<p >Cross Product of two vectors gives a vector. Direction Ratios of a vector are the numeric parts of the given vector. They are the tree parts of the vector which determine the magnitude (value) of the vector. The method of finding a cross product is the same as finding the determinant of an order 3 matrix consisting of the first row with unit vectors of magnitude 1, the second row with the direction ratios of the first vector and the third row with the direction ratios of the second vector. The magnitude of a vector is it's value expressed as a number. Let the direction ratios of the first vector, P be: a, b, c Let the direction ratios of the second vector, Q be: x, y, z Therefore the calculation for the cross product can be arranged as:</p>
|
||||
<div class="fragment"><div class="line">P x Q:</div>
|
||||
<div class="line"> 1 1 1</div>
|
||||
<div class="line"> a b c</div>
|
||||
<div class="line"> x y z</div>
|
||||
</div><!-- fragment --><p>The direction ratios (DR) are calculated as follows: 1st DR, J: (b * z) - (c * y) 2nd DR, A: -((a * z) - (c * x)) 3rd DR, N: (a * y) - (b * x)</p>
|
||||
<p>Therefore, the direction ratios of the cross product are: J, A, N The following C++ Program calculates the direction ratios of the cross products of two vector. The program uses a function, <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#abed307975124243d63fe2e118254defe" title="Function to calculate the cross product of the passed arrays containing the direction ratios of the t...">cross()</a> for doing so. The direction ratios for the first and the second vector has to be passed one by one seperated by a space character.</p>
|
||||
<p>Magnitude of a vector is the square root of the sum of the squares of the direction ratios.</p>
|
||||
</div><!-- fragment --><p >The direction ratios (DR) are calculated as follows: 1st DR, J: (b * z) - (c * y) 2nd DR, A: -((a * z) - (c * x)) 3rd DR, N: (a * y) - (b * x)</p>
|
||||
<p >Therefore, the direction ratios of the cross product are: J, A, N The following C++ Program calculates the direction ratios of the cross products of two vector. The program uses a function, <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#a225732399c5c076976eae5b180a9f8c9" title="Function to calculate the cross product of the passed arrays containing the direction ratios of the t...">cross()</a> for doing so. The direction ratios for the first and the second vector has to be passed one by one seperated by a space character.</p>
|
||||
<p >Magnitude of a vector is the square root of the sum of the squares of the direction ratios.</p>
|
||||
<h3><a class="anchor" id="autotoc_md76"></a>
|
||||
Example:</h3>
|
||||
<p>An example of a running instance of the executable program: </p><pre class="fragment">Pass the first Vector: 1 2 3
|
||||
<p >An example of a running instance of the executable program: </p><pre class="fragment">Pass the first Vector: 1 2 3
|
||||
</pre><p> Pass the second Vector: 4 5 6 The cross product is: -3 6 -3 Magnitude: 7.34847</p>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/Shreyas-OwO">Shreyas Sable</a> </dd></dl>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/Shreyas-OwO" target="_blank">Shreyas Sable</a> </dd></dl>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
<a id="abed307975124243d63fe2e118254defe"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#abed307975124243d63fe2e118254defe">◆ </a></span>cross()</h2>
|
||||
<a id="a225732399c5c076976eae5b180a9f8c9" name="a225732399c5c076976eae5b180a9f8c9"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a225732399c5c076976eae5b180a9f8c9">◆ </a></span>cross()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a><double, 3> math::vector_cross::cross </td>
|
||||
<td class="memname"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< double, 3 > math::vector_cross::cross </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< double, 3 > & </td>
|
||||
<td class="paramname"><em>A</em>, </td>
|
||||
@@ -186,26 +185,26 @@ Example:</h3>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>the direction ratios of the cross product. </dd></dl>
|
||||
<p>Performs the cross product as shown in @algorithm.</p>
|
||||
<div class="fragment"><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  {</div>
|
||||
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> product;<span class="comment"></span></div>
|
||||
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span> <span class="comment"> /// Performs the cross product as shown in @algorithm.</span></div>
|
||||
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span> <span class="comment"></span> product[0] = (A[1] * B[2]) - (A[2] * B[1]);</div>
|
||||
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  product[1] = -((A[0] * B[2]) - (A[2] * B[0]));</div>
|
||||
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  product[2] = (A[0] * B[1]) - (A[1] * B[0]);</div>
|
||||
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <span class="keywordflow">return</span> product;</div>
|
||||
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  }</div>
|
||||
<p >Performs the cross product as shown in @algorithm.</p>
|
||||
<div class="fragment"><div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> {</div>
|
||||
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> product;<span class="comment"></span></div>
|
||||
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span><span class="comment"> /// Performs the cross product as shown in @algorithm.</span></div>
|
||||
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span><span class="comment"></span> product[0] = (A[1] * B[2]) - (A[2] * B[1]);</div>
|
||||
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> product[1] = -((A[0] * B[2]) - (A[2] * B[0]));</div>
|
||||
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> product[2] = (A[0] * B[1]) - (A[1] * B[0]);</div>
|
||||
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <span class="keywordflow">return</span> product;</div>
|
||||
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> }</div>
|
||||
<div class="ttc" id="aarray_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a></div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d66/vector__cross__product_8cpp_abed307975124243d63fe2e118254defe_cgraph.svg" width="146" height="76"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d66/vector__cross__product_8cpp_a225732399c5c076976eae5b180a9f8c9_cgraph.svg" width="146" height="76"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="a4b2a9757a87c18e1642d72410ecfaba8"></a>
|
||||
<a id="a4b2a9757a87c18e1642d72410ecfaba8" name="a4b2a9757a87c18e1642d72410ecfaba8"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a4b2a9757a87c18e1642d72410ecfaba8">◆ </a></span>mag()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
@@ -229,10 +228,10 @@ Here is the call graph for this function:</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>type: double description: the magnitude of the mathematical vector from the given direction ratios. </dd></dl>
|
||||
<div class="fragment"><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  {</div>
|
||||
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="keywordtype">double</span> magnitude = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">sqrt</a>((vec[0] * vec[0]) + (vec[1] * vec[1]) + (vec[2] * vec[2]));</div>
|
||||
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <span class="keywordflow">return</span> magnitude;</div>
|
||||
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  }</div>
|
||||
<div class="fragment"><div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> {</div>
|
||||
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> <span class="keywordtype">double</span> magnitude = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">sqrt</a>((vec[0] * vec[0]) + (vec[1] * vec[1]) + (vec[2] * vec[2]));</div>
|
||||
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> <span class="keywordflow">return</span> magnitude;</div>
|
||||
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> }</div>
|
||||
<div class="ttc" id="asqrt_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a></div><div class="ttdeci">T sqrt(T... args)</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
@@ -243,7 +242,7 @@ Here is the call graph for this function:</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
||||
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">◆ </a></span>main()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
@@ -260,43 +259,43 @@ Here is the call graph for this function:</div>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Main Function. </p>
|
||||
<p>Asks the user to enter the direction ratios for each of the two mathematical vectors using <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> </p><dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
|
||||
<p>Tests the functions with sample input before asking for user input.</p>
|
||||
<p>Gets the values for the first vector.</p>
|
||||
<p>Gets the values for the second vector.</p>
|
||||
<p>Displays the output out.</p>
|
||||
<p>Displays the magnitude of the cross product.</p>
|
||||
<div class="fragment"><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  {</div>
|
||||
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span> <span class="comment"></span> </div>
|
||||
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span> <span class="comment"> /// Tests the functions with sample input before asking for user input.</span></div>
|
||||
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span> <span class="comment"></span> <a class="code" href="../../df/d66/vector__cross__product_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>();</div>
|
||||
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  </div>
|
||||
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> vec1;</div>
|
||||
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> vec2;</div>
|
||||
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span> <span class="comment"></span> </div>
|
||||
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span> <span class="comment"> /// Gets the values for the first vector.</span></div>
|
||||
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span> <span class="comment"></span> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"\nPass the first Vector: "</span>;</div>
|
||||
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> vec1[0] >> vec1[1] >> vec1[2];</div>
|
||||
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span> <span class="comment"></span> </div>
|
||||
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span> <span class="comment"> /// Gets the values for the second vector.</span></div>
|
||||
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span> <span class="comment"></span> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"\nPass the second Vector: "</span>;</div>
|
||||
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> vec2[0] >> vec2[1] >> vec2[2];</div>
|
||||
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span> <span class="comment"></span> </div>
|
||||
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span> <span class="comment"> /// Displays the output out.</span></div>
|
||||
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span> <span class="comment"></span> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> product = <a class="code" href="../../df/d66/vector__cross__product_8cpp.html#abed307975124243d63fe2e118254defe">math::vector_cross::cross</a>(vec1, vec2);</div>
|
||||
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"\nThe cross product is: "</span> << product[0] << <span class="stringliteral">" "</span> << product[1] << <span class="stringliteral">" "</span> << product[2] << <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span> <span class="comment"></span> </div>
|
||||
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span> <span class="comment"> /// Displays the magnitude of the cross product.</span></div>
|
||||
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span> <span class="comment"></span> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Magnitude: "</span> << <a class="code" href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8">math::vector_cross::mag</a>(product) << <span class="stringliteral">"\n"</span> << <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  </div>
|
||||
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span> }</div>
|
||||
<p >Asks the user to enter the direction ratios for each of the two mathematical vectors using <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> </p><dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
|
||||
<p >Tests the functions with sample input before asking for user input.</p>
|
||||
<p >Gets the values for the first vector.</p>
|
||||
<p >Gets the values for the second vector.</p>
|
||||
<p >Displays the output out.</p>
|
||||
<p >Displays the magnitude of the cross product.</p>
|
||||
<div class="fragment"><div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> {</div>
|
||||
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span><span class="comment"></span> </div>
|
||||
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span><span class="comment"> /// Tests the functions with sample input before asking for user input.</span></div>
|
||||
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span><span class="comment"></span> <a class="code hl_function" href="../../df/d66/vector__cross__product_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>();</div>
|
||||
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> </div>
|
||||
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> vec1;</div>
|
||||
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> vec2;</div>
|
||||
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span><span class="comment"></span> </div>
|
||||
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span><span class="comment"> /// Gets the values for the first vector.</span></div>
|
||||
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"\nPass the first Vector: "</span>;</div>
|
||||
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> vec1[0] >> vec1[1] >> vec1[2];</div>
|
||||
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span><span class="comment"></span> </div>
|
||||
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span><span class="comment"> /// Gets the values for the second vector.</span></div>
|
||||
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"\nPass the second Vector: "</span>;</div>
|
||||
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> vec2[0] >> vec2[1] >> vec2[2];</div>
|
||||
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span><span class="comment"></span> </div>
|
||||
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span><span class="comment"> /// Displays the output out.</span></div>
|
||||
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> product = <a class="code hl_function" href="../../df/d66/vector__cross__product_8cpp.html#a225732399c5c076976eae5b180a9f8c9">math::vector_cross::cross</a>(vec1, vec2);</div>
|
||||
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"\nThe cross product is: "</span> << product[0] << <span class="stringliteral">" "</span> << product[1] << <span class="stringliteral">" "</span> << product[2] << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span><span class="comment"></span> </div>
|
||||
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span><span class="comment"> /// Displays the magnitude of the cross product.</span></div>
|
||||
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Magnitude: "</span> << <a class="code hl_function" href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8">math::vector_cross::mag</a>(product) << <span class="stringliteral">"\n"</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> </div>
|
||||
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span>}</div>
|
||||
<div class="ttc" id="abasic_istream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a></div></div>
|
||||
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
|
||||
<div class="ttc" id="aendl_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a></div><div class="ttdeci">T endl(T... args)</div></div>
|
||||
<div class="ttc" id="avector__cross__product_8cpp_html_a225732399c5c076976eae5b180a9f8c9"><div class="ttname"><a href="../../df/d66/vector__cross__product_8cpp.html#a225732399c5c076976eae5b180a9f8c9">math::vector_cross::cross</a></div><div class="ttdeci">std::array< double, 3 > cross(const std::array< double, 3 > &A, const std::array< double, 3 > &B)</div><div class="ttdoc">Function to calculate the cross product of the passed arrays containing the direction ratios of the t...</div><div class="ttdef"><b>Definition:</b> vector_cross_product.cpp:69</div></div>
|
||||
<div class="ttc" id="avector__cross__product_8cpp_html_a4b2a9757a87c18e1642d72410ecfaba8"><div class="ttname"><a href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8">math::vector_cross::mag</a></div><div class="ttdeci">double mag(const std::array< double, 3 > &vec)</div><div class="ttdoc">Calculates the magnitude of the mathematical vector from it's direction ratios.</div><div class="ttdef"><b>Definition:</b> vector_cross_product.cpp:83</div></div>
|
||||
<div class="ttc" id="avector__cross__product_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../df/d66/vector__cross__product_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">namespace math</div><div class="ttdef"><b>Definition:</b> vector_cross_product.cpp:94</div></div>
|
||||
<div class="ttc" id="avector__cross__product_8cpp_html_abed307975124243d63fe2e118254defe"><div class="ttname"><a href="../../df/d66/vector__cross__product_8cpp.html#abed307975124243d63fe2e118254defe">math::vector_cross::cross</a></div><div class="ttdeci">std::array< double, 3 > cross(const std::array< double, 3 > &A, const std::array< double, 3 > &B)</div><div class="ttdoc">Function to calculate the cross product of the passed arrays containing the direction ratios of the t...</div><div class="ttdef"><b>Definition:</b> vector_cross_product.cpp:69</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
@@ -306,7 +305,7 @@ Here is the call graph for this function:</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="aa8dca7b867074164d5f45b0f3851269d"></a>
|
||||
<a id="aa8dca7b867074164d5f45b0f3851269d" name="aa8dca7b867074164d5f45b0f3851269d"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#aa8dca7b867074164d5f45b0f3851269d">◆ </a></span>test()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
@@ -330,19 +329,19 @@ Here is the call graph for this function:</div>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>namespace math </p>
|
||||
<p>test function.</p>
|
||||
<p>test the <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#abed307975124243d63fe2e118254defe" title="Function to calculate the cross product of the passed arrays containing the direction ratios of the t...">cross()</a> and the <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8" title="Calculates the magnitude of the mathematical vector from it's direction ratios.">mag()</a> functions. </p>
|
||||
<p>Tests the <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#abed307975124243d63fe2e118254defe" title="Function to calculate the cross product of the passed arrays containing the direction ratios of the t...">cross()</a> function.</p>
|
||||
<p>Tests the <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8" title="Calculates the magnitude of the mathematical vector from it's direction ratios.">mag()</a> function.</p>
|
||||
<div class="fragment"><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  {<span class="comment"></span></div>
|
||||
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span> <span class="comment"> /// Tests the cross() function.</span></div>
|
||||
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span> <span class="comment"></span> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> t_vec = <a class="code" href="../../df/d66/vector__cross__product_8cpp.html#abed307975124243d63fe2e118254defe">math::vector_cross::cross</a>({1, 2, 3}, {4, 5, 6});</div>
|
||||
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  assert(t_vec[0] == -3 && t_vec[1] == 6 && t_vec[2] == -3);</div>
|
||||
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span> <span class="comment"></span> </div>
|
||||
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span> <span class="comment"> /// Tests the mag() function.</span></div>
|
||||
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span> <span class="comment"></span> <span class="keywordtype">double</span> t_mag = <a class="code" href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8">math::vector_cross::mag</a>({6, 8, 0});</div>
|
||||
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  assert(t_mag == 10);</div>
|
||||
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span> }</div>
|
||||
<p >test function.</p>
|
||||
<p >test the <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#a225732399c5c076976eae5b180a9f8c9" title="Function to calculate the cross product of the passed arrays containing the direction ratios of the t...">cross()</a> and the <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8" title="Calculates the magnitude of the mathematical vector from it's direction ratios.">mag()</a> functions. </p>
|
||||
<p >Tests the <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#a225732399c5c076976eae5b180a9f8c9" title="Function to calculate the cross product of the passed arrays containing the direction ratios of the t...">cross()</a> function.</p>
|
||||
<p >Tests the <a class="el" href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8" title="Calculates the magnitude of the mathematical vector from it's direction ratios.">mag()</a> function.</p>
|
||||
<div class="fragment"><div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> {<span class="comment"></span></div>
|
||||
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span><span class="comment"> /// Tests the cross() function.</span></div>
|
||||
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array<double, 3></a> t_vec = <a class="code hl_function" href="../../df/d66/vector__cross__product_8cpp.html#a225732399c5c076976eae5b180a9f8c9">math::vector_cross::cross</a>({1, 2, 3}, {4, 5, 6});</div>
|
||||
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> assert(t_vec[0] == -3 && t_vec[1] == 6 && t_vec[2] == -3);</div>
|
||||
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span><span class="comment"></span> </div>
|
||||
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span><span class="comment"> /// Tests the mag() function.</span></div>
|
||||
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span><span class="comment"></span> <span class="keywordtype">double</span> t_mag = <a class="code hl_function" href="../../df/d66/vector__cross__product_8cpp.html#a4b2a9757a87c18e1642d72410ecfaba8">math::vector_cross::mag</a>({6, 8, 0});</div>
|
||||
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> assert(t_mag == 10);</div>
|
||||
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span>}</div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -352,7 +351,7 @@ Here is the call graph for this function:</div>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_296d53ceaeaa7e099814a6def439fe8a.html">math</a></li><li class="navelem"><a class="el" href="../../df/d66/vector__cross__product_8cpp.html">vector_cross_product.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user