math - C# XNA: Looking for a function like MathHelper.Clamp -


I have a function that many would assume, which needs to be normal to [1, 1] of the range. MathHelper.Clamp () takes only those values ​​that are out of range and sets them whatever is bound. Is there anything in XNA or C # that I see? (I see through the documentation, but I can not get it.)

This is the movement of the mouse, the value is different between the mouse coordinates between a tick and the next I'm not sure the maximum value for it What is this.

This function will take values ​​at a time - so there is no repeated at all prices to scale them all or to see what is the minimum and maximum.

I currently have it:

  // max - not minutes == 0 can personalize the private floatReorange (float value, float min, float max) { Returns (2.0 F * (Price - Minimum) / (Max - Minimum)) -1.0 F; }  

apply formula 2 * (x-min) / (max-min)

(x-min) / (max-min) gives you the value between 0 and 1

Multiplying by 2 gives you between 0 and 2 Value

decreases by 1 gives you the value between 1 and 1


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -