HIDIHO!

giving something back to the Flash community

hysteresis and a non ideal relay

Tags: , , , ,

cover
And here we go again for a useless script !

The hysteresis is a physics phenomenon involved when a force affects a body.

Given a cause C providing an effect E. There is hysteresis when the E = f( C ) curve obtained while C increases does not overlap the E = f( C ) curve obtained when C decreases.

ok I gave it a try now you can check the official version on  wikipedia of course but mostly you should give this a try. It is comprehensive and easier to understand.

You can think of the behavior of a water dropplet that will first repell the other dropplets and then, when they finally melt, try to retain the others around it. same move, different direction, different behaviour.

now why is it even interesting?

First of all because I like the name of it…

Second because it could be used to create ‘realistic’ interfaces and interactions between materials in physics engines thus  opening the haptic desktop era

well, for now it’s just about having a non ideal relay system: http://euclid.ucc.ie/hysteresis/node9.htm

so the class is VERY simple:  we set an Alpha and a Beta value

var nir:NonIdealRelay = new NonIdealRelay( -1,1 );

then we pass it a Gamma(the slider value) with the direction (positive/negative Number).

nir.check( gamma, direction );

then the class sets its two boolean getters ( alpha/beta) to true or false depending on the direction and the gamma value.
for instance you could get this type of prose. the first 2 params are values passed to the check() method:

2, 1 alpha: false beta: true
—————————–
-1, -1 alpha: false beta: true
—————————–
-2, -1 alpha: true beta: false

if the direction is negative (ie slider is decreasing) and the value of the slider is smaller than the Alpha value of the relay then the state alpha is true.

if the direction is positive(ie slider is increasing) and the value of the slider is higher than the Beta value of the relay then the state beta is true.

see the sample hereunder:

so you move the slider and you can see that there are two ways you can be between -1 and 1 either on top or at the bottom. when you actually switch to the alpha or beta state, the red line ‘jumps’ up or down.

another good thing is that you can add so many relays as you want in between alpha an beta states.
here’s an example with 5 relays distributed with regular thresholds

and another with an hundred relays random alpha/beta thresholds

notice how the behavior is affected by the state ( alpha/beta) of the relay. red/blue depend on the direction

I told you it would be useless but forgot to mention it would also be long and boring :)
here’s the most interesting feature for each single relay:

we can assigns two different ‘motions rules’ for the alpha and beta states.
now red is when the relay is on alpha state and blue when on beta.
motion is a property and could be replaced by or combined with anything.

I don’t have a clue what I’ll use this for but I will use it for sure,
I just wanted to share this as is :)

Tags: , , , ,

© 2009 HIDIHO!. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.