0% found this document useful (0 votes)
99 views6 pages

Graphics Slides 02

This document discusses 3D computer graphics and techniques for representing and projecting 3D objects onto 2D planes for display. It introduces planar polygons, wire frame models, and different projection types including orthographic and perspective projections. It also discusses the need for transformations to manipulate 3D objects and viewpoints, and how matrix transformations are used to achieve rotations, scaling, and other effects.

Uploaded by

api-3738981
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views6 pages

Graphics Slides 02

This document discusses 3D computer graphics and techniques for representing and projecting 3D objects onto 2D planes for display. It introduces planar polygons, wire frame models, and different projection types including orthographic and perspective projections. It also discusses the need for transformations to manipulate 3D objects and viewpoints, and how matrix transformations are used to achieve rotations, scaling, and other effects.

Uploaded by

api-3738981
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Interactive Computer Graphics Planar Polyhedra

These are three dimensional objects whose faces are


Lecture 2: all planar polygons often called facets.

Three Dimensional objects, Projection and


Transformations

Graphics Lecture 2: Slide 1 Graphics Lecture 2: Slide 2

Representing Planar Polygons Projections of Wire Frame Models

In order to represent planar polygons in the computer Wire frame models simply include points and lines.
we will require a mixture of numerical and
topological data. In order to draw a 3D wire frame model we must first
convert the points to a 2D representation. Then we
Numerical Data can use simple drawing primitives to draw them.
Actual 3D coordinates of vertices, etc.
The conversion from 3D into 2D is a form of
Topological Data projection.
Details of what is connected to what

Graphics Lecture 2: Slide 3 Graphics Lecture 2: Slide 4

Planar Projection Non Linear Projections

3D Object In general it is possible to project onto any surface:


Plane of Projection
Sphere
Cone
Vi
etc
or to use curved projectors, for example to produce
Viewpoint lens effects.

Projection of Vi However we will only consider planar linear


Projector projections.

Graphics Lecture 2: Slide 5 Graphics Lecture 2: Slide 6

1
Normal Orthographic Projection Orthographic Projection onto z=0

This is the simplest form of projection, and effective y


in many cases.
V
z
The viewpoint is at z = -∞
The plane of projection is z=0

