Loading...
Logo
Processing Forum

calculate increment

in Programming Questions  •  1 year ago  

i calculate the y increment with this:

Copy code
  1. yInc = plotHeight/gv.AL_persons.size();

which works fine as you can see in the image.
The maximum diameter get's calculated with:

Copy code
  1. float maxDiameter = (yInc/1.5f)+(2*gv.maxEmailsMonth); 

Which also works fine (red).
If you look good then you see the horizontal lines also behind the red, i want to skip there the space of maxDiameter. But for that the y increment must decrease and since that happens the maxDiameter should also since they relay on each other.

I'm guessing that calculating a close value for those 2 must be done in a loop, since each iteration will bring the best possible value closer. Only the tries i made are not correct, it's leaving me a too big white space at the bottom (like 3x maxDiameter).


Copy code
  1. yInc = plotHeight/gv.AL_persons.size();
  2. float maxDiameter = (yInc/1.5f)+(2*gv.maxEmailsMonth);
  3. for(int i = 0; i < 999; i++) {
  4. yInc = (plotHeight-maxDiameter)/gv.AL_persons.size()-1;
  5. maxDiameter = (yInc/1.5f)+(2*gv.maxEmailsMonth);
  6. }


Replies(1)

My question was a bit bad formulated, it can be quite hard if your not fit and not a native english speaker. I doubt that someone ever returns here after a few days but someone helped me today, the solution turns out to be quite simple:

Copy code
  1. float yInc = plotHeight/gv.AL_persons.size();
  2. float maxDiameter = (yInc/1.5f)+(2*gv.maxEmailsMonth);  // needed to calculate the skip
  3. float scale = plotHeight/(plotHeight+maxDiameter);
  4. maxDiameter *= scale;
  5. yInc *= scale;