Fit Range To Another Range

27 views
Skip to first unread message

Francesco

unread,
Jul 25, 2019, 1:37:28 AM7/25/19
to Python Programming for Autodesk Maya
Hi everybody!

I have a quick question on how to modify one range to another one. Let's say my initial range is (-1, 1) and my new range is (3, 7), what mathematical formula would I use to match the two?

Thanks!

tomas mikulak

unread,
Jul 25, 2019, 1:42:39 AM7/25/19
to python_in...@googlegroups.com
Hi, maya has fit() function

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4f99a396-2cb9-4caa-b51d-797fe3173a23%40googlegroups.com.

Francesco

unread,
Jul 25, 2019, 4:19:15 AM7/25/19
to Python Programming for Autodesk Maya
Hi Thomas, thank you for the quick answer! I'm aware there is a fit function but I was curious to know the mathematical formula behind it.

Justin Israel

unread,
Jul 25, 2019, 6:53:13 AM7/25/19
to python_in...@googlegroups.com


On Thu, Jul 25, 2019, 8:19 PM Francesco <vetu...@gmail.com> wrote:
Hi Thomas, thank you for the quick answer! I'm aware there is a fit function but I was curious to know the mathematical formula behind it.


On Wednesday, July 24, 2019 at 10:42:39 PM UTC-7, tomas mikulak wrote:
Hi, maya has fit() function



tomas

On Thu, 25 Jul 2019 at 07:37, Francesco <vetu...@gmail.com> wrote:
Hi everybody!

I have a quick question on how to modify one range to another one. Let's say my initial range is (-1, 1) and my new range is (3, 7), what mathematical formula would I use to match the two?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
Message has been deleted

Francesco

unread,
Jul 25, 2019, 1:40:50 PM7/25/19
to Python Programming for Autodesk Maya
Hi Justin, thank you that really helps! I see the formula, but I still don't fully understand it (my math knowledge isn't that great). I don't see how the numbers I have would plug into the formula, if anyone can explain it would help a lot!

Justin Israel

unread,
Jul 25, 2019, 5:24:55 PM7/25/19
to python_in...@googlegroups.com
On Fri, Jul 26, 2019 at 5:40 AM Francesco <vetu...@gmail.com> wrote:
Hi Justin, thank you that really helps! I see the formula, but I still don't fully understand it (my math knowledge isn't that great). I don't see how the numbers I have would plug into the formula, if anyone can explain it would help a lot!

This would be a direct translation of that formula to a function:

def fit(x, min_x, max_x, a=0, b=1):
    return a + ((((x - min_x)) * float(b-a)) / (max_x - min_x))

fit(5, 0, 10)
# 0.5

fit(0.5, 0, 1, 0, 100)
# 50.0

It doesn't have any error checking like preventing a divide-by-zero.  


On Thursday, July 25, 2019 at 3:53:13 AM UTC-7, Justin Israel wrote:


On Thu, Jul 25, 2019, 8:19 PM Francesco <vetu...@gmail.com> wrote:
Hi Thomas, thank you for the quick answer! I'm aware there is a fit function but I was curious to know the mathematical formula behind it.



On Wednesday, July 24, 2019 at 10:42:39 PM UTC-7, tomas mikulak wrote:
Hi, maya has fit() function



tomas

On Thu, 25 Jul 2019 at 07:37, Francesco <vetu...@gmail.com> wrote:
Hi everybody!

I have a quick question on how to modify one range to another one. Let's say my initial range is (-1, 1) and my new range is (3, 7), what mathematical formula would I use to match the two?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages