perspective() \ Language (API) \ Processing 1.0
Author: Casey Reas & Ben Fry
Description: Processing is an electronic sketchbook for developing ideas. It is a context for learning fundamentals of computer programming within the context of the electronic arts.
Keywords: Processing, Processing, Interactive Media, Electronic Arts, Programming, Java, Ben Fry, Casey Reas

Reference for Processing version 1.5. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name | ### perspective()
Examples |
    // Re-creates the default perspective
    size(100, 100, P3D);
    noFill();
    float fov = PI/3.0;
    float cameraZ = (height/2.0) / tan(fov/2.0);
    perspective(fov, float(width)/float(height),
                cameraZ/10.0, cameraZ*10.0);
    translate(50, 50, 0);
    rotateX(-PI/6);
    rotateY(PI/3);
    box(45);
Description | Sets a perspective projection applying foreshortening, making distant objects appear smaller than closer ones. The parameters define a viewing volume with the shape of truncated pyramid. Objects near to the front of the volume appear their actual size, while farther objects appear smaller. This projection simulates the perspective of the world more accurately than orthographic projection. The version of perspective without parameters sets the default perspective and the version with four parameters allows the programmer to set the area precisely. The default values are: perspective(PI/3.0, width/height, cameraZ/10.0, cameraZ*10.0) where cameraZ is ((height/2.0) / tan(PI*60.0/360.0));
Syntax |
    perspective()
    perspective(fov, aspect, zNear, zFar)
Parameters |
fov | float: field-of-view angle (in radians) for vertical direction
aspect | float: ratio of width to height
zNear | float: z-position of nearest clipping plane
zFar | float: z-position of nearest farthest plane
Returns | None
Usage | Web & Application

Updated on August 30, 2010 04:29:39pm EDT