# The camera is always right

Put your camera location and look_at back to what we’ve been using.

location <0, 2, -10>

look_at <0, 0, 0>

All of the images we’ve made so far have been in “television format”. The width and the height are at an aspect ratio of 4 to 3, like a television set and like many computer monitors. As you’ll recall, I’ve been using 640 pixels wide by 480 pixels tall. Multiply 480 by 4/3 and you get 640.

This is a reasonable aspect ratio to work in, but it is not always what you want. Many computers now come with widescreen displays, and if you want to make a desktop background you’ll need to use a height and width that are not at a 4/3 aspect ratio.

For example, one common display size on widescreen displays is 1,680 pixels wide by 1,050 pixels tall. Go into the scene’s settings, go to the “Output” pane, and change the width to 1680 and the height to 1050. When you render the scene at this size, it will be oddly out of shape. The spheres will be stretched horizontally. That’s because our width and our height no longer match our aspect ratio.

We need to tell our camera to use the aspect ratio that matches the width and height we want. You can determine the aspect ratio by pulling out a calculator and dividing the width by the height. For 1,680 by 1,050, that’s an aspect ratio of 1.6.

The aspect ratio is the width divided by the height of the resulting image. In POV-Ray, you can tell the camera to use specific right and up triplets to determine the aspect ratio. The defaults that we’ve been using are:

right x*1.33

up y

The horizontal number (x) is 1.33. The vertical number (y) is unchanged at 1. This is the default aspect ratio of 4 to 3: four (horizontal) divided by three (vertical) is 1.33.

The up, with its unchanged y, is almost always what we want, so we can leave it at the default. What we’ll change is the right, which has the aspect ratio in it. We could change the 1.33 to 1.6 in this case, but we can also tell POV-Ray to calculate the aspect ratio automatically. POV-Ray has its own built-in calculator that you can use when you give it numbers. The built-in calculator also has some default values that depend on your scene. It has, for example, values for the image_width and the image_height. We can use those. The aspect ratio will be the image_width divided by the image_height.

camera {

location <0, 2, -10>

look_at <0, 0, 0>

right x*image_width/image_height

}

If you add that right line to your camera, you can experiment with rendering the scene in all sorts of shapes.

Try making a banner with a width of 700 pixels and a height of 100 pixels.

Once you’ve got the aspect ratio automatic, you don’t need the width to be larger than the height. Switch the width and height around so that your banner is 100 pixels wide and 700 pixels tall, and you’ll get a nice side-banner. Changing the aspect ratio is like reshaping the window on which you view the scene.

Take another look at those two banners. The wide one (700 by 100) shows the entire planet, tiny. The thin, tall one (100 by 700) shows only a portion of the planet, at about the same size as we’ve come to expect in our normal renderings.

The reason for the difference is that, in both cases, we are applying the aspect ratio change to the x, or right. When that change is large (700 divided by 100) we get a small image. When the change is tiny (100 divided by 700, we get a larger image.

If you want your vertical banner to show the entire planet in the same way it does in the horizontal banner, you can get that effect by applying the reverse change to the up, or y direction.

Remember that the default in POV-Ray is for right to be x*1.33 and for up to be y. If we choose to modify y instead of x, we have to tell POV-Ray to make right be just x.

camera {

location <0, 2, -10>

look_at <0, 0, 0>

//right x*image_width/image_height

right x

up y*image_height/image_width

}

Remember that when we put two slashes in front of a line, POV-Ray ignores that line. Look at the old right line and the new up line. What we’re doing to y in the up line is the opposite of what we did to the x in the right line. Instead of image_width divided by image_height, it is image_height divided by image_width. This produces the same size for the objects in the image as in our horizontal banner.