Maths question - normalization I think
Hi,
Ill explain my math issue.
input.acceleration.x returns a value of -1 : 1
I have a speed rate of 4, if I multiply acceleration.x by speed at its maximum the speed is 4.
Now what I have done is clamped the returned acceleration using acceler.x = Mathf.Clamp (acceler.x, -0.3f, 0.3f);
this effectively creates a deadzone but I still want speed to equal 4 at the clamped maximum, now I'm sure its simple but I'm having a real brain ache with this.
Please help, Thanks
Answer by rutter · Oct 23, 2015 at 10:30 PM
If your input range is [-maxInput, maxInput]
and you'd like to multiply that out to the range [-maxOutput, maxOutput]
, then you can multiply your input by maxOutput / maxInput
.
For example, an input of 0.3
, multiplied by 4 / 0.3
, will become 4
.