1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
<HTML>
<HEAD>
<TITLE>The Synthesis ToolKit in C++ (STK)</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<img src="princeton.gif"> <img src="ccrma.gif"> <img src="mcgill.gif"><P>
<a class="qindex" href="index.html">Home</a> <a class="qindex" href="information.html">Information</a> <a class="qindex" href="classes.html">Classes</a> <a class="qindex" href="download.html">Download</a> <a class="qindex" href="usage.html">Usage</a> <a class="qindex" href="maillist.html">Mail List</a> <a class="qindex" href="system.html">Requirements</a> <a class="qindex" href="links.html">Links</a> <a class="qindex" href="faq.html">FAQ</a> <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
<HR>
<!-- Generated by Doxygen 1.6.2 -->
<div class="navpath"><a class="el" href="dir_221deb9bdff892d63ed1e409450a60d2.html">include</a>
</div>
<div class="contents">
<h1>Sphere.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef STK_SPHERE_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define STK_SPHERE_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include "Stk.h"</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include "Vector3D.h"</span>
<a name="l00006"></a>00006
<a name="l00007"></a>00007 <span class="keyword">namespace </span>stk {
<a name="l00008"></a>00008
<a name="l00009"></a>00009 <span class="comment">/***************************************************/</span>
<a name="l00018"></a>00018 <span class="comment">/***************************************************/</span>
<a name="l00019"></a>00019
<a name="l00020"></a><a class="code" href="classstk_1_1Sphere.html">00020</a> <span class="keyword">class </span><a class="code" href="classstk_1_1Sphere.html" title="STK sphere class.">Sphere</a> : <span class="keyword">public</span> <a class="code" href="classstk_1_1Stk.html" title="STK base class.">Stk</a>
<a name="l00021"></a>00021 {
<a name="l00022"></a>00022 <span class="keyword">public</span>:
<a name="l00024"></a><a class="code" href="classstk_1_1Sphere.html#a73d4fac54fba9aa11a56a34e4198656c">00024</a> <a class="code" href="classstk_1_1Sphere.html#a73d4fac54fba9aa11a56a34e4198656c" title="Constructor taking an initial radius value.">Sphere</a>( StkFloat radius = 1.0 ) { radius_ = radius; mass_ = 1.0; };
<a name="l00025"></a>00025
<a name="l00027"></a><a class="code" href="classstk_1_1Sphere.html#acfa3d4475f9c5ab655276473b1816f39">00027</a> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Sphere.html#acfa3d4475f9c5ab655276473b1816f39" title="Set the 3D center position of the sphere.">setPosition</a>( StkFloat x, StkFloat y, StkFloat z ) { position_.<a class="code" href="classstk_1_1Vector3D.html#a65fd03de6d9d42ea53a6cb8418ee7149" title="Set the X, Y, and Z values simultaniously.">setXYZ</a>(x, y, z); };
<a name="l00028"></a>00028
<a name="l00030"></a><a class="code" href="classstk_1_1Sphere.html#ac76725a19fe806e9af9841d30faacb11">00030</a> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Sphere.html#ac76725a19fe806e9af9841d30faacb11" title="Set the 3D velocity of the sphere.">setVelocity</a>( StkFloat x, StkFloat y, StkFloat z ) { velocity_.<a class="code" href="classstk_1_1Vector3D.html#a65fd03de6d9d42ea53a6cb8418ee7149" title="Set the X, Y, and Z values simultaniously.">setXYZ</a>(x, y, z); };
<a name="l00031"></a>00031
<a name="l00033"></a><a class="code" href="classstk_1_1Sphere.html#ac3f4f85642307bebe0733662620f0ee2">00033</a> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Sphere.html#ac3f4f85642307bebe0733662620f0ee2" title="Set the radius of the sphere.">setRadius</a>( StkFloat radius ) { radius_ = radius; };
<a name="l00034"></a>00034
<a name="l00036"></a><a class="code" href="classstk_1_1Sphere.html#a0db842c9f06b377bcd803391b7126d2f">00036</a> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Sphere.html#a0db842c9f06b377bcd803391b7126d2f" title="Set the mass of the sphere.">setMass</a>( StkFloat mass ) { mass_ = mass; };
<a name="l00037"></a>00037
<a name="l00039"></a><a class="code" href="classstk_1_1Sphere.html#a91a3e710a7ff0cf160e9d46fca373bfd">00039</a> <a class="code" href="classstk_1_1Vector3D.html" title="STK 3D vector class.">Vector3D</a>* <a class="code" href="classstk_1_1Sphere.html#a91a3e710a7ff0cf160e9d46fca373bfd" title="Get the current position of the sphere as a 3D vector.">getPosition</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> &position_; };
<a name="l00040"></a>00040
<a name="l00042"></a>00042 <a class="code" href="classstk_1_1Vector3D.html" title="STK 3D vector class.">Vector3D</a>* <a class="code" href="classstk_1_1Sphere.html#a4cf8f763e732bcf9ca79b8602e8ec24a" title="Get the relative position of the given point to the sphere as a 3D vector.">getRelativePosition</a>( <a class="code" href="classstk_1_1Vector3D.html" title="STK 3D vector class.">Vector3D</a> *position );
<a name="l00043"></a>00043
<a name="l00045"></a>00045 StkFloat <a class="code" href="classstk_1_1Sphere.html#a43ccf47d5d952f14f1ba0940aa87f4c5" title="Set the velcoity of the sphere as a 3D vector.">getVelocity</a>( <a class="code" href="classstk_1_1Vector3D.html" title="STK 3D vector class.">Vector3D</a>* velocity );
<a name="l00046"></a>00046
<a name="l00048"></a>00048 StkFloat <a class="code" href="classstk_1_1Sphere.html#a00bf47b0d5cd06a858d08f37d220ef9f" title="Returns the distance from the sphere boundary to the given position (&lt; 0 if inside)...">isInside</a>( <a class="code" href="classstk_1_1Vector3D.html" title="STK 3D vector class.">Vector3D</a> *position );
<a name="l00049"></a>00049
<a name="l00051"></a><a class="code" href="classstk_1_1Sphere.html#a03550bbe32d62ead67787651619b8c8b">00051</a> StkFloat <a class="code" href="classstk_1_1Sphere.html#a03550bbe32d62ead67787651619b8c8b" title="Get the current sphere radius.">getRadius</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> radius_; };
<a name="l00052"></a>00052
<a name="l00054"></a><a class="code" href="classstk_1_1Sphere.html#aa82d922e0b8513364d9d0d473e6239c6">00054</a> StkFloat <a class="code" href="classstk_1_1Sphere.html#aa82d922e0b8513364d9d0d473e6239c6" title="Get the current sphere mass.">getMass</a>( <span class="keywordtype">void</span> ) { <span class="keywordflow">return</span> mass_; };
<a name="l00055"></a>00055
<a name="l00057"></a>00057 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Sphere.html#a16666f1e94c6d1e6b1fa35ee6c46331f" title="Increase the current sphere velocity by the given 3D components.">addVelocity</a>( StkFloat x, StkFloat y, StkFloat z );
<a name="l00058"></a>00058
<a name="l00060"></a>00060 <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Sphere.html#adc4709622b77fc91ad6f33be98c86344" title="Move the sphere for the given time increment.">tick</a>( StkFloat timeIncrement );
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="keyword">private</span>:
<a name="l00063"></a>00063 <a class="code" href="classstk_1_1Vector3D.html" title="STK 3D vector class.">Vector3D</a> position_;
<a name="l00064"></a>00064 <a class="code" href="classstk_1_1Vector3D.html" title="STK 3D vector class.">Vector3D</a> velocity_;
<a name="l00065"></a>00065 <a class="code" href="classstk_1_1Vector3D.html" title="STK 3D vector class.">Vector3D</a> workingVector_;
<a name="l00066"></a>00066 StkFloat radius_;
<a name="l00067"></a>00067 StkFloat mass_;
<a name="l00068"></a>00068 };
<a name="l00069"></a>00069
<a name="l00070"></a><a class="code" href="classstk_1_1Sphere.html#adc4709622b77fc91ad6f33be98c86344">00070</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classstk_1_1Sphere.html#adc4709622b77fc91ad6f33be98c86344" title="Move the sphere for the given time increment.">Sphere::tick</a>( StkFloat timeIncrement )
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072 position_.<a class="code" href="classstk_1_1Vector3D.html#a9825ba3adb8fb272d2e3ca20740a48c5" title="Set the X value.">setX</a>(position_.<a class="code" href="classstk_1_1Vector3D.html#ae4f7cddc34ed1cf80262ff2d5dad65f4" title="Get the current X value.">getX</a>() + (timeIncrement * velocity_.<a class="code" href="classstk_1_1Vector3D.html#ae4f7cddc34ed1cf80262ff2d5dad65f4" title="Get the current X value.">getX</a>()));
<a name="l00073"></a>00073 position_.<a class="code" href="classstk_1_1Vector3D.html#a94de5326b083c6cf72f509aa0fc532f3" title="Set the Y value.">setY</a>(position_.<a class="code" href="classstk_1_1Vector3D.html#af83bfbe865d702845e37e14d82f642b6" title="Get the current Y value.">getY</a>() + (timeIncrement * velocity_.<a class="code" href="classstk_1_1Vector3D.html#af83bfbe865d702845e37e14d82f642b6" title="Get the current Y value.">getY</a>()));
<a name="l00074"></a>00074 position_.<a class="code" href="classstk_1_1Vector3D.html#a826f2aa5e7b95a0d91f9432f26bec881" title="Set the Z value.">setZ</a>(position_.<a class="code" href="classstk_1_1Vector3D.html#af1c7389a2b4640cbe594fa33f9e4f805" title="Get the current Z value.">getZ</a>() + (timeIncrement * velocity_.<a class="code" href="classstk_1_1Vector3D.html#af1c7389a2b4640cbe594fa33f9e4f805" title="Get the current Z value.">getZ</a>()));
<a name="l00075"></a>00075 };
<a name="l00076"></a>00076
<a name="l00077"></a>00077 } <span class="comment">// stk namespace</span>
<a name="l00078"></a>00078
<a name="l00079"></a>00079 <span class="preprocessor">#endif</span>
</pre></div></div>
<HR>
<table>
<tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
<tr><td>©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>
|