Skip to content

Transform a float depending on 2 ranges

Ask for help here ;)

Transform a float depending on 2 ranges

Postby ren072 » 03 Aug 2011, 14:49

Hi,

Is there already existing something to do this?
I have an input float and an input range define by two floats. I want the input float to be expressed (transformed) depending on a second range. For ex:
- input value: 2.35
- input range: 1.2 to 10.23
- output range: -5.24 to 6.58
Should output: -3.73468
Also output value could be clamped by output range, meaning I wouldn't get output values out of the output range, even if input value get out of input range.

If there's nothing already existing, I would consider doing a smart block.

Thanks
ren072
 
Posts: 154
Joined: 21 Jun 2011, 14:00
Location: Belgium

Re: Transform a float depending on 2 ranges

Postby Neodrop » 03 Aug 2011, 18:03

Math >> Mathf Do >> Clamp
User avatar
Neodrop
Администратор
 
Posts: 1068
Joined: 15 Jan 2011, 13:18

Re: Transform a float depending on 2 ranges

Postby ren072 » 04 Aug 2011, 07:44

Thanks for your reply, but it's only part of the problem. I mainly have to remap a value from an input range to a new value in an output range.
Perhaps with lerp?

Thanks
ren072
 
Posts: 154
Joined: 21 Jun 2011, 14:00
Location: Belgium

Re: Transform a float depending on 2 ranges

Postby Neodrop » 04 Aug 2011, 08:09

It's can be processed like this :
Input (2.35) >> Clamp(1.2 and 10.23) >> Math Expression Calculator to get reletaion to 1 (one) and Clamp again between (-5.24 and 6.58)

But yes - in this case is better to write your own Smart Block. It's will be faster and shortly.
User avatar
Neodrop
Администратор
 
Posts: 1068
Joined: 15 Jan 2011, 13:18

Re: Transform a float depending on 2 ranges

Postby Trezvie » 27 Nov 2015, 14:14

This is very nice and cool post tahsnk for this ..........!!!!!!!!!!!!!!!!!!!!!!!!
Trezvie
 
Posts: 13
Joined: 26 Nov 2015, 15:32


Return to HELP!!!

Who is online

Registered users: No registered users