The dist() function creates unexpected values

Hello, I struggle with this code. I even tried to talk to the ChatGBT but didn’t help.

For some reason, “dist” creates big dips in its values and therefore bigger ellipses on the path where they should not be. See image.
How can I get rid of the big circles and just have the smooth line?
Can somebody help? Thank you.
Bildschirmfoto 2023-01-13 um 22.40.27

import processing.pdf.*;
import java.util.*;

PVector loc;
PVector old;

float angle, noiseZ, radiusN;

float radius = 100;
float ellipseSize;

float oldX, oldY, oldDist;
float alpha, size;

      float maxDist;
void setup() {
  size(800, 800);
  noiseDetail(1, 0.9);


  loc = new PVector(width/2, height/2);
  old = new PVector(0, 0);
maxDist = 1;
noiseZ = 0.0;

void draw() {


  translate(width/2, height/2);

    radiusN = radius + (1.0-sqrt(noise(noiseZ))) * 340; // SUPER
    float n = map(noise(noiseZ/2), 0. , 1.0 , -PI, PI);
    loc.x = cos(angle + n) * radiusN;
    loc.y = sin(angle + n) * radiusN;

 float dist = loc.dist(old);
  old =  loc.copy();
    if (frameCount > 6) {
     fill(dist*50,0,0.0, map(dist, 0., 4, 5, 30));

     ellipseSize = map(dist, 0.0, 4., 50., 5.);
     ellipse(loc.x, loc.y, ellipseSize, ellipseSize);
  angle += 0.005 ;
  noiseZ += 0.01;


Hi @JamOne,

Guess everything is ok with dist function.
Maybe you should check the doc about

Always it would be an idea to trace your values by ie. println to the console and check if they are as expected.

— mnse

Hey mnse,
thank you very much. I did trace the values with println(), that’s how I found the dist dips.
The map() function works excactly like it should be.

So maybe, there is a different way to implement noise() or another more elaborated noise() library somebody could recomend?