<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx</link><description>Games often have to make discrete decisions based on continuously varying analog input values. This happens a lot when making animation systems respond to controller inputs: if (speed &amp;gt; 0.7) ShowRunAnimation(); else if (speed &amp;gt; 0.1) ShowWalkAnimation();</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#2260653</link><pubDate>Tue, 24 Apr 2007 17:15:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2260653</guid><dc:creator>trayle</dc:creator><description>&lt;p&gt;Now you are talking my language. &amp;nbsp;I am an engineer, although not a control theory expert. &amp;nbsp;Your post made me wonder, how much control theory is used in the gaming field currently?&lt;/p&gt;
</description></item><item><title>re: Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#2260957</link><pubDate>Tue, 24 Apr 2007 17:58:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2260957</guid><dc:creator>GregGorman</dc:creator><description>&lt;p&gt;Your idea makes sense but the implementation doesn't.&lt;/p&gt;
&lt;p&gt;Say threshold = .7&lt;/p&gt;
&lt;p&gt;const float hysteresisAmount = 0.1;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;if (inputValue &amp;gt; threshold + hysteresisAmount)&lt;/p&gt;
&lt;p&gt;All you've done here is move the threshold to .8 so now the gamer holds the joystick at that point and still catches the break between two animations.&lt;/p&gt;
&lt;p&gt;To work like your example of a thermostat, you 'd have to modify the inputValue to something greater than your threshold. &amp;nbsp;As gamers generally don't like their input being modified that's probably not a good idea.&lt;/p&gt;
&lt;p&gt;The only way I see to handle the problem your suggesting is to do a moving average of the input value and test to see if that is greater than the threshold.&lt;/p&gt;
</description></item><item><title>re: Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#2262001</link><pubDate>Tue, 24 Apr 2007 19:57:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2262001</guid><dc:creator>GregGorman</dc:creator><description>&lt;p&gt;Doh! &amp;nbsp;It might help if made sure I understood what Hysteresis was first. &amp;nbsp;Then I would have seen more in your code than I did. &amp;nbsp;The implementation can't be reduced to one line like I did.&lt;/p&gt;
</description></item><item><title>re: Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#2262535</link><pubDate>Tue, 24 Apr 2007 20:52:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2262535</guid><dc:creator>zombiecrusher</dc:creator><description>&lt;p&gt;Hah, I was going to call you on that, but you beat me to it. :P&lt;/p&gt;
</description></item><item><title>re: Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#2266510</link><pubDate>Wed, 25 Apr 2007 04:09:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2266510</guid><dc:creator>trayle</dc:creator><description>&lt;p&gt;Ah but Greg and Zombie you have missed the point. &amp;nbsp; &amp;nbsp;If you hold the input at 0.79-0.81 it will only run the DoSomething() function until you get an input lower than 0.6. &amp;nbsp;So you don't get a situation where your bouncing back and forth between DoSomething() and OtherThing(). &amp;nbsp;If the input is bouncing between 0.79 and 0.81 there is no transition.&lt;/p&gt;
</description></item><item><title>re: Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#2275433</link><pubDate>Wed, 25 Apr 2007 22:30:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2275433</guid><dc:creator>GregGorman</dc:creator><description>&lt;p&gt;Thanks Trayle. &amp;nbsp;I saw that after I actually went to wikipedia and looked up hysteresis. &amp;nbsp;On my initial read through of the sample code I effectively reduced the algorithm to one line - which doesn't work with this implementation.&lt;/p&gt;
&lt;p&gt;Still another idea to achieve the same effect is to use a moving average of the input. &amp;nbsp;The moving average would add the element of time into the calculation in much the same was as the hysteresis value. A moving average seems to be a slightly more complex solution though.&lt;/p&gt;
</description></item><item><title>re: Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#2367744</link><pubDate>Wed, 02 May 2007 06:45:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2367744</guid><dc:creator>blargg</dc:creator><description>&lt;p&gt;The implementation shown doesn't clearly show that there was some hidden state added, that of the current action being performed. At first I also thought it wasn't demonstrating hysteresis. Without it, the action can be determined by the current input alone; with it, the previous action must also be taken into account. Here's another implementation that seems more direct to me (with concrete values for clarity):&lt;/p&gt;
&lt;p&gt;[code]static float threshold = 0.5;&lt;/p&gt;
&lt;p&gt;if ( input &amp;lt; threshold )&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;threshold = 0.6;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;below();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;else&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;threshold = 0.4;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;above();&lt;/p&gt;
&lt;p&gt;}[/code]&lt;/p&gt;
</description></item><item><title>re: Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#2368021</link><pubDate>Wed, 02 May 2007 07:06:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2368021</guid><dc:creator>ShawnHargreaves</dc:creator><description>&lt;p&gt;This bit seems like a pretty clear persistence of existing state to me:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;else&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;KeepOnDoingWhateverYouAlreadyAre();&lt;/p&gt;
</description></item><item><title>Blog on Game programming with the XNA Framework</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#2406371</link><pubDate>Fri, 04 May 2007 10:05:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2406371</guid><dc:creator>Walter Stiers - Academic Relations Team (BeLux)</dc:creator><description>&lt;p&gt;Shawn Hargreaves Blog announces the release of the Game State Management sample . His blog entry on Transitions&lt;/p&gt;</description></item><item><title>re: Hysteresis</title><link>http://blogs.msdn.com/shawnhar/archive/2007/04/23/hysteresis.aspx#9888879</link><pubDate>Sat, 29 Aug 2009 05:38:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9888879</guid><dc:creator>required</dc:creator><description>&lt;p&gt;Interessting, i will remember this!&lt;/p&gt;
&lt;p&gt;But your water heater example reminded me of a documentation video i saw about F-16's (Airplane) it has such an unstable non-aerodynamic form that only a computer can keep it in the air by chaning the position of the wings(the little things that go up and down at the end of a wing) all the time! The pilot's motion are then added to that. That way the whole thing stays stable... hmmm...&lt;/p&gt;</description></item></channel></rss>