Code Monkey home page Code Monkey logo

Comments (2)

Rudxain avatar Rudxain commented on July 20, 2024

I'll list a summary of what I currently know and think about it:

Pros

  • Shorter, more concise code
  • Possibly a slight performance increase
  • Precision-preserving, because less arithmetic is needed to calculate it, and thus less rounding-errors
  • Increased likelihood of devs recognizing the methods because of their names

Cons

  • Slightly "pollutes" the Math namespace because the methods are easily replaceable
  • More names to remember
  • Less likelihood to be approved by the comitee, because they're too specialized and defined in terms of another method that's currently a proposal

I think I'm wrong about at least 1 of these, please let me know any mistakes.
I'll add more to both lists if I get requests to do so

from proposal-math-extensions.

Rudxain avatar Rudxain commented on July 20, 2024

Petition to add variadic relative normalization:

Math.normRelative = (...values) => {
	const min = Math.min(...values)
	const max = Math.max(...values)
	return values.map(
		x => (x - min) * 2 / (max - min) - 1
	)
}

This scales each value to the range [-1,+1], from a range relative to the minimum and maximum values themselves.

I'm aware that a Math.* method returning an Array is controversial, since every method should return a Number

from proposal-math-extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.