Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

101
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda