# Understanding camera() settings in Processing

I have trouble understanding the way a camera is set in Processing (according to the reference this shoudn't be very different from OpenGl). For starters, when I set the eye position of the camera I have to set three coordinates. I'm assuming that the X coordinate is the horizontal border of the display and the Y coordinate would be the vertical border. I think the Z coordinate to be behind or in front my computer.

So when I do:

camera(width/2, height/2, depth, 250, 250, 0, 0, 1, 0);


I'm setting the camera in the middle of the display and putting it some depth in the axis that comes into my eyes.

I think this part is clear enough. However, the two other parameters are not as clear. In particular in don't see the difference between the center of the scene and the last parameter which is the axis that is facing upward.

For the center of the scene I'm assuming that it gives me the direction the camera is looking to but what is the axis that is facing upward?

• Welcome to the CGSE! To get relevant help, you will have to add more context to your question. What tool or language are you using? Is "Processing" some setting of that tool? Commented Mar 7, 2017 at 15:56
• Thanks for your welcome. Processing is a tool for developing basic computer graphics programs. I edited my post. Commented Mar 7, 2017 at 16:00

As the documentation describes it, it looks like each group of three parameters is a vector in 3D space. The first three are the position of the “eye”, the next three are the position it’s looking at, and the last three are the “up vector”, i.e. the direction of an arrow pointing out of the top (…sort of—more detail below) of the eye. The positions aren’t related to the size of your display window—the view of your 3D geometry from the camera at that point will fill the display.

In other words, if you have a box centered at (0, 0, 0) that’s 1×1×1 units in size, then your camera should be positioned a few units away—say (2, 3, 4)—and looking roughly at the center of the box, i.e. (0, 0, 0). If the box is 100×100×100 instead, then the eye position should be on the same order of magnitude in distance, e.g. (200, 300, 400). The behavior of the up vector is a little more complicated to explain, but leaving it at (0,1,0) is fine for most purposes—it’s mostly there to help you avoid gimbal lock.