Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

97
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda