Top Banner
Projections and their transformations
208

Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Mar 20, 2018

Download

Documents

trinhkien
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

Page 2: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world.

Page 3: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world. The final image, however, will be displayed on a 2-

dimensional surface.

Page 4: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world. The final image, however, will be displayed on a 2-

dimensional surface.

The transformation from the 3-dimensional model space to the

2-dimensional viewing space is accomplished by projecting the

model onto the view or projection plane.

Page 5: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world. The final image, however, will be displayed on a 2-

dimensional surface.

The transformation from the 3-dimensional model space to the

2-dimensional viewing space is accomplished by projecting the

model onto the view or projection plane.

Here is where our “virtual camera” model offers a good analogy.

Page 6: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world. The final image, however, will be displayed on a 2-

dimensional surface.

The transformation from the 3-dimensional model space to the

2-dimensional viewing space is accomplished by projecting the

model onto the view or projection plane.

Here is where our “virtual camera” model offers a good analogy.

camera

scene

view plane

Page 7: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world. The final image, however, will be displayed on a 2-

dimensional surface.

The transformation from the 3-dimensional model space to the

2-dimensional viewing space is accomplished by projecting the

model onto the view or projection plane.

Here is where our “virtual camera” model offers a good analogy.

camera

scene

view plane

Modeling transforms position the model.

Page 8: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world. The final image, however, will be displayed on a 2-

dimensional surface.

The transformation from the 3-dimensional model space to the

2-dimensional viewing space is accomplished by projecting the

model onto the view or projection plane.

Here is where our “virtual camera” model offers a good analogy.

camera

scene

view plane

Modeling transforms position the model. Viewing transforms

position the camera.

Page 9: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world. The final image, however, will be displayed on a 2-

dimensional surface.

The transformation from the 3-dimensional model space to the

2-dimensional viewing space is accomplished by projecting the

model onto the view or projection plane.

Here is where our “virtual camera” model offers a good analogy.

camera

scene

view plane

Modeling transforms position the model. Viewing transforms

position the camera. Projection transforms control the type of

lens, the focal length, etc...

Page 10: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world. The final image, however, will be displayed on a 2-

dimensional surface.

The transformation from the 3-dimensional model space to the

2-dimensional viewing space is accomplished by projecting the

model onto the view or projection plane.

Here is where our “virtual camera” model offers a good analogy.

camera

scene

view plane

Modeling transforms position the model. Viewing transforms

position the camera. Projection transforms control the type of

lens, the focal length, etc...

Things are really a bit different, however, because with com-

puter graphics we have rather more freedom than we have with

a camera.

Page 11: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Projections and their transformations

We have looked at modeling 3-dimensional figures in a 3-dimensional

world. The final image, however, will be displayed on a 2-

dimensional surface.

The transformation from the 3-dimensional model space to the

2-dimensional viewing space is accomplished by projecting the

model onto the view or projection plane.

Here is where our “virtual camera” model offers a good analogy.

camera

scene

view plane

Modeling transforms position the model. Viewing transforms

position the camera. Projection transforms control the type of

lens, the focal length, etc...

Things are really a bit different, however, because with com-

puter graphics we have rather more freedom than we have with

a camera.

1

Page 12: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

There are two basic projections we will discuss — parallel projections

and perspective projections.

Page 13: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

There are two basic projections we will discuss — parallel projections

and perspective projections.

Parallel projections

Page 14: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

There are two basic projections we will discuss — parallel projections

and perspective projections.

Parallel projections

The basic property of a parallel projection is that features are

projected by parallel rays onto the viewing surface.

Page 15: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

There are two basic projections we will discuss — parallel projections

and perspective projections.

Parallel projections

The basic property of a parallel projection is that features are

projected by parallel rays onto the viewing surface.

Page 16: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

There are two basic projections we will discuss — parallel projections

and perspective projections.

Parallel projections

The basic property of a parallel projection is that features are

projected by parallel rays onto the viewing surface.

There are again two types of parallel projections

Page 17: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

There are two basic projections we will discuss — parallel projections

and perspective projections.

Parallel projections

The basic property of a parallel projection is that features are

projected by parallel rays onto the viewing surface.

There are again two types of parallel projections — projec-

tions in which the projection is parallel to the normal of the

viewing surface are orthographic projections;

Page 18: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

There are two basic projections we will discuss — parallel projections

and perspective projections.

Parallel projections

The basic property of a parallel projection is that features are

projected by parallel rays onto the viewing surface.

There are again two types of parallel projections — projec-

tions in which the projection is parallel to the normal of the

viewing surface are orthographic projections; projections where

the projection rays are not normal to the surface are oblique

projections.

Page 19: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

There are two basic projections we will discuss — parallel projections

and perspective projections.

Parallel projections

The basic property of a parallel projection is that features are

projected by parallel rays onto the viewing surface.

There are again two types of parallel projections — projec-

tions in which the projection is parallel to the normal of the

viewing surface are orthographic projections; projections where

the projection rays are not normal to the surface are oblique

projections.

2

Page 20: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans.

Page 21: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Page 22: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Page 23: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Orthographic projections preserve the distance along lines which

are parallel to the plane of projection.

Page 24: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Orthographic projections preserve the distance along lines which

are parallel to the plane of projection. Thus, one can take

measurements along such lines directly from their projections.

Page 25: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Orthographic projections preserve the distance along lines which

are parallel to the plane of projection. Thus, one can take

measurements along such lines directly from their projections.

Also, lines which are parallel will be projected to parallel lines.

Page 26: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Orthographic projections preserve the distance along lines which

are parallel to the plane of projection. Thus, one can take

measurements along such lines directly from their projections.

Also, lines which are parallel will be projected to parallel lines.

The isometric projection has the direction of projection at the

same angle to all three principal axes.

Page 27: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Orthographic projections preserve the distance along lines which

are parallel to the plane of projection. Thus, one can take

measurements along such lines directly from their projections.

Also, lines which are parallel will be projected to parallel lines.

The isometric projection has the direction of projection at the

same angle to all three principal axes.

Page 28: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Orthographic projections preserve the distance along lines which

are parallel to the plane of projection. Thus, one can take

measurements along such lines directly from their projections.

Also, lines which are parallel will be projected to parallel lines.

The isometric projection has the direction of projection at the

same angle to all three principal axes.

The isometric projection has the property that all 3 axes can

be measured on the same scale.

Page 29: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Orthographic projections preserve the distance along lines which

are parallel to the plane of projection. Thus, one can take

measurements along such lines directly from their projections.

Also, lines which are parallel will be projected to parallel lines.

The isometric projection has the direction of projection at the

same angle to all three principal axes.

The isometric projection has the property that all 3 axes can

be measured on the same scale. For an isometric projection of

cube, all projected lines have the same length.

Page 30: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Orthographic projections preserve the distance along lines which

are parallel to the plane of projection. Thus, one can take

measurements along such lines directly from their projections.

Also, lines which are parallel will be projected to parallel lines.

The isometric projection has the direction of projection at the

same angle to all three principal axes.

The isometric projection has the property that all 3 axes can

be measured on the same scale. For an isometric projection of

cube, all projected lines have the same length.

Page 31: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

A common set of orthographic projections are the front, side,

and top views typical of architectural plans. In this case the

projections are parallel to the model’s principal axes.

Top viewFront view Side view

Orthographic projections preserve the distance along lines which

are parallel to the plane of projection. Thus, one can take

measurements along such lines directly from their projections.

Also, lines which are parallel will be projected to parallel lines.

The isometric projection has the direction of projection at the

same angle to all three principal axes.

The isometric projection has the property that all 3 axes can

be measured on the same scale. For an isometric projection of

cube, all projected lines have the same length.

3

Page 32: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Isometric projections are a special case of axonometric orthographic

projections.

Page 33: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Isometric projections are a special case of axonometric orthographic

projections. Such projections use projection planes that are

not normal to a principal axis.

Page 34: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Isometric projections are a special case of axonometric orthographic

projections. Such projections use projection planes that are

not normal to a principal axis. Axonometric orthographic pro-

jections give the illusion of perspective but do not exhibit true

perspective foreshortening, where the length of projected lines

are dependent upon their distance from the projection plane.

Page 35: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Isometric projections are a special case of axonometric orthographic

projections. Such projections use projection planes that are

not normal to a principal axis. Axonometric orthographic pro-

jections give the illusion of perspective but do not exhibit true

perspective foreshortening, where the length of projected lines

are dependent upon their distance from the projection plane.

4

Page 36: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

[From urlwww.kirupa.com/developer/isometric/perspective.htm]

Page 37: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

[From urlwww.kirupa.com/developer/isometric/perspective.htm]

Such projections have been popular in video games for many

years.

5

Page 38: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Oblique projections

Oblique projections are the most general parallel views.

Page 39: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Oblique projections

Oblique projections are the most general parallel views. In an

oblique projection, the projectors make some arbitrary angle

with the projection plane.

Page 40: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Oblique projections

Oblique projections are the most general parallel views. In an

oblique projection, the projectors make some arbitrary angle

with the projection plane.

Page 41: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Oblique projections

Oblique projections are the most general parallel views. In an

oblique projection, the projectors make some arbitrary angle

with the projection plane.

These views are somewhat unnatural, but can be used to convey

more information than orthographic projections.

Page 42: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Oblique projections

Oblique projections are the most general parallel views. In an

oblique projection, the projectors make some arbitrary angle

with the projection plane.

These views are somewhat unnatural, but can be used to convey

more information than orthographic projections.

The human eye, and most other physical viewing devices, have

a lens fixed with respect to (and usually parallel to) the viewing

plane.

Page 43: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Oblique projections

Oblique projections are the most general parallel views. In an

oblique projection, the projectors make some arbitrary angle

with the projection plane.

These views are somewhat unnatural, but can be used to convey

more information than orthographic projections.

The human eye, and most other physical viewing devices, have

a lens fixed with respect to (and usually parallel to) the viewing

plane. This is what makes oblique projections seem unnatural.

Page 44: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Oblique projections

Oblique projections are the most general parallel views. In an

oblique projection, the projectors make some arbitrary angle

with the projection plane.

These views are somewhat unnatural, but can be used to convey

more information than orthographic projections.

The human eye, and most other physical viewing devices, have

a lens fixed with respect to (and usually parallel to) the viewing

plane. This is what makes oblique projections seem unnatural.

6

Page 45: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections

Page 46: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections

In a perspective projection, the projecting rays are not parallel,

but instead pass through one or more vanishing points or points

at infinity.

Page 47: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections

In a perspective projection, the projecting rays are not parallel,

but instead pass through one or more vanishing points or points

at infinity.

Page 48: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections

In a perspective projection, the projecting rays are not parallel,

but instead pass through one or more vanishing points or points

at infinity.

Note that lines which are parallel in the model actually converge

in the “far distance.”

Page 49: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections

In a perspective projection, the projecting rays are not parallel,

but instead pass through one or more vanishing points or points

at infinity.

Note that lines which are parallel in the model actually converge

in the “far distance.” This creates an illusion of depth in a 2-

dimensional figure.

Page 50: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections

In a perspective projection, the projecting rays are not parallel,

but instead pass through one or more vanishing points or points

at infinity.

Note that lines which are parallel in the model actually converge

in the “far distance.” This creates an illusion of depth in a 2-

dimensional figure.

7

Page 51: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Two point perspective would use 2 vanishing points, roughly

orthogonal to each other in the “model world.”

Page 52: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Two point perspective would use 2 vanishing points, roughly

orthogonal to each other in the “model world.” Three point

perspective would use 3 vanishing points.

Page 53: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Two point perspective would use 2 vanishing points, roughly

orthogonal to each other in the “model world.” Three point

perspective would use 3 vanishing points.

Page 54: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Two point perspective would use 2 vanishing points, roughly

orthogonal to each other in the “model world.” Three point

perspective would use 3 vanishing points.

[From www.csse.monash.edu.au/∼aland/notes]

Page 55: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Two point perspective would use 2 vanishing points, roughly

orthogonal to each other in the “model world.” Three point

perspective would use 3 vanishing points.

[From www.csse.monash.edu.au/∼aland/notes]

Note that OpenGL has no concept of the number of vanishing

points.

Page 56: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Two point perspective would use 2 vanishing points, roughly

orthogonal to each other in the “model world.” Three point

perspective would use 3 vanishing points.

[From www.csse.monash.edu.au/∼aland/notes]

Note that OpenGL has no concept of the number of vanishing

points. This is a notion from the worlds of classical art and

drafting.

Page 57: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Two point perspective would use 2 vanishing points, roughly

orthogonal to each other in the “model world.” Three point

perspective would use 3 vanishing points.

[From www.csse.monash.edu.au/∼aland/notes]

Note that OpenGL has no concept of the number of vanishing

points. This is a notion from the worlds of classical art and

drafting.

In a perspective projection, we need to specify a point as the

center of projection;

Page 58: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Two point perspective would use 2 vanishing points, roughly

orthogonal to each other in the “model world.” Three point

perspective would use 3 vanishing points.

[From www.csse.monash.edu.au/∼aland/notes]

Note that OpenGL has no concept of the number of vanishing

points. This is a notion from the worlds of classical art and

drafting.

In a perspective projection, we need to specify a point as the

center of projection; for parallel projections we needed to spec-

ify a direction of projection.

Page 59: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Two point perspective would use 2 vanishing points, roughly

orthogonal to each other in the “model world.” Three point

perspective would use 3 vanishing points.

[From www.csse.monash.edu.au/∼aland/notes]

Note that OpenGL has no concept of the number of vanishing

points. This is a notion from the worlds of classical art and

drafting.

In a perspective projection, we need to specify a point as the

center of projection; for parallel projections we needed to spec-

ify a direction of projection.

8

Page 60: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane.

Page 61: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

Page 62: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP,

Page 63: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

Page 64: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

(u ,v )

VRP

VPNn

u

v

VUP

viewplane

min min(u ,v )

max max

Page 65: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

(u ,v )

VRP

VPNn

u

v

VUP

viewplane

min min(u ,v )

max max

The view plane corresponds to the “film” in our virtual camera.

Page 66: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

(u ,v )

VRP

VPNn

u

v

VUP

viewplane

min min(u ,v )

max max

The view plane corresponds to the “film” in our virtual camera.

We also need to describe the orientation of the film or viewport

in the view plane.

Page 67: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

(u ,v )

VRP

VPNn

u

v

VUP

viewplane

min min(u ,v )

max max

The view plane corresponds to the “film” in our virtual camera.

We also need to describe the orientation of the film or viewport

in the view plane. This is done by specifying a vector called

the view up vector (VUP).

Page 68: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

(u ,v )

VRP

VPNn

u

v

VUP

viewplane

min min(u ,v )

max max

The view plane corresponds to the “film” in our virtual camera.

We also need to describe the orientation of the film or viewport

in the view plane. This is done by specifying a vector called

the view up vector (VUP). The projection of the VUP vector

defines the v axis in the plane.

Page 69: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

(u ,v )

VRP

VPNn

u

v

VUP

viewplane

min min(u ,v )

max max

The view plane corresponds to the “film” in our virtual camera.

We also need to describe the orientation of the film or viewport

in the view plane. This is done by specifying a vector called

the view up vector (VUP). The projection of the VUP vector

defines the v axis in the plane. This, in effect, orients the

camera.

Page 70: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

(u ,v )

VRP

VPNn

u

v

VUP

viewplane

min min(u ,v )

max max

The view plane corresponds to the “film” in our virtual camera.

We also need to describe the orientation of the film or viewport

in the view plane. This is done by specifying a vector called

the view up vector (VUP). The projection of the VUP vector

defines the v axis in the plane. This, in effect, orients the

camera. The u axis is perpendicular to v and n ( u = v×n ).

Page 71: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

(u ,v )

VRP

VPNn

u

v

VUP

viewplane

min min(u ,v )

max max

The view plane corresponds to the “film” in our virtual camera.

We also need to describe the orientation of the film or viewport

in the view plane. This is done by specifying a vector called

the view up vector (VUP). The projection of the VUP vector

defines the v axis in the plane. This, in effect, orients the

camera. The u axis is perpendicular to v and n ( u = v×n ).

Defining minimum and maximum values of u and v determines

the viewport.

Page 72: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing surface

The plane onto which the image is projected is usually called

the view plane. It has coordinate axes u, v, and n orthogonal

to each other.

It is defined by the view reference point or VRP, and the view

plane normal or VPN and points along the n axis.

(u ,v )

VRP

VPNn

u

v

VUP

viewplane

min min(u ,v )

max max

The view plane corresponds to the “film” in our virtual camera.

We also need to describe the orientation of the film or viewport

in the view plane. This is done by specifying a vector called

the view up vector (VUP). The projection of the VUP vector

defines the v axis in the plane. This, in effect, orients the

camera. The u axis is perpendicular to v and n ( u = v×n ).

Defining minimum and maximum values of u and v determines

the viewport.

9

Page 73: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

Page 74: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

Page 75: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

Page 76: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

Page 77: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly.

Page 78: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified.

Page 79: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP.

Page 80: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP. In

fact, these are specified in the MODELVIEW transformation.

Page 81: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP. In

fact, these are specified in the MODELVIEW transformation.

The orientation of the camera also needs to be specified (VUP).

Page 82: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP. In

fact, these are specified in the MODELVIEW transformation.

The orientation of the camera also needs to be specified (VUP).

gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy,

upz)

Page 83: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP. In

fact, these are specified in the MODELVIEW transformation.

The orientation of the camera also needs to be specified (VUP).

gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy,

upz)

eyex, eyey, and eyez specify the camera (or eye) position,

Page 84: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP. In

fact, these are specified in the MODELVIEW transformation.

The orientation of the camera also needs to be specified (VUP).

gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy,

upz)

eyex, eyey, and eyez specify the camera (or eye) position,

atx, aty, and atz specify the object center.

Page 85: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP. In

fact, these are specified in the MODELVIEW transformation.

The orientation of the camera also needs to be specified (VUP).

gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy,

upz)

eyex, eyey, and eyez specify the camera (or eye) position,

atx, aty, and atz specify the object center.

upx, upy, and upz specify VUP.

Page 86: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP. In

fact, these are specified in the MODELVIEW transformation.

The orientation of the camera also needs to be specified (VUP).

gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy,

upz)

eyex, eyey, and eyez specify the camera (or eye) position,

atx, aty, and atz specify the object center.

upx, upy, and upz specify VUP.

The glu.. functions are not OpenGL functions, but are part of

a standard library which forms part of most OpenGL systems.

Page 87: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP. In

fact, these are specified in the MODELVIEW transformation.

The orientation of the camera also needs to be specified (VUP).

gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy,

upz)

eyex, eyey, and eyez specify the camera (or eye) position,

atx, aty, and atz specify the object center.

upx, upy, and upz specify VUP.

The glu.. functions are not OpenGL functions, but are part of

a standard library which forms part of most OpenGL systems.

(GLUT is another library which provides user interaction.)

Page 88: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

In many graphics systems, there are functions which set the

viewing parameters explicitly, using functions like:

set_view_reference_point(x, y, z)

set_view_plane_normal(nx, ny, nz)

set_view_up(vx, vy, vz)

In OpenGL, there is a convenient function which is rather more

direct, and uses the virtual camera model explicitly. Basically,

the position of the camera (or eye), and the position of the

object are specified. These specify the VPN and VRP. In

fact, these are specified in the MODELVIEW transformation.

The orientation of the camera also needs to be specified (VUP).

gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy,

upz)

eyex, eyey, and eyez specify the camera (or eye) position,

atx, aty, and atz specify the object center.

upx, upy, and upz specify VUP.

The glu.. functions are not OpenGL functions, but are part of

a standard library which forms part of most OpenGL systems.

(GLUT is another library which provides user interaction.)

The tutorial projection shows the use of the projection func-

tions for orthogonal and perspective transformations.

10

Page 89: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Clipping

Viewing involves both projection and clipping.

Page 90: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Clipping

Viewing involves both projection and clipping. In three di-

mensions, we must clip against a 3-dimensional view volume.

Page 91: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Clipping

Viewing involves both projection and clipping. In three di-

mensions, we must clip against a 3-dimensional view volume.

For the parallel projection case, the additions to the 2-dimensional

clipping we discussed earlier are a front clipping plane and a

back clipping plane, forming a clipping rectangular volume.

Page 92: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Clipping

Viewing involves both projection and clipping. In three di-

mensions, we must clip against a 3-dimensional view volume.

For the parallel projection case, the additions to the 2-dimensional

clipping we discussed earlier are a front clipping plane and a

back clipping plane, forming a clipping rectangular volume.

VPN

Backclipping

planeplaneclipping

Front

planeView

Page 93: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Clipping

Viewing involves both projection and clipping. In three di-

mensions, we must clip against a 3-dimensional view volume.

For the parallel projection case, the additions to the 2-dimensional

clipping we discussed earlier are a front clipping plane and a

back clipping plane, forming a clipping rectangular volume.

VPN

Backclipping

planeplaneclipping

Front

planeView

The perspective projection case is a bit different.

Page 94: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Clipping

Viewing involves both projection and clipping. In three di-

mensions, we must clip against a 3-dimensional view volume.

For the parallel projection case, the additions to the 2-dimensional

clipping we discussed earlier are a front clipping plane and a

back clipping plane, forming a clipping rectangular volume.

VPN

Backclipping

planeplaneclipping

Front

planeView

The perspective projection case is a bit different. Here, the

front and back clipping planes are parallel to the view plane,

but are of different sizes.

Page 95: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Clipping

Viewing involves both projection and clipping. In three di-

mensions, we must clip against a 3-dimensional view volume.

For the parallel projection case, the additions to the 2-dimensional

clipping we discussed earlier are a front clipping plane and a

back clipping plane, forming a clipping rectangular volume.

VPN

Backclipping

planeplaneclipping

Front

planeView

The perspective projection case is a bit different. Here, the

front and back clipping planes are parallel to the view plane,

but are of different sizes. This shape is known as a frustum.

Page 96: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Clipping

Viewing involves both projection and clipping. In three di-

mensions, we must clip against a 3-dimensional view volume.

For the parallel projection case, the additions to the 2-dimensional

clipping we discussed earlier are a front clipping plane and a

back clipping plane, forming a clipping rectangular volume.

VPN

Backclipping

planeplaneclipping

Front

planeView

The perspective projection case is a bit different. Here, the

front and back clipping planes are parallel to the view plane,

but are of different sizes. This shape is known as a frustum.

clippingBack

planeclipping

Front

planeView

VPN

plane

Page 97: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Clipping

Viewing involves both projection and clipping. In three di-

mensions, we must clip against a 3-dimensional view volume.

For the parallel projection case, the additions to the 2-dimensional

clipping we discussed earlier are a front clipping plane and a

back clipping plane, forming a clipping rectangular volume.

VPN

Backclipping

planeplaneclipping

Front

planeView

The perspective projection case is a bit different. Here, the

front and back clipping planes are parallel to the view plane,

but are of different sizes. This shape is known as a frustum.

clippingBack

planeclipping

Front

planeView

VPN

plane

11

Page 98: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

Page 99: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

In OpenGL, there is only one parallel viewing function, the

orthographic viewing function

Page 100: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

In OpenGL, there is only one parallel viewing function, the

orthographic viewing function

glOrtho(left, right, bottom, top, near, far)

Page 101: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

In OpenGL, there is only one parallel viewing function, the

orthographic viewing function

glOrtho(left, right, bottom, top, near, far)

where (left, bottom, -near) are the coordinates of the lower

front corner of the rectangular volume,

Page 102: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

In OpenGL, there is only one parallel viewing function, the

orthographic viewing function

glOrtho(left, right, bottom, top, near, far)

where (left, bottom, -near) are the coordinates of the lower

front corner of the rectangular volume, and (right, top, -

far) are the coordinates of the back top corner.

Page 103: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

In OpenGL, there is only one parallel viewing function, the

orthographic viewing function

glOrtho(left, right, bottom, top, near, far)

where (left, bottom, -near) are the coordinates of the lower

front corner of the rectangular volume, and (right, top, -

far) are the coordinates of the back top corner.

near or far are the distances of the near and far clipping planes

from the eye.

Page 104: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

In OpenGL, there is only one parallel viewing function, the

orthographic viewing function

glOrtho(left, right, bottom, top, near, far)

where (left, bottom, -near) are the coordinates of the lower

front corner of the rectangular volume, and (right, top, -

far) are the coordinates of the back top corner.

near or far are the distances of the near and far clipping planes

from the eye. If either near or far is negative, this means that

the corresponding clipping plane is located behind the eye.

Page 105: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

In OpenGL, there is only one parallel viewing function, the

orthographic viewing function

glOrtho(left, right, bottom, top, near, far)

where (left, bottom, -near) are the coordinates of the lower

front corner of the rectangular volume, and (right, top, -

far) are the coordinates of the back top corner.

near or far are the distances of the near and far clipping planes

from the eye. If either near or far is negative, this means that

the corresponding clipping plane is located behind the eye.

For example, for a view volume consisting of a 2x2x2 cube cen-

tered at the origin, the function calls would be

Page 106: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

In OpenGL, there is only one parallel viewing function, the

orthographic viewing function

glOrtho(left, right, bottom, top, near, far)

where (left, bottom, -near) are the coordinates of the lower

front corner of the rectangular volume, and (right, top, -

far) are the coordinates of the back top corner.

near or far are the distances of the near and far clipping planes

from the eye. If either near or far is negative, this means that

the corresponding clipping plane is located behind the eye.

For example, for a view volume consisting of a 2x2x2 cube cen-

tered at the origin, the function calls would be

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);

Page 107: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Parallel projections in OpenGL

In OpenGL, there is only one parallel viewing function, the

orthographic viewing function

glOrtho(left, right, bottom, top, near, far)

where (left, bottom, -near) are the coordinates of the lower

front corner of the rectangular volume, and (right, top, -

far) are the coordinates of the back top corner.

near or far are the distances of the near and far clipping planes

from the eye. If either near or far is negative, this means that

the corresponding clipping plane is located behind the eye.

For example, for a view volume consisting of a 2x2x2 cube cen-

tered at the origin, the function calls would be

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);

12

Page 108: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

Page 109: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

Page 110: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

defines a frustum similar to the rectangular volume for glOrtho(..).

Page 111: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

defines a frustum similar to the rectangular volume for glOrtho(..).

lefttop

bottom

right

far

near

Page 112: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

defines a frustum similar to the rectangular volume for glOrtho(..).

lefttop

bottom

right

far

near

Note that near and far must be positive for glFrustum.

Page 113: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

defines a frustum similar to the rectangular volume for glOrtho(..).

lefttop

bottom

right

far

near

Note that near and far must be positive for glFrustum.

A typical use would be

Page 114: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

defines a frustum similar to the rectangular volume for glOrtho(..).

lefttop

bottom

right

far

near

Note that near and far must be positive for glFrustum.

A typical use would be

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 10.0);

Page 115: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

defines a frustum similar to the rectangular volume for glOrtho(..).

lefttop

bottom

right

far

near

Note that near and far must be positive for glFrustum.

A typical use would be

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 10.0);

Here the front clipping plane is (-1, -1, -1) to (1, 1, -1).

Page 116: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

defines a frustum similar to the rectangular volume for glOrtho(..).

lefttop

bottom

right

far

near

Note that near and far must be positive for glFrustum.

A typical use would be

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 10.0);

Here the front clipping plane is (-1, -1, -1) to (1, 1, -1). The

rear clipping plane is 9 units beyond the front clipping plane

with corners (-10, -10, -10) to (10, 10, -10).

Page 117: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

defines a frustum similar to the rectangular volume for glOrtho(..).

lefttop

bottom

right

far

near

Note that near and far must be positive for glFrustum.

A typical use would be

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 10.0);

Here the front clipping plane is (-1, -1, -1) to (1, 1, -1). The

rear clipping plane is 9 units beyond the front clipping plane

with corners (-10, -10, -10) to (10, 10, -10).

While conceptually easy, glFrustum() can be difficult to use.

Page 118: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Perspective projections in OpenGL

There are two functions for perspective projections.

glFrustum(left, right, bottom, top, near, far)

defines a frustum similar to the rectangular volume for glOrtho(..).

lefttop

bottom

right

far

near

Note that near and far must be positive for glFrustum.

A typical use would be

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 10.0);

Here the front clipping plane is (-1, -1, -1) to (1, 1, -1). The

rear clipping plane is 9 units beyond the front clipping plane

with corners (-10, -10, -10) to (10, 10, -10).

While conceptually easy, glFrustum() can be difficult to use.

13

Page 119: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

An alternate way to determine the view volume is by specifying

an angular field (in the y direction, in this case),

Page 120: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

An alternate way to determine the view volume is by specifying

an angular field (in the y direction, in this case), an aspect

ratio (width/height)

Page 121: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

An alternate way to determine the view volume is by specifying

an angular field (in the y direction, in this case), an aspect

ratio (width/height) and the distance of the near and far clip-

ping planes.

Page 122: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

An alternate way to determine the view volume is by specifying

an angular field (in the y direction, in this case), an aspect

ratio (width/height) and the distance of the near and far clip-

ping planes.

gluPerspective(fovy, aspect, near, far)

Page 123: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

An alternate way to determine the view volume is by specifying

an angular field (in the y direction, in this case), an aspect

ratio (width/height) and the distance of the near and far clip-

ping planes.

gluPerspective(fovy, aspect, near, far)

wnear

far

fovy h

Page 124: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

An alternate way to determine the view volume is by specifying

an angular field (in the y direction, in this case), an aspect

ratio (width/height) and the distance of the near and far clip-

ping planes.

gluPerspective(fovy, aspect, near, far)

wnear

far

fovy h

With this function, it is necessary to pick appropriate values for

the field of view, or the view looks distorted.

Page 125: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

An alternate way to determine the view volume is by specifying

an angular field (in the y direction, in this case), an aspect

ratio (width/height) and the distance of the near and far clip-

ping planes.

gluPerspective(fovy, aspect, near, far)

wnear

far

fovy h

With this function, it is necessary to pick appropriate values for

the field of view, or the view looks distorted.

With both gluPerspective() and glFrustum() rotations

and translations can be applied to change the default orientation

of the viewing volume.

Page 126: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

An alternate way to determine the view volume is by specifying

an angular field (in the y direction, in this case), an aspect

ratio (width/height) and the distance of the near and far clip-

ping planes.

gluPerspective(fovy, aspect, near, far)

wnear

far

fovy h

With this function, it is necessary to pick appropriate values for

the field of view, or the view looks distorted.

With both gluPerspective() and glFrustum() rotations

and translations can be applied to change the default orientation

of the viewing volume.

Without such transformations, the viewpoint remains at the

origin, with the line of sight along the negative z-axis.

Page 127: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

An alternate way to determine the view volume is by specifying

an angular field (in the y direction, in this case), an aspect

ratio (width/height) and the distance of the near and far clip-

ping planes.

gluPerspective(fovy, aspect, near, far)

wnear

far

fovy h

With this function, it is necessary to pick appropriate values for

the field of view, or the view looks distorted.

With both gluPerspective() and glFrustum() rotations

and translations can be applied to change the default orientation

of the viewing volume.

Without such transformations, the viewpoint remains at the

origin, with the line of sight along the negative z-axis.

The tutorial projection illustrates the use of gluPerspective().

14

Page 128: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple orthogonal projection

Page 129: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple orthogonal projection

Let us consider a projection onto a plane perpendicular to the

z-axis, at z = 0.

Page 130: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple orthogonal projection

Let us consider a projection onto a plane perpendicular to the

z-axis, at z = 0.

in this case, points retain their x and y values, and the equations

of projection are

Page 131: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple orthogonal projection

Let us consider a projection onto a plane perpendicular to the

z-axis, at z = 0.

in this case, points retain their x and y values, and the equations

of projection are

xp = x, yp = y, and zp = 0,

Page 132: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple orthogonal projection

Let us consider a projection onto a plane perpendicular to the

z-axis, at z = 0.

in this case, points retain their x and y values, and the equations

of projection are

xp = x, yp = y, and zp = 0,

In homogeneous coordinates,

Page 133: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple orthogonal projection

Let us consider a projection onto a plane perpendicular to the

z-axis, at z = 0.

in this case, points retain their x and y values, and the equations

of projection are

xp = x, yp = y, and zp = 0,

In homogeneous coordinates,

xp

yp

zp

1

=

1 0 0 0

0 1 0 0

0 0 0 0

0 0 0 1

·

x

y

z

1

Page 134: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple orthogonal projection

Let us consider a projection onto a plane perpendicular to the

z-axis, at z = 0.

in this case, points retain their x and y values, and the equations

of projection are

xp = x, yp = y, and zp = 0,

In homogeneous coordinates,

xp

yp

zp

1

=

1 0 0 0

0 1 0 0

0 0 0 0

0 0 0 1

·

x

y

z

1

We can use the transformation matrices to further modify this

projection matrix.

15

Page 135: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

Page 136: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

We will again consider the case where the projection is on a

plane on the z-axis, at a point (0, 0, zp)

Page 137: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

We will again consider the case where the projection is on a

plane on the z-axis, at a point (0, 0, zp)

(x,y,z)

p

y

z

x

(x,z)

z = −d

(a) (b)

x

z

p p

p(x ,−d)

(x ,y ,z )

Page 138: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

We will again consider the case where the projection is on a

plane on the z-axis, at a point (0, 0, zp)

(x,y,z)

p

y

z

x

(x,z)

z = −d

(a) (b)

x

z

p p

p(x ,−d)

(x ,y ,z )

Here, figure (b) is an orthogonal projection of (a) looking di-

rectly along the y axis.

Page 139: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

We will again consider the case where the projection is on a

plane on the z-axis, at a point (0, 0, zp)

(x,y,z)

p

y

z

x

(x,z)

z = −d

(a) (b)

x

z

p p

p(x ,−d)

(x ,y ,z )

Here, figure (b) is an orthogonal projection of (a) looking di-

rectly along the y axis.

By similar triangles, x/z = xp/d

Page 140: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

We will again consider the case where the projection is on a

plane on the z-axis, at a point (0, 0, zp)

(x,y,z)

p

y

z

x

(x,z)

z = −d

(a) (b)

x

z

p p

p(x ,−d)

(x ,y ,z )

Here, figure (b) is an orthogonal projection of (a) looking di-

rectly along the y axis.

By similar triangles, x/z = xp/d

Similarly, y/z = yp/d

Page 141: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

We will again consider the case where the projection is on a

plane on the z-axis, at a point (0, 0, zp)

(x,y,z)

p

y

z

x

(x,z)

z = −d

(a) (b)

x

z

p p

p(x ,−d)

(x ,y ,z )

Here, figure (b) is an orthogonal projection of (a) looking di-

rectly along the y axis.

By similar triangles, x/z = xp/d

Similarly, y/z = yp/d

So, xp =x

z/dand yp =

y

z/d

Page 142: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

We will again consider the case where the projection is on a

plane on the z-axis, at a point (0, 0, zp)

(x,y,z)

p

y

z

x

(x,z)

z = −d

(a) (b)

x

z

p p

p(x ,−d)

(x ,y ,z )

Here, figure (b) is an orthogonal projection of (a) looking di-

rectly along the y axis.

By similar triangles, x/z = xp/d

Similarly, y/z = yp/d

So, xp =x

z/dand yp =

y

z/d

It is possible to find a matrix which accomplishes the perspective

projection on the z-axis.

Page 143: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

We will again consider the case where the projection is on a

plane on the z-axis, at a point (0, 0, zp)

(x,y,z)

p

y

z

x

(x,z)

z = −d

(a) (b)

x

z

p p

p(x ,−d)

(x ,y ,z )

Here, figure (b) is an orthogonal projection of (a) looking di-

rectly along the y axis.

By similar triangles, x/z = xp/d

Similarly, y/z = yp/d

So, xp =x

z/dand yp =

y

z/d

It is possible to find a matrix which accomplishes the perspective

projection on the z-axis. We must relax the condition that

W = 1 in our homogeneous coordinate system, however.

Page 144: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

Simple perspective projection

We will again consider the case where the projection is on a

plane on the z-axis, at a point (0, 0, zp)

(x,y,z)

p

y

z

x

(x,z)

z = −d

(a) (b)

x

z

p p

p(x ,−d)

(x ,y ,z )

Here, figure (b) is an orthogonal projection of (a) looking di-

rectly along the y axis.

By similar triangles, x/z = xp/d

Similarly, y/z = yp/d

So, xp =x

z/dand yp =

y

z/d

It is possible to find a matrix which accomplishes the perspective

projection on the z-axis. We must relax the condition that

W = 1 in our homogeneous coordinate system, however.

16

Page 145: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

Page 146: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

M =

1 0 0 0

0 1 0 0

0 0 −1 0

0 0 1/d 0

Page 147: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

M =

1 0 0 0

0 1 0 0

0 0 −1 0

0 0 1/d 0

Transforms the point (x, y, z, 1) into (x, y,−z, z/d)

Page 148: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

M =

1 0 0 0

0 1 0 0

0 0 −1 0

0 0 1/d 0

Transforms the point (x, y, z, 1) into (x, y,−z, z/d)

Homogenizing (i.e. dividing by W = z/d), gives

Page 149: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

M =

1 0 0 0

0 1 0 0

0 0 −1 0

0 0 1/d 0

Transforms the point (x, y, z, 1) into (x, y,−z, z/d)

Homogenizing (i.e. dividing by W = z/d), gives

(x

z/d,

y

z/d,−d, 1)

Page 150: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

M =

1 0 0 0

0 1 0 0

0 0 −1 0

0 0 1/d 0

Transforms the point (x, y, z, 1) into (x, y,−z, z/d)

Homogenizing (i.e. dividing by W = z/d), gives

(x

z/d,

y

z/d,−d, 1)

which is the required transformation.

Page 151: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

M =

1 0 0 0

0 1 0 0

0 0 −1 0

0 0 1/d 0

Transforms the point (x, y, z, 1) into (x, y,−z, z/d)

Homogenizing (i.e. dividing by W = z/d), gives

(x

z/d,

y

z/d,−d, 1)

which is the required transformation.

All of our usual transformations (translation, rotation, scaling,

shearing) were affine, meaning that they preserved parallel lines.

Page 152: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

M =

1 0 0 0

0 1 0 0

0 0 −1 0

0 0 1/d 0

Transforms the point (x, y, z, 1) into (x, y,−z, z/d)

Homogenizing (i.e. dividing by W = z/d), gives

(x

z/d,

y

z/d,−d, 1)

which is the required transformation.

All of our usual transformations (translation, rotation, scaling,

shearing) were affine, meaning that they preserved parallel lines.

This transformation is not affine, nor is it invertible — all points

along a projector map into the same point.

Page 153: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

M =

1 0 0 0

0 1 0 0

0 0 −1 0

0 0 1/d 0

Transforms the point (x, y, z, 1) into (x, y,−z, z/d)

Homogenizing (i.e. dividing by W = z/d), gives

(x

z/d,

y

z/d,−d, 1)

which is the required transformation.

All of our usual transformations (translation, rotation, scaling,

shearing) were affine, meaning that they preserved parallel lines.

This transformation is not affine, nor is it invertible — all points

along a projector map into the same point.

Again, it is possible to transform this matrix to project in an

arbitrary direction.

Page 154: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The transformation matrix

M =

1 0 0 0

0 1 0 0

0 0 −1 0

0 0 1/d 0

Transforms the point (x, y, z, 1) into (x, y,−z, z/d)

Homogenizing (i.e. dividing by W = z/d), gives

(x

z/d,

y

z/d,−d, 1)

which is the required transformation.

All of our usual transformations (translation, rotation, scaling,

shearing) were affine, meaning that they preserved parallel lines.

This transformation is not affine, nor is it invertible — all points

along a projector map into the same point.

Again, it is possible to transform this matrix to project in an

arbitrary direction.

17

Page 155: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing pipeline

What happens, in OpenGL, in order to view an image?

Page 156: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing pipeline

What happens, in OpenGL, in order to view an image?

Perspective

eye

Normalizeddevice

coordinates

coordinates

coordinatesclip

object

coordinates

coordinates

Window ViewportTransformation

ModelView

Matrix

ProjectionMatrix

Division

Page 157: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing pipeline

What happens, in OpenGL, in order to view an image?

Perspective

eye

Normalizeddevice

coordinates

coordinates

coordinatesclip

object

coordinates

coordinates

Window ViewportTransformation

ModelView

Matrix

ProjectionMatrix

Division

The objects themselves are described in their own coordinate

spaces, and placed in the global model world by the appropri-

ate MODELVIEW transformation.

Page 158: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing pipeline

What happens, in OpenGL, in order to view an image?

Perspective

eye

Normalizeddevice

coordinates

coordinates

coordinatesclip

object

coordinates

coordinates

Window ViewportTransformation

ModelView

Matrix

ProjectionMatrix

Division

The objects themselves are described in their own coordinate

spaces, and placed in the global model world by the appropri-

ate MODELVIEW transformation. After transformation all

vertices are expressed in eye coordinates.

Page 159: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing pipeline

What happens, in OpenGL, in order to view an image?

Perspective

eye

Normalizeddevice

coordinates

coordinates

coordinatesclip

object

coordinates

coordinates

Window ViewportTransformation

ModelView

Matrix

ProjectionMatrix

Division

The objects themselves are described in their own coordinate

spaces, and placed in the global model world by the appropri-

ate MODELVIEW transformation. After transformation all

vertices are expressed in eye coordinates.

The PROJECTION matrix applies the requested projection.

Page 160: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing pipeline

What happens, in OpenGL, in order to view an image?

Perspective

eye

Normalizeddevice

coordinates

coordinates

coordinatesclip

object

coordinates

coordinates

Window ViewportTransformation

ModelView

Matrix

ProjectionMatrix

Division

The objects themselves are described in their own coordinate

spaces, and placed in the global model world by the appropri-

ate MODELVIEW transformation. After transformation all

vertices are expressed in eye coordinates.

The PROJECTION matrix applies the requested projection.

However, under the hood, OpenGL also applies projection normalization

which maps the model world into a canonical clipping volume

(more on this below).

Page 161: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing pipeline

What happens, in OpenGL, in order to view an image?

Perspective

eye

Normalizeddevice

coordinates

coordinates

coordinatesclip

object

coordinates

coordinates

Window ViewportTransformation

ModelView

Matrix

ProjectionMatrix

Division

The objects themselves are described in their own coordinate

spaces, and placed in the global model world by the appropri-

ate MODELVIEW transformation. After transformation all

vertices are expressed in eye coordinates.

The PROJECTION matrix applies the requested projection.

However, under the hood, OpenGL also applies projection normalization

which maps the model world into a canonical clipping volume

(more on this below). After projection, vertices are expressed

in clip coordinates.

Page 162: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The viewing pipeline

What happens, in OpenGL, in order to view an image?

Perspective

eye

Normalizeddevice

coordinates

coordinates

coordinatesclip

object

coordinates

coordinates

Window ViewportTransformation

ModelView

Matrix

ProjectionMatrix

Division

The objects themselves are described in their own coordinate

spaces, and placed in the global model world by the appropri-

ate MODELVIEW transformation. After transformation all

vertices are expressed in eye coordinates.

The PROJECTION matrix applies the requested projection.

However, under the hood, OpenGL also applies projection normalization

which maps the model world into a canonical clipping volume

(more on this below). After projection, vertices are expressed

in clip coordinates.

We saw above in “Simple perspective projection” that projec-

18

Page 163: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization).

Page 164: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline.

Page 165: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline. After this stage

we have vertices in normalized device coordinates.

Page 166: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline. After this stage

we have vertices in normalized device coordinates.

Finally, the viewport transformation maps the projected ver-

tices onto window coordinates.

Page 167: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline. After this stage

we have vertices in normalized device coordinates.

Finally, the viewport transformation maps the projected ver-

tices onto window coordinates. Window coordinates are mea-

sured in units of pixels on the display, with the origin in the

lower-left corner.

Page 168: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline. After this stage

we have vertices in normalized device coordinates.

Finally, the viewport transformation maps the projected ver-

tices onto window coordinates. Window coordinates are mea-

sured in units of pixels on the display, with the origin in the

lower-left corner. In fact, window coordinates maintain depth

information which is necessary for hidden surface removal.

Page 169: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline. After this stage

we have vertices in normalized device coordinates.

Finally, the viewport transformation maps the projected ver-

tices onto window coordinates. Window coordinates are mea-

sured in units of pixels on the display, with the origin in the

lower-left corner. In fact, window coordinates maintain depth

information which is necessary for hidden surface removal.

Projection normalization?

Page 170: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline. After this stage

we have vertices in normalized device coordinates.

Finally, the viewport transformation maps the projected ver-

tices onto window coordinates. Window coordinates are mea-

sured in units of pixels on the display, with the origin in the

lower-left corner. In fact, window coordinates maintain depth

information which is necessary for hidden surface removal.

Projection normalization?

Whatever view volume is specified by calls to glOrtho or glFrustum

(or gluPerspective), OpenGL transforms that volume into

the canonical view volume.

Page 171: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline. After this stage

we have vertices in normalized device coordinates.

Finally, the viewport transformation maps the projected ver-

tices onto window coordinates. Window coordinates are mea-

sured in units of pixels on the display, with the origin in the

lower-left corner. In fact, window coordinates maintain depth

information which is necessary for hidden surface removal.

Projection normalization?

Whatever view volume is specified by calls to glOrtho or glFrustum

(or gluPerspective), OpenGL transforms that volume into

the canonical view volume. This volume is defined by planes

at x ± 1, y ± 1, and z ± 1.

Page 172: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline. After this stage

we have vertices in normalized device coordinates.

Finally, the viewport transformation maps the projected ver-

tices onto window coordinates. Window coordinates are mea-

sured in units of pixels on the display, with the origin in the

lower-left corner. In fact, window coordinates maintain depth

information which is necessary for hidden surface removal.

Projection normalization?

Whatever view volume is specified by calls to glOrtho or glFrustum

(or gluPerspective), OpenGL transforms that volume into

the canonical view volume. This volume is defined by planes

at x ± 1, y ± 1, and z ± 1. The canonical view volume may

be generated directly as follows:

Page 173: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

tion requires both multiplication by a transformation matrix

and a division step (a.k.a renormalization). Thus, perspective

division forms the third stage of the pipeline. After this stage

we have vertices in normalized device coordinates.

Finally, the viewport transformation maps the projected ver-

tices onto window coordinates. Window coordinates are mea-

sured in units of pixels on the display, with the origin in the

lower-left corner. In fact, window coordinates maintain depth

information which is necessary for hidden surface removal.

Projection normalization?

Whatever view volume is specified by calls to glOrtho or glFrustum

(or gluPerspective), OpenGL transforms that volume into

the canonical view volume. This volume is defined by planes

at x ± 1, y ± 1, and z ± 1. The canonical view volume may

be generated directly as follows:

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);

19

Page 174: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

For a general orthographic projection, the projection normal-

ization does the following:

Page 175: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

For a general orthographic projection, the projection normal-

ization does the following:

Page 176: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

For a general orthographic projection, the projection normal-

ization does the following:

Perspective projections will also be converted to the same canon-

ical view volume.

Page 177: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

For a general orthographic projection, the projection normal-

ization does the following:

Perspective projections will also be converted to the same canon-

ical view volume.

Page 178: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

For a general orthographic projection, the projection normal-

ization does the following:

Perspective projections will also be converted to the same canon-

ical view volume.

where COP means centre of projection.

Page 179: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

For a general orthographic projection, the projection normal-

ization does the following:

Perspective projections will also be converted to the same canon-

ical view volume.

where COP means centre of projection. On the left is a top-

down view of a cube within a frustum-shaped view volume.

Page 180: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

For a general orthographic projection, the projection normal-

ization does the following:

Perspective projections will also be converted to the same canon-

ical view volume.

where COP means centre of projection. On the left is a top-

down view of a cube within a frustum-shaped view volume.

After projection normalization, the view volume has been made

canonical, and the cube has been appropriately distorted.

Page 181: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

For a general orthographic projection, the projection normal-

ization does the following:

Perspective projections will also be converted to the same canon-

ical view volume.

where COP means centre of projection. On the left is a top-

down view of a cube within a frustum-shaped view volume.

After projection normalization, the view volume has been made

canonical, and the cube has been appropriately distorted.

20

Page 182: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The purpose of projection normalization is to simplify clipping.

Page 183: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The purpose of projection normalization is to simplify clipping.

It is easier to transform primitives to the canonical viewing vol-

ume and then clip, than to clip them beforehand to an arbitrary

view volume.

Page 184: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The purpose of projection normalization is to simplify clipping.

It is easier to transform primitives to the canonical viewing vol-

ume and then clip, than to clip them beforehand to an arbitrary

view volume.

21

Page 185: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The planet.c example revisited...

Look at the display call below.

Page 186: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The planet.c example revisited...

Look at the display call below. What is the plane of the

planet’s travel about the sun?

Page 187: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The planet.c example revisited...

Look at the display call below. What is the plane of the

planet’s travel about the sun?

void display(void)

{

glClear (GL_COLOR_BUFFER_BIT);

glColor3f (1.0, 1.0, 1.0);

glPushMatrix();

glutWireSphere(1.0, 20, 16); /* draw sun */

glRotatef ((GLfloat) year, 0.0, 1.0, 0.0);

glTranslatef (2.0, 0.0, 0.0);

glRotatef ((GLfloat) day, 0.0, 1.0, 0.0);

glutWireSphere(0.2, 10, 8); /* draw smaller planet */

glPopMatrix();

glutSwapBuffers();

}

Page 188: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The planet.c example revisited...

Look at the display call below. What is the plane of the

planet’s travel about the sun?

void display(void)

{

glClear (GL_COLOR_BUFFER_BIT);

glColor3f (1.0, 1.0, 1.0);

glPushMatrix();

glutWireSphere(1.0, 20, 16); /* draw sun */

glRotatef ((GLfloat) year, 0.0, 1.0, 0.0);

glTranslatef (2.0, 0.0, 0.0);

glRotatef ((GLfloat) day, 0.0, 1.0, 0.0);

glutWireSphere(0.2, 10, 8); /* draw smaller planet */

glPopMatrix();

glutSwapBuffers();

}

22

Page 189: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The reshape function below positions the eye within the xz

plane

Page 190: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The reshape function below positions the eye within the xz

plane

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Page 191: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The reshape function below positions the eye within the xz

plane

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Lets say that that we want to zoom in a little, so that when

year is either 0 or 180, the outside of the planet just touches

the window’s edge.

Page 192: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The reshape function below positions the eye within the xz

plane

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Lets say that that we want to zoom in a little, so that when

year is either 0 or 180, the outside of the planet just touches

the window’s edge.

By examining the code in display we can see that, in eye

coordinates, the planetary system has a radius of 2.2 (extending

out to the planet’s outer edge).

Page 193: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The reshape function below positions the eye within the xz

plane

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Lets say that that we want to zoom in a little, so that when

year is either 0 or 180, the outside of the planet just touches

the window’s edge.

By examining the code in display we can see that, in eye

coordinates, the planetary system has a radius of 2.2 (extending

out to the planet’s outer edge). Examing the arguments to

gluLookAt we can see that the system is 5 units away from the

eye.

Page 194: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The reshape function below positions the eye within the xz

plane

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Lets say that that we want to zoom in a little, so that when

year is either 0 or 180, the outside of the planet just touches

the window’s edge.

By examining the code in display we can see that, in eye

coordinates, the planetary system has a radius of 2.2 (extending

out to the planet’s outer edge). Examing the arguments to

gluLookAt we can see that the system is 5 units away from the

eye. Simple trigonometry tells us that the horizontal field of

view, fovx, is

Page 195: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The reshape function below positions the eye within the xz

plane

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Lets say that that we want to zoom in a little, so that when

year is either 0 or 180, the outside of the planet just touches

the window’s edge.

By examining the code in display we can see that, in eye

coordinates, the planetary system has a radius of 2.2 (extending

out to the planet’s outer edge). Examing the arguments to

gluLookAt we can see that the system is 5 units away from the

eye. Simple trigonometry tells us that the horizontal field of

view, fovx, is

23

Page 196: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

fovx = 2 tan−1(2.2/5)

Page 197: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

fovx = 2 tan−1(2.2/5)

We define a variable aspect as follows

Page 198: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

fovx = 2 tan−1(2.2/5)

We define a variable aspect as follows

aspect =width

height

Page 199: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

fovx = 2 tan−1(2.2/5)

We define a variable aspect as follows

aspect =width

height

aspect =angular width

angular height

Page 200: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

fovx = 2 tan−1(2.2/5)

We define a variable aspect as follows

aspect =width

height

aspect =angular width

angular height

aspect =fovx

fovy

Page 201: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

fovx = 2 tan−1(2.2/5)

We define a variable aspect as follows

aspect =width

height

aspect =angular width

angular height

aspect =fovx

fovy

Therefore, we can find the required value of fovy as follows

Page 202: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

fovx = 2 tan−1(2.2/5)

We define a variable aspect as follows

aspect =width

height

aspect =angular width

angular height

aspect =fovx

fovy

Therefore, we can find the required value of fovy as follows

fovy =fovx

aspect

Page 203: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

fovx = 2 tan−1(2.2/5)

We define a variable aspect as follows

aspect =width

height

aspect =angular width

angular height

aspect =fovx

fovy

Therefore, we can find the required value of fovy as follows

fovy =fovx

aspect

24

Page 204: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The following code for reshape implements this zoomed-in

view.

Page 205: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The following code for reshape implements this zoomed-in

view.

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

double aspect = w / (GLfloat) h;

double fovx = 47.5; /* 2*arctan(2.2/5.0)=47.5 */

double fovy = fovx / aspect;

gluPerspective(fovy, aspect, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Page 206: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The following code for reshape implements this zoomed-in

view.

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

double aspect = w / (GLfloat) h;

double fovx = 47.5; /* 2*arctan(2.2/5.0)=47.5 */

double fovy = fovx / aspect;

gluPerspective(fovy, aspect, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Note that when executing the example code (in planet2.c)

the planet is clipped out when close to the viewer.

Page 207: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The following code for reshape implements this zoomed-in

view.

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

double aspect = w / (GLfloat) h;

double fovx = 47.5; /* 2*arctan(2.2/5.0)=47.5 */

double fovy = fovx / aspect;

gluPerspective(fovy, aspect, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Note that when executing the example code (in planet2.c)

the planet is clipped out when close to the viewer. Why is

this?

Page 208: Projections and their transformations - Computer … and their transformations Wehavelookedatmodeling3-dimensionalfiguresina3-dimensional world. The final image, however, will be

The following code for reshape implements this zoomed-in

view.

void reshape (int w, int h)

{

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

glMatrixMode (GL_PROJECTION);

glLoadIdentity ();

double aspect = w / (GLfloat) h;

double fovx = 47.5; /* 2*arctan(2.2/5.0)=47.5 */

double fovy = fovx / aspect;

gluPerspective(fovy, aspect, 1.0, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

Note that when executing the example code (in planet2.c)

the planet is clipped out when close to the viewer. Why is

this?

25