Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError using math.map #234

Open
fusepilot opened this issue Jun 26, 2015 · 0 comments
Open

RangeError using math.map #234

fusepilot opened this issue Jun 26, 2015 · 0 comments

Comments

@fusepilot
Copy link

Everytime I use math.map I forget that I need to clamp the input val and get a RangeError. So I need to write this currently:

var currentFrame = 0;
var startFrame = 10;
var endFrame = 20;
var clampedFrame = mout.math.clamp(currentFrame, startFrame, endFrame);
var result = mout.math.map(clampedFrame, startFrame, endFrame, 0, 100); // result == 0

instead of simply:

var currentFrame = 0;
var startFrame = 10;
var endFrame = 20;
var result = mout.math.map(currentFrame, startFrame, endFrame, 0, 100); // result == 0

There was a little discussion on this in #199.

I know its not technically correct, but can we remove the RangeError that is causing this in math.norm? Or, if that is too much of a philosophical problem, can we just inline the norm function without the RangeError inside of map so that norm retains its current behavior and map gets a little more robust?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants