mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-29 21:14:35 +08:00
Documentation for 0931d530ae
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.5"/>
|
||||
<meta name="generator" content="Doxygen 1.9.6"/>
|
||||
<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"/>
|
||||
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.5 -->
|
||||
<!-- Generated by Doxygen 1.9.6 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
@@ -129,31 +129,31 @@ Namespaces</h2></td></tr>
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></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="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. <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="memdesc:a4b2a9757a87c18e1642d72410ecfaba8"><td class="mdescLeft"> </td><td class="mdescRight">Calculates the magnitude of the mathematical vector from it's direction ratios. <br /></td></tr>
|
||||
<tr class="separator:a4b2a9757a87c18e1642d72410ecfaba8"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d66/vector__cross__product_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
|
||||
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft"> </td><td class="mdescRight">namespace math <a href="../../df/d66/vector__cross__product_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft"> </td><td class="mdescRight">namespace math <br /></td></tr>
|
||||
<tr class="separator:aa8dca7b867074164d5f45b0f3851269d"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../df/d66/vector__cross__product_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
|
||||
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft"> </td><td class="mdescRight">Main Function. <a href="../../df/d66/vector__cross__product_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft"> </td><td class="mdescRight">Main Function. <br /></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" 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="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, cross() 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, cross() 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_md86"></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" target="_blank">Shreyas Sable</a> </dd></dl>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
@@ -192,7 +192,7 @@ 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>
|
||||
<p>Performs the cross product as shown in @algorithm.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 69</span> {</div>
|
||||
<div class="line"><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"><span class="lineno"> 71</span><span class="comment"> /// Performs the cross product as shown in @algorithm.</span></div>
|
||||
@@ -266,12 +266,12 @@ 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>
|
||||
<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"><span class="lineno"> 109</span> {</div>
|
||||
<div class="line"><span class="lineno"> 110</span><span class="comment"></span> </div>
|
||||
<div class="line"><span class="lineno"> 111</span><span class="comment"> /// Tests the functions with sample input before asking for user input.</span></div>
|
||||
@@ -336,10 +336,10 @@ Here is the call graph for this function:</div>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>namespace math </p>
|
||||
<p >test function.</p>
|
||||
<p >test the cross() and the mag() functions. </p>
|
||||
<p >Tests the cross() function.</p>
|
||||
<p >Tests the mag() function.</p>
|
||||
<p>test function.</p>
|
||||
<p>test the cross() and the mag() functions. </p>
|
||||
<p>Tests the cross() function.</p>
|
||||
<p>Tests the mag() function.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 94</span> {<span class="comment"></span></div>
|
||||
<div class="line"><span class="lineno"> 95</span><span class="comment"> /// Tests the cross() function.</span></div>
|
||||
<div class="line"><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>
|
||||
@@ -358,7 +358,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.5 </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.6 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user