Counting point size based on chart area during zooming/unzoomin

Posted by Gacek on Stack Overflow See other posts from Stack Overflow or by Gacek
Published on 2010-06-16T15:53:17Z Indexed on 2010/06/16 16:02 UTC
Read the original article Hit count: 201

Filed under:
|
|

Hi folks.

I heave a quite simple task. I know (I suppose) it should be easy, but from the reasons I cannot understand, I try to solve it since 2 days and I don't know where I'm making the mistake.

So, the problem is as follows:
- we have a chart with some points
- The chart starts with some known area and points have known size
- we would like to "emulate" the zooming effect. So when we zoom to some part of the chart, the size of points is getting proportionally bigger. In other words, the smaller part of the chart we select, the bigger the point should get.

So, we have something like that. We know this two parameters:

initialArea; // Initial area - area of the whole chart, counted as width*height 
initialSize; // initial size of the points

Now lets assume we are handling some kind of OnZoom event. We selected some part of the chart and would like to count the current size of the points

float CountSizeOnZoom()
{
float currentArea = CountArea(...); // the area is counted for us. 
float currentSize = initialSize * initialArea / currentArea;
return currentSize;
}

And it works. But the rate of change is too fast. In other words, the points are getting really big too soon. So I would like the currentSize to be invertly proportional to currentArea, but with some scaling coefficient.

So I created the second function:

float CountSizeOnZoom()
{
float currentArea = CountArea(...); % the area is counted for us. 
// Lets assume we want the size of points to change ten times slower, than area of the chart changed.
float currentSize = initialSize + 0.1f* initialSize * ((initialArea / currentArea) -1);
return currentSize;
}

Lets do some calculations in mind.
if currentArea is smaller than initialArea, initialArea/currentArea > 1 and then we add "something" small and postive to initialSize. Checked, it works.

Lets check what happens if we would un-zoom. currentArea will be equal to initialArea, so we would have 0 at the right side (1-1), so new size should be equal to initialSize. Right? Yeah. So lets check it... and it doesn't work.

My question is: where is the mistake? Or maybe you have any ideas how to count this scaled size depending on current area in some other way?

© Stack Overflow or respective owner

Related posts about math

Related posts about Charting