Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
Normalize a logarithmic regression of distance

How would i go forth with creating a logarithmic gradient that increases as I go farther from a point in javascript. I would also like to normalize the values of this gradient to stay between 0 and 1. As of right now I have the folllowing methods:

generateGradient(x, y) {
        let distance = Math.sqrt(Math.pow((x - this.x), 2) + Math.pow((y - this.y), 2));
        return distance;
    }

This method is straightforward and just uses the distance formula from generic math Next I normalize these values to stay between zero and one:

normalize(x) {
        let x_normalized = (x - this.x) / (width - this.x);
        return Math.abs(x_normalized);
    }

Both these methods work as expected, tested with this for loop:

var light = new lightSource(100, 100);
for (var i = light.x+1; i < width; i++) {
    console.log(light.normalize(light.generateGradient(i, 100)));
}

The lightsource class is just a class with x and y variables that are used when instantiating it. The for loop generates values from 0 to 1 based on the distance, but how would I create a logarithmic regression.

I would like the values to increase exponentially as the distance increases

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!