diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/a02940.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/a02940.html | 387 |
1 files changed, 387 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a02940.html b/docs/doxygen/nel/a02940.html new file mode 100644 index 00000000..efabc7a4 --- /dev/null +++ b/docs/doxygen/nel/a02940.html @@ -0,0 +1,387 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>NeL: NLMISC::CMouseSmoother class Reference</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.3.6 --> +<div class="qindex"> <form class="search" action="search.php" method="get"> +<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div> +<h1>NLMISC::CMouseSmoother Class Reference</h1><code>#include <<a class="el" href="a06044.html">mouse_smoother.h</a>></code> +<p> +<hr><a name="_details"></a><h2>Detailed Description</h2> +This smooth position of mouse using cubic splines. The mouse is sampled at the given period. The higher the period, the smoother the movement. However there is a delay of 2 * samplingPeriod between the user moving the mouse and the pointer reaching the wanted poistion.<p> +<dl compact><dt><b>Author:</b></dt><dd>Nicolas Vizerie <p> +Nevrax France </dd></dl> +<dl compact><dt><b>Date:</b></dt><dd>1/2004 </dd></dl> + +<p> + +<p> +Definition at line <a class="el" href="a06044.html#l00044">44</a> of file <a class="el" href="a06044.html">mouse_smoother.h</a>.<table border=0 cellpadding=0 cellspacing=0> +<tr><td></td></tr> +<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="a02940.html#NLMISC_1_1CMouseSmoothera0">CMouseSmoother</a> (double samplingPeriod=0.2)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>double </td><td class="memItemRight" valign=bottom><a class="el" href="a02940.html#NLMISC_1_1CMouseSmoothera1">getSamplingPeriod</a> () const </td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02940.html#NLMISC_1_1CMouseSmoothera2">reset</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03660.html">CVector2f</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02940.html#NLMISC_1_1CMouseSmoothera3">samplePos</a> (const <a class="el" href="a03660.html">CVector2f</a> &wantedPos, double date)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02940.html#NLMISC_1_1CMouseSmoothera4">setSamplingPeriod</a> (double period)</td></tr> + +<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02940.html#NLMISC_1_1CMouseSmootherr0">_Init</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02941.html">CSample</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a> [4]</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>double </td><td class="memItemRight" valign=bottom><a class="el" href="a02940.html#NLMISC_1_1CMouseSmootherr2">_SamplingPeriod</a></td></tr> + +</table> +<hr><h2>Constructor & Destructor Documentation</h2> +<a class="anchor" name="NLMISC_1_1CMouseSmoothera0" doxytag="NLMISC::CMouseSmoother::CMouseSmoother" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLMISC::CMouseSmoother::CMouseSmoother </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">double </td> + <td class="mdname1" valign="top" nowrap> <em>samplingPeriod</em> = 0.2 </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06043.html#l00053">53</a> of file <a class="el" href="a06043.html">mouse_smoother.cpp</a>. +<p> +References <a class="el" href="a06044.html#l00075">_Init</a>, <a class="el" href="a06044.html#l00074">_SamplingPeriod</a>, and <a class="el" href="a05622.html#l00290">nlassert</a>. +<p> +<div class="fragment"><pre>00054 { +00055 <a class="code" href="a04199.html#a6">nlassert</a>(samplingPeriod > 0); +00056 <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr2">_SamplingPeriod</a> = samplingPeriod; +00057 <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr0">_Init</a> = <span class="keyword">false</span>; +00058 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NLMISC_1_1CMouseSmoothera1" doxytag="NLMISC::CMouseSmoother::getSamplingPeriod" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> double NLMISC::CMouseSmoother::getSamplingPeriod </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06044.html#l00054">54</a> of file <a class="el" href="a06044.html">mouse_smoother.h</a>. +<p> +References <a class="el" href="a06044.html#l00074">_SamplingPeriod</a>. +<p> +<div class="fragment"><pre>00054 { <span class="keywordflow">return</span> <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr2">_SamplingPeriod</a>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CMouseSmoothera2" doxytag="NLMISC::CMouseSmoother::reset" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CMouseSmoother::reset </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06043.html#l00136">136</a> of file <a class="el" href="a06043.html">mouse_smoother.cpp</a>. +<p> +References <a class="el" href="a06044.html#l00075">_Init</a>. +<p> +Referenced by <a class="el" href="a06043.html#l00062">setSamplingPeriod()</a>. +<p> +<div class="fragment"><pre>00137 { +00138 <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr0">_Init</a> = <span class="keyword">false</span>; +00139 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CMouseSmoothera3" doxytag="NLMISC::CMouseSmoother::samplePos" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03660.html">NLMISC::CVector2f</a> NLMISC::CMouseSmoother::samplePos </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03660.html">CVector2f</a> & </td> + <td class="mdname" nowrap> <em>wantedPos</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>double </td> + <td class="mdname" nowrap> <em>date</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06043.html#l00072">72</a> of file <a class="el" href="a06043.html">mouse_smoother.cpp</a>. +<p> +References <a class="el" href="a06044.html#l00075">_Init</a>, <a class="el" href="a06044.html#l00074">_SamplingPeriod</a>, <a class="el" href="a06043.html#l00033">NLMISC::BuildHermiteVector()</a>, <a class="el" href="a05587.html#l00115">NLMISC::clamp()</a>, <a class="el" href="a06044.html#l00064">NLMISC::CMouseSmoother::CSample::Date</a>, <a class="el" href="a05484.html#l00038">min</a>, <a class="el" href="a06044.html#l00065">NLMISC::CMouseSmoother::CSample::Pos</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::x</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>. +<p> +<div class="fragment"><pre>00073 { +00074 <span class="keywordflow">if</span> (!<a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr0">_Init</a>) +00075 { +00076 <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[0] = <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[1] = _Sample[2] = _Sample[3] = CSample(date, wantedPos); +00077 <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr0">_Init</a> = <span class="keyword">true</span>; +00078 } +00079 <span class="keywordflow">else</span> +00080 { +00081 <span class="comment">// see if enough time has elapsed since last sample</span> +00082 <span class="keywordflow">if</span> (date - <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[3].<a class="code" href="a02941.html#NLMISC_1_1CMouseSmoother_1_1CSampleo0">Date</a> >= <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr2">_SamplingPeriod</a>) +00083 { +00084 <a class="code" href="a04558.html#a15">uint</a> numSamples = (<a class="code" href="a04558.html#a15">uint</a>) floor((date - _Sample[3].Date) / _SamplingPeriod); +00085 numSamples = <a class="code" href="a04061.html#a0">std::min</a>(numSamples, (<a class="code" href="a04558.html#a15">uint</a>) 4); +00086 <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a15">uint</a> k = 0; k < numSamples; ++k) +00087 { +00088 <span class="comment">// add a new sample</span> +00089 <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[0] = <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[1]; +00090 _Sample[1] = _Sample[2]; +00091 _Sample[2] = _Sample[3]; +00092 _Sample[3] = CSample(date, wantedPos); +00093 } +00094 } +00095 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (date == <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[3].<a class="code" href="a02941.html#NLMISC_1_1CMouseSmoother_1_1CSampleo0">Date</a>) +00096 { +00097 <span class="comment">// update cur pos</span> +00098 _Sample[3] = CSample(date, wantedPos); +00099 } +00100 } +00101 <span class="keywordflow">if</span> (<a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[1].<a class="code" href="a02941.html#NLMISC_1_1CMouseSmoother_1_1CSampleo1">Pos</a>.x == <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[2].<a class="code" href="a02941.html#NLMISC_1_1CMouseSmoother_1_1CSampleo1">Pos</a>.x && +00102 <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[1].<a class="code" href="a02941.html#NLMISC_1_1CMouseSmoother_1_1CSampleo1">Pos</a>.y == <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[2].<a class="code" href="a02941.html#NLMISC_1_1CMouseSmoother_1_1CSampleo1">Pos</a>.y +00103 ) +00104 { +00105 <span class="comment">// special case : if pointer hasn't moved, allow a discontinuity of speed</span> +00106 <span class="keywordflow">return</span> <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[2].<a class="code" href="a02941.html#NLMISC_1_1CMouseSmoother_1_1CSampleo1">Pos</a>; +00107 } +00108 <span class="keywordtype">double</span> evalDate = date - 2 * <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr2">_SamplingPeriod</a>; +00109 <a class="code" href="a05378.html#a374">clamp</a>(evalDate, _Sample[1].Date, _Sample[2].Date); +00110 CVector2f t0; +00111 <span class="keywordtype">double</span> dt = <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr1">_Sample</a>[2].<a class="code" href="a02941.html#NLMISC_1_1CMouseSmoother_1_1CSampleo0">Date</a> - _Sample[1].Date; +00112 <span class="keywordflow">if</span> (_Sample[2].Date != _Sample[0].Date) +00113 { +00114 t0 = (<span class="keywordtype">float</span>) dt * (_Sample[2].Pos - _Sample[0].Pos) / (<span class="keywordtype">float</span>) (_Sample[2].Date - _Sample[0].Date); +00115 } +00116 <span class="keywordflow">else</span> +00117 { +00118 t0= <a class="code" href="a03128.html#NLMISC_1_1CVectors3">NLMISC::CVector::Null</a>; +00119 } +00120 CVector2f t1; +00121 <span class="keywordflow">if</span> (_Sample[3].Date != _Sample[1].Date) +00122 { +00123 t1 = (<span class="keywordtype">float</span>) dt * (_Sample[3].Pos - _Sample[1].Pos) / (<span class="keywordtype">float</span>) (_Sample[3].Date - _Sample[1].Date); +00124 } +00125 <span class="keywordflow">else</span> +00126 { +00127 t1= <a class="code" href="a03128.html#NLMISC_1_1CVectors3">NLMISC::CVector::Null</a>; +00128 } +00129 <a class="code" href="a03660.html">NLMISC::CVector2f</a> result; +00130 <span class="keywordflow">if</span> (dt == 0) <span class="keywordflow">return</span> _Sample[2].Pos; +00131 <a class="code" href="a05378.html#a336">BuildHermiteVector</a>(_Sample[1].Pos, _Sample[2].Pos, t0, t1, result, (<span class="keywordtype">float</span>) ((evalDate - _Sample[1].Date) / dt)); +00132 <span class="keywordflow">return</span> result; +00133 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CMouseSmoothera4" doxytag="NLMISC::CMouseSmoother::setSamplingPeriod" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CMouseSmoother::setSamplingPeriod </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">double </td> + <td class="mdname1" valign="top" nowrap> <em>period</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Change the sampling period. The longer it lasts, the more smooth the movement. NB : this reset the smoother +<p> +Definition at line <a class="el" href="a06043.html#l00062">62</a> of file <a class="el" href="a06043.html">mouse_smoother.cpp</a>. +<p> +References <a class="el" href="a06044.html#l00074">_SamplingPeriod</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, and <a class="el" href="a06043.html#l00136">reset()</a>. +<p> +<div class="fragment"><pre>00063 { +00064 <span class="keywordflow">if</span> (period == <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr2">_SamplingPeriod</a>) <span class="keywordflow">return</span>; +00065 <a class="code" href="a02940.html#NLMISC_1_1CMouseSmoothera2">reset</a>(); +00066 <a class="code" href="a04199.html#a6">nlassert</a>(_SamplingPeriod > 0); +00067 <a class="code" href="a02940.html#NLMISC_1_1CMouseSmootherr2">_SamplingPeriod</a> = period; +00068 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Field Documentation</h2> +<a class="anchor" name="NLMISC_1_1CMouseSmootherr0" doxytag="NLMISC::CMouseSmoother::_Init" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool <a class="el" href="a02940.html#NLMISC_1_1CMouseSmootherr0">NLMISC::CMouseSmoother::_Init</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06044.html#l00075">75</a> of file <a class="el" href="a06044.html">mouse_smoother.h</a>. +<p> +Referenced by <a class="el" href="a06043.html#l00053">CMouseSmoother()</a>, <a class="el" href="a06043.html#l00136">reset()</a>, and <a class="el" href="a06043.html#l00072">samplePos()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CMouseSmootherr1" doxytag="NLMISC::CMouseSmoother::_Sample" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a02941.html">CSample</a> <a class="el" href="a02940.html#NLMISC_1_1CMouseSmootherr1">NLMISC::CMouseSmoother::_Sample</a>[4]<code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +4 samples are needed to compute smoothed position : Sample 0 & 2 are used to compute tangent at sample 1 Sample 1 & 3 are used to compute tangent at sample 2 +<p> +Definition at line <a class="el" href="a06044.html#l00080">80</a> of file <a class="el" href="a06044.html">mouse_smoother.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CMouseSmootherr2" doxytag="NLMISC::CMouseSmoother::_SamplingPeriod" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> double <a class="el" href="a02940.html#NLMISC_1_1CMouseSmootherr2">NLMISC::CMouseSmoother::_SamplingPeriod</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06044.html#l00074">74</a> of file <a class="el" href="a06044.html">mouse_smoother.h</a>. +<p> +Referenced by <a class="el" href="a06043.html#l00053">CMouseSmoother()</a>, <a class="el" href="a06044.html#l00054">getSamplingPeriod()</a>, <a class="el" href="a06043.html#l00072">samplePos()</a>, and <a class="el" href="a06043.html#l00062">setSamplingPeriod()</a>. </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following files:<ul> +<li><a class="el" href="a06044.html">mouse_smoother.h</a><li><a class="el" href="a06043.html">mouse_smoother.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:23:12 2004 for NeL by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 > +</a>1.3.6 </small></address> +</body> +</html> |