Frage

I have several point values which I must display in a 3D chart with x, y and z axis. The problem is if one of the axis range is significantly greater than another the points aren't displayed properly. To avoid this I need to get all x,y,z values in a common range.

e.x - Greatest values of each axis,

x - 5.8
y - 0.6
z - 43700

What I need is something like,

x - 5.8
y - 6.0 *10^-1 
z - 4.37 *10^4

Where I only use the values 5.8, 0.6 and 4.37 to plot the points in the graph but use the power of 10 in the axis header to indicate the actual value range of the axis. (e.g in the y axis name is displayed as "y axis (10 ^ -1)"). To do this I need both 6.0 and 10^-1 values separately. How can I achieve this?

Thanks.

War es hilfreich?

Lösung

You can get the exponent by rounding down the decadic logarithm.

void normalized_notation(double x, double& a, int& exponent)
{
  exponent = (int)floor(log10(x));
  a = x / pow(10, exponent);
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top