Hi,

I developed a program which models the dynamics of a stellar disk. Rendering is done in 3D with rotation and zoom functionalities. Here's an image at the start of the simulation :

You can see on top the different statistics. My problem is about the initial value of the scale (100 kpc). Indeed, I use for initialization a perspective projection this way :

Code :if (isDisplayFirst) { isDisplayFirst = false; // Initialize View glViewport(0, 0, w_width, w_height); glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix /* perspective */ gluPerspective(45.0f, (float)w_width / w_height, g_nearPlane, g_farPlane); /* distance z = 3 */ gluLookAt (0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); /* zoom out = 100/3 */ glScalef(0.03f, 0.03f, 0.03f); }

My widget has the following dimensions :

Code :w_width = w_height = 600

So, from a simple computation, I think that I can have :

Code :Scale_value_Init = tan(45) * distance * zoom_out = 3*100/3 = 100

with

Code :distance = 3 and zoom_out = 100/3

To display the HUD (Head Up Display), I use a orthogonal projection and I draw a line of 100 pixels.

When I compare the "Scale_value_init" value with the average position values of each particle, I can see this initial value is a little too big.

There must be an arror in this initial value computation for scale bar.

Unities used in this program are "kpc" (kilo parsec) and I have set : 1 pixel = 1 kpc.

I just want to get a good value which gives a distance scale in (xy) plane.

Could you tell me why this calculus is wrong and give me some clues to get a good estimation ?