PDA

View Full Version : Draw a shpere, but look more like an egg, what's matter?



reader1
04-25-2015, 10:16 AM
command
glutSolidSphere(0.8,32,22);
but look more like an egg, odd enough.
whT'S MATTER?

reader1
04-25-2015, 10:22 AM
remark,screen has been calibrated.

Aleksandar
04-25-2015, 11:29 AM
Wrong aspect of the viewport!

reader1
04-25-2015, 06:25 PM
Wrong aspect of the viewport!
aspect has been cal, too.

glLoadIdentity ();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 60.0);
where w/l=300/300

reader1
04-25-2015, 07:16 PM
when draw a cycle, it looks perfect round!

Aleksandar
04-26-2015, 04:41 AM
OK, then the distortion is a side effect of the wide field-of-view (FOV).
Narrow down the FOV and move camera back (i.e. set the first parameter of gluPerspective() to 40 or 45).

reader1
04-26-2015, 06:30 AM
OK, then the distortion is a side effect of the wide field-of-view (FOV).
Narrow down the FOV and move camera back (i.e. set the first parameter of gluPerspective() to 40 or 45).
That's reasonable, but 60 degree is a normal fov of our human being. howevr I shall have a try.

Aleksandar
04-26-2015, 07:27 AM
That's reasonable, but 60 degree is a normal fov of our human being.
Actually, it is not! FOV depends on the viewer's distance from the monitor.

In order to make analysis simpler, let's assume the human eye is a standard camera sensor. Since the focal length of the human eye is 48.24mm, an equivalent vertical FOV should be about 41 deg.

Nowadays, applications and games usually make fixed horizontal FOV, probably because the use of wide screen monitors. Maybe you saw that someone suggested the usage of 60 deg, but probably for the horizontal FOV.

GClements
04-26-2015, 08:01 AM
In order to make analysis simpler, let's assume the human eye is a standard camera sensor. Since the focal length of the human eye is 48.24mm, an equivalent vertical FOV should be about 41 deg.
Focal length has nothing to do with it.

The "correct" field of view angle is dictated by the size of the monitor and the distance of the eye from the monitor. The angle should be that subtended by the edges of the monitor. If the distance is d and the size (height for vertical field-of-view angle, width for horizontal) is s, then the field-of-view angle should be 2.arctan(s/2d).

But this will be far too narrow for most uses, resulting in a "blinkered" view. Imagine creating a rectangular paper cone with the monitor as its base and your eyes looking through its apex. For any reasonable viewing distance, the angle is so narrow that you'd have great difficulty walking around with your view so restricted.

So most applications choose a compromise between a field of view which is large enough to be useful while not being so large as to produce extreme distortion. Performance may also be a factor (a wider view angle makes more of the world visible, potentially increasing rendering load).

Aleksandar
04-26-2015, 08:36 AM
Focal length has nothing to do with it.

It does if you need to overlap artificially generated image and the picture from the real camera, link in augmented reality.
In that case, the following parameters of the sensor are important to calculate FOV: aspect, size and focal length.

We agree on the way how FOV should be calculated. But since we cannot predict the size of the monitor and the viewer's distance, I used a standard sensor analogy.

reader1
04-26-2015, 09:27 AM
Actually, it is not! FOV depends on the viewer's distance from the monitor.

That will depend on how you define fov, now we talk about angle, thus it has nothig to do with distance how far we are from the monitor.


In order to make analysis simpler, let's assume the human eye is a standard camera sensor. Since the focal length of the human eye is 48.24mm, an equivalent vertical FOV should be about 41 deg.

Nowadays, applications and games usually make fixed horizontal FOV, probably because the use of wide screen monitors. Maybe you saw that someone suggested the usage of 60 deg, but probably for the horizontal FOV.
I see, but I remember that human being's eye forcus is 35-42mm, thus, we have standard 35mm film.
I shall check it.
and our horizon fov, I remember is 110degree. of cause vertical aspect is lower than this number, thus we have 16:9 concept. from the point of view of a painter, however, 60 degree is a good nomal view angle. no distortion from this angle.

reader1
04-26-2015, 09:39 AM
Focal length has nothing to do with it.
d).
focal distance has something to do with it. you can deduce it from object, imagine and focus relationship.


The "correct" field of view angle is dictated by the size of the monitor and the distance of the eye from the monitor. The angle should be that subtended by the edges of the monitor. If the distance is d and the size (height for vertical field-of-view angle, width for horizontal) is s, then the field-of-view angle should be 2.arctan(s/2d).

But this will be far too narrow for most uses, resulting in a "blinkered" view. Imagine creating a rectangular paper cone with the monitor as its base and your eyes looking through its apex. For any reasonable viewing distance, the angle is so narrow that you'd have great difficulty walking around with your view so restricted.

So most applications choose a compromise between a field of view which is large enough to be useful while not being so large as to produce extreme distortion. Performance may also be a factor (a wider view angle makes more of the world visible, potentially increasing rendering loa
the fomula you deduced is correct.
so it is, wide-angle or fish-eye lens can watch more wider world, but with distortion. which can form a certain art exagration.

reader1
04-26-2015, 09:50 AM
It does if you need to overlap artificially generated image and the picture from the real camera, link in augmented reality.
In that case, the following parameters of the sensor are important to calculate FOV: aspect, size and focal length.

We agree on the way how FOV should be calculated. But since we cannot predict the size of the monitor and the viewer's distance, I used a standard sensor analogy.

both of your two are correct, just discuss from differnt aspect.
back to our topic, we can set them by glPerspective and glLookat, I change the angle to 40, it seems there is no much improvement.

reader1
04-26-2015, 09:54 AM
here is pic,
1762
1763
this pic takes about 200ms to draw.

reader1
04-26-2015, 07:18 PM
Correct:
I browse the cyber net, explanation is confusion. I sumarize that the human being nomal focal length should be 17.2mm. The standard of 35mm or 50mm lens will have similar fov with human being.

fov=110degree(h) x 80deg(v).

reader1
04-27-2015, 08:17 AM
After a bout of comparation, I find when it sites at center, it looks like perfect circle.
when draw a circle at that location, it's also perfect.
what's matter?

reader1
04-27-2015, 08:57 AM
1764
Look, as if they are projected to a curved surface, not on the plane.
What caused this distortion?

Alfonse Reinheart
04-27-2015, 09:30 AM
That is simply the effect of projecting any object. Your distortion is exaggerated because it's rather large (or that it's apparent size is large relative to its distance to the camera).

Hold a ball really close to your eye, and it too will not appear circular.

GClements
04-27-2015, 09:47 AM
What caused this distortion?
Projecting a sphere to a point results in a circular cone, whose axis is the line through the projection origin and the centre of the sphere. If the axis is perpendicular to the projection plane, the intersection of that cone with the projection plane will be a circle. Otherwise, provided that the projection plane doesn't intersect the sphere, it will be an ellipse (if the projection plane does intersect the sphere, it will be a parabola or a hyperbola).

See e.g. the Wikipedia page for Conic section (http://en.wikipedia.org/wiki/Conic_section) for some background.

In short, the perspective projection of a sphere is only a circle if the sphere is in the "centre" of the view (that's the projection centre, i.e. the line through the projection origin which is perpendicular to the projection plane; which isn't necessarily the centre of the viewport).

The eccentricity of the ellipse increases as the centre of the sphere moves farther from the centre of the view. The eccentricity is effectively limited by the field-of-view angle, as cases resulting in high eccentricity will be wholly or mostly outside of the view, so increasing the field-of-view angle increases the maximum eccentricity which can be obtained for a sphere which is entirely within the view frustum.

reader1
04-27-2015, 06:21 PM
That is simply the effect of projecting any object. Your distortion is exaggerated because it's rather large (or that it's apparent size is large relative to its distance to the camera).

Hold a ball really close to your eye, and it too will not appear circular.
No, you are confusing geo projection and real wide-angle lens. we can imitate it, but here not..

reader1
04-27-2015, 06:29 PM
Projecting a sphere to a point results in a circular cone, whose axis is the line through the projection origin and the centre of the sphere. If the axis is perpendicular to the projection plane, the intersection of that cone with the projection plane will be a circle. Otherwise, provided that the projection plane doesn't intersect the sphere, it will be an ellipse (if the projection plane does intersect the sphere, it will be a parabola or a hyperbola).

See e.g. the Wikipedia page for Conic section (http://en.wikipedia.org/wiki/Conic_section) for some background.

In short, the perspective projection of a sphere is only a circle if the sphere is in the "centre" of the view (that's the projection centre, i.e. the line through the projection origin which is perpendicular to the projection plane; which isn't necessarily the centre of the viewport).

The eccentricity of the ellipse increases as the centre of the sphere moves farther from the centre of the view. The eccentricity is effectively limited by the field-of-view angle, as cases resulting in high eccentricity will be wholly or mostly outside of the view, so increasing the field-of-view angle increases the maximum eccentricity which can be obtained for a sphere which is entirely within the view frustum.
It is different conic sections of a cone. which form differnt curve. similarly, if you cut a cycline, you could get an ellipse profile, but if you cut a sphere, you will always get a circle.

reader1
04-27-2015, 09:21 PM
try this code to show on your computer to verify if it is a circle?

display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 0.6, 0.1);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(50.0, 1, 1.0, 60.0);
glMatrixMode(GL_MODELVIEW);

gluLookAt(0.0,0.0,12.0, 0.0,0.0,3.0, 0.0,1.0,0.0);
glTranslatef(-3.0,-3.5,-6.0);
glutSolidSphere(2.8,32,32);

//glLineWidth(6.0);
Draw_Circle(0,0,2,22);

glLoadIdentity();
glTranslatef(0.0,0.0,-15.0);
glRotatef(20,1.0,0.0,0.0);
glutSolidSphere(0.8,32,32);
// glutSolidTeapot(1);

glLoadIdentity();
glTranslatef(-1.5,1.5,-6.0);
GLUquadricObj *obj;
obj=gluNewQuadric();
gluQuadricDrawStyle(obj,GLU_LINE);
gluSphere(obj,1.0,30,30); //wire feature.

glLoadIdentity();
glPushMatrix();
glColor3f(1.0,1.0,0.0);
glTranslatef(1.0,1.0,-5.0);
glRotatef(90,0.0,0.0,1.0);
gluPartialDisk(obj,0.3,1.6,22,22,60.0,100.0);

glTranslatef(1.6,-1.8,-7.0);
glutSolidSphere(0.8,32,32);

glutSwapBuffers();
}