Re: How to calculate the aspect ratio for PerspectiveFovLH ?

From: ZMan (news-replies_at_thezbuffer)
Date: 10/30/04

Date: Sat, 30 Oct 2004 15:01:49 -0700

You as a programmer can never guarantee a pixel aspect ratio of 1.0. For a
start take a look at any of the many controls on most modern CRT monitors.
You can change the height, width and many other settings that would affect
the aspect ratio of all or part of the screen without the program having any
clue what is happening.

Now consider the different resolutions of most video cards - here's some
from mine:
 1600x1200 is 4:3, 1280x1024 5:4 1280x960 4:3 1280x768 5:3

So if your circle looks like a circle in 1280x1024 then it won't look like a
circle in 1280x768 and it might not look like a circle in someone elses

What you can do is assume that most PCs have 4:3 ratio monitors so the 4:3
modes are probably going to have the closest looking circles which is why
things generally work out. If you detect a different ratio for the screen
resolution you could maybe deduce they have a wide scrren monitor if the
ratio look 16:9 or you could apply some scale factor to try to correct for
their strange choice. Or if accuracy is very very important you could
display a circle and ask them to measure and adjust their monitor/resolution
or some parameters in your program until it matches.


" Just Me" <> wrote in message
> 1. I thought there was (and still might be) a video mode where it was not
> true that the pixel aspect ratio was 1.0. Glad to here that is not true.
> 2. FYI, I found "this.Width/this.Height" is used in the book I'm using
> but I think "(float)this.Width/this.Height" is better.
> I had something happing that prompted the question. I think I now know
> what the cause is.
> Thanks
> "Teis Draiby" <> wrote in message
> news:OG4brNHvEHA.2172@TK2MSFTNGP14.phx.gbl...
>>> If I want a circle to display as a circle seems it should be related to
>> how
>>> the display displays.
>> - What do you mean by that? Don't computer monitors by definition have a
>> pixel aspect ratio of 1.0? Correct me if I'm wrong.
>> The width/height ration of the render surface usually works fine, like
>> this:
>> device.Transform.Projection =
>> Matrix.PerspectiveFovLH((float)Math.PI/2.0F,
>> this.Width/this.Height, 1.0F, 10.0F);
>> regards, Teis