Projector
so
V+µd
x
(d=[0,0,-1)
All projectors have direction d = [0,0,-1]

Graphics Lecture 2: Slide 7 Graphics Lecture 2: Slide 8

Calculating an Orthographic Projection Orthographic Projection of a Cube

Projector Equation:
P=V+µd
Substitute d = [0,0,-1] Looking at a Face General View
Yields cartesian form
Px = Vx + 0 Py = Vy + 0 Pz = Vz - µ
The projection plane is z=0 so the projected
coordinate is Looking at a vertex
[Vx,Vy,0]
ie we simply take the 3D x and y components of the
vertex
Graphics Lecture 2: Slide 9 Graphics Lecture 2: Slide 10

Perspective Projection Canonical Form for Perspective Projection

Orthographic projection is fine in cases where we are Projected point


Y
Scene
not worried about depth (ie most objects are at the
same distance from the viewer).
Projector Z

However for close work (particularly computer Plane of Projection


games) it will not do. (z=f)

Instead we use perspective projection f

X
Viewpoint
Graphics Lecture 2: Slide 11 Graphics Lecture 2: Slide 12

2
Calculating Perspective Projection Perspective Projection of a Cube

Projector Equation:
7
P = µ V (all projectors go through the origin)
At the projected point Pz=f Looking at a Face General View

µp = Pz/Vz = f/Vz
Px = µp Vx and Py = µp Vy
Thus
Looking at a vertex
Px = f Vx/Vz and Py = f Vy/Vz
The constant µp is sometimes called the fore-
shortenting factor

Graphics Lecture 2: Slide 13 Graphics Lecture 2: Slide 14

Problem Break The Need for Transformations

Given that the viewpoint is at the origin, and the Graphics scenes are defined in one co-ordinate system
viewing plane is at z=5: What point on the viewplane
corresponds to the 3D vertex {10,10,10} in We want to be able to draw a graphics scene from any
a. Perspective projection angle
b. Orthographic projection

To draw a graphics scene we need the viewpoint to be


Perspective x'= f x/z = 5 and y' = f y/z = 5 the origin and the z axis to be the direction of view.

Orthographic x' = 10 and y' =10


Hence we need to be able to transform the coordinates
of a graphics scene.
Graphics Lecture 2: Slide 15 Graphics Lecture 2: Slide 16

Transformation of viewpoint Matrix transformations of points

To transform points we use matrix multiplications.


Y
Viewpoint X

Y
For example to make an object at the origin twice as
Z
big we could use:
Z
[x',y',z'] = 2 0 0 x
0 2 0 y
X
0 0 2 z
Coordinate System for definition Coordinate System for viewing

yields

x' = 2x y' = 2y z' = 2z


Graphics Lecture 2: Slide 17 Graphics Lecture 2: Slide 18

3
Translation by Matrix multiplication Honogenous Coordinates

Many of our transformations will require translation The answer is to use homogenous coordinates
of the points.
For example if we want to move all the points two
units along the x axis we would require: [x', y', z', 1] = [ x, y, z, 1] 1 0 0 0
0 1 0 0
0 0 1 0
x’ = x + 2 2 0 0 1
y’ = y
z’ = z

But how can we do this with a matrix?


Graphics Lecture 2: Slide 19 Graphics Lecture 2: Slide 20

General Homogenous Coordinates Affine Transformations

In most cases the last ordinate will be 1, but in general Affine transformations are those that preserve parallel
we can consider it a scale factor. lines.

Thus: Most transformations we require are affine, the most


important being:
[x, y, z, s] is equivalent to [x/s, y/s, z/s] Scaling
Translating
Homogenous Cartesian
Rotating
Other more complex transforms will be built from
these three.
Graphics Lecture 2: Slide 21 Graphics Lecture 2: Slide 22

Translation Inverting a translation

Since we know what transformation matrices do, we


can write down their inversions directly

[ x, y, z, 1] 1 0 0 0 = [x+tx, y+ty, z+tz, 1 ]


0 1 0 0 For example:
0 0 1 0
tx ty tz 1
1 0 0 0 has inversion 1 0 0 0
0 1 0 0 0 1 0 0
0 0 1 0 0 0 1 0
tx ty tz 1 -tx -ty -tz 1

Graphics Lecture 2: Slide 23 Graphics Lecture 2: Slide 24

4
Scaling Inverting scaling

[x, y, z, 1] sx 0 0 0 = [sx*x, sy*y, sz*z, 1] sx 0 0 0 has inversion 1/sx 0 0 0


0 sy 0 0 0 sy 0 0 0 1/sy 0 0
0 0 sz 0 0 0 sz 0 0 0 1/sz 0
0 0 0 1 0 0 0 1 0 0 0 1

Graphics Lecture 2: Slide 25 Graphics Lecture 2: Slide 26

Combining transformations Combined transformations

Suppose we want to make an object at the origin We multiply out the transformation matrices first,
twice as big and then move it to a point [5, 5, 20]. then transform the points

The transformation is a scaling followed by a


translation: [x',y',z',1] = [x, y, z, 1] 2 0 0 0
0 2 0 0
0 0 2 0
[x',y',z',1] = [x, y, z, 1] 2 0 0 0 1 0 0 0 5 5 20 1
0 2 0 0 0 1 0 0
0 0 2 0 0 0 1 0
0 0 0 1 5 5 20 1

Graphics Lecture 2: Slide 27 Graphics Lecture 2: Slide 28

Transformations are not commutative The order of transformations is significant

The order in which transformations are applied Graphics Scene Y Y


Translate
matters: (Square at origin)
x:=x+1
Y
X X
Scale
In general x:=x*2
X

Y Y
T * S is not the same as S * T Translate Scale
x:=x+1 x:=x*2
X X

Graphics Lecture 2: Slide 29 Graphics Lecture 2: Slide 30

5
Rotation Rotation Matrices

To define a rotation we need an axis.

Rx = 1 0 0 0 Ry = Cos(θ) 0 -Sin(θ) 0
The simplest rotations are about the Cartesian axes 0 Cos(θ) Sin(θ) 0 0 1 0 0
0 -Sin(θ) Cos(θ) 0 Sin(θ) 0 Cos(θ) 0
0 0 0 1 0 0 0 1
eg Rz = Cos(θ) Sin(θ) 0 0
-Sin(θ) Cos(θ) 0 0
0 0 1 0
Rx - Rotate about the X axis 0 0 0 1

Ry - Rotate about the Y axis


Rz - Rotate about the Z axis
Graphics Lecture 2: Slide 31 Graphics Lecture 2: Slide 32

Deriving Rz Y Signs of Rotations


[X', Y']

Rotate by θ
Rotations have a direction.
r

r [X,Y] The following rule applies to the matrix formulations


θ given in the notes:
φ
X
Rotation is clockwise when viewed from the positive
[X,Y] = [r Cosφ, r Sinφ]
[X',Y'] = [ r Cos(θ+φ) , r Sin(θ+φ) ]
side of the axis
= [ r Cosφ Cosθ - rSinφ Sinθ, rSinφCosθ + rCosφSinθ ]
= [ X Cosθ -Y Sinθ, YCosθ + XSinθ]
=[X Y] Cosθ Sinθ
-Sinθ Cosθ
Graphics Lecture 2: Slide 33 Graphics Lecture 2: Slide 34

Inverting Rotation Inverting Rz

Inverting a rotation by an angle θ is equivalent to


rotating through an angle of -θ, now

Cos(θ) Sin(θ) 0 0 has inversion Cos(θ) -Sin(θ) 0 0


Cos(-θ) = Cos(θ) -Sin(θ) Cos(θ) 0 0 Sin(θ) Cos(θ) 0 0
0 0 1 0 0 0 1 0
0 0 0 1 0 0 0 1
and

Sin(-θ) = -Sin(θ)

Graphics Lecture 2: Slide 35 Graphics Lecture 2: Slide 36

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy