You are on page 1of 76

Part - #2

COMPUTER GRAPHICS &


GEOMETRIC
TRANSFORMATION (2D & 3D)

28 Sept. 2022
Cad System Architecture

Hardwar
e

Software Data
Basic Structure of a CAD system
I/O devises of CAD system
Display Technologies
 Various display technologies are now available to the user to choose from. They are all
based on the concept of converting the computer’s electrical signals, controlled by the
corresponding digital information, into visible images at high speeds.
 Among the available technologies, the most common graphics output devices are:
1. Standard Cathode Ray Tube (CRT):: is a technologies based on the concept of energizing
an electron beam that strikes the phosphor coating at very high speed. The energy transfer
from the electron to the phosphor due to the impact causes it to illuminate and glow. The
electrons are generated via the electron gun that contains the cathode and are focused into
a beam via the focusing unit. Figure 2.1 shows a schematic diagram & the display
processor in relation to the components of the workstation of a typical CRT. Other
technology utilize laser beam, instead of an electron beam, is used to trace an image in a
film.
2. Flat Panel Displays: in which, a liquid crystal display (LCD) and Light-Emitting Diodes
(LEDs) are used to gene rate images.
a. Light-emitting Diode (LED)- in LED, a matrix of diodes is arranged -form the pixel
positions
b. Liquid-crystal Displays (LCDs)- produce picture -passing polarized light e through a
liquid
3. Plasma Panel Displays: the plasma display uses small neon bulbs arranged in a panel
which provides a medium resolution display.
 Thus far, none of these display technologies has been able to displace the CRT as the
Graphics Display: CRT

Figure 2.1
Graphics Display: CRT
 By controlling the beam direction and intensity in a way related to
the graphics information generated in the computer, meaningful and
desired graphics can be displayed on the screen.
 The deflection system of the CRT controls the x and y, or the
horizontal and vertical, positions of the beam which in turn are
related to the graphics information through the display controller,
which typically sits between the computer and the CRT. The
controller receives the information from the computer and converts it
into signals acceptable to the CRT.
 Other names for the display controller are the display processor, the
display logical processor, or the display processing unit.
 The major tasks that the display processor performs are the voltage-
level convergence between the computer and the CRT, the
compensation for the difference in speed between the computer and
the CRT (by acting as a buffer) and the generation of graphics and
texts.
Graphics Display: CRT
 More often, display processors are furnished with additional hardware to
implement standard graphics software functions into hardware to improve the
speed of response. Such functions include transformations (scaling, rotation and
translation) and shading.
 The graphics display can be divided into two types based on the scan technology
used to control the electron beam when generating graphics on the screen. These
are random and raster scan.
1. Random Scan: The word “random” indicates that the screen is not scanned in a
particular order. In random scan, graphics can be generated by drawing vectors or
line segments on the screen in a random order which is controlled by the user
input and the software.
2. Raster Scan: in the raster scan system, the screen is scanned from left to right,
top to bottom, all the time to generate graphics. This is similar to the home
television scan system, thus suggesting the name “digital scan.”
 The three existing CRT displays that are based on these techniques are the refresh
display, direct view storage tube and the raster display. The first two are vector
displays based on the random scan technique and the last is based on the raster
scan technique. The details of each display are discussed below.
Graphics Display: CRT

Fig. 2.2 CRT Screen Scan Techniques


Refresh Display
The deflection system of the
CRT is controlled and driven
by the vector and character
generators and digital-to-
analog converters. The
refresh buffer stores the
display file or program,
which contains points, lines,
characters and other
attributes of the picture to be
drawn.
Figure 2.3 shows the main components of a typical refresh display
• These commands are interpreted and processed by the display
processor. The electron beam accordingly excites the phosphor, which
glows for a short period. To maintain a steady flicker-free image, the
screen must be refreshed or redrawn at least 30 to 60 times per
Direct View Storage Tube (DVST)

Refresh displays were very expensive, due to the required refresh


buffer memory and fast display processor could only display a few
hundred vectors on the screen without flicker. The DVST eliminates
the refresh processors completely and, consequently, the refresh buffer
used with the refresh display, as shown in Fig. 2.4.
Raster Display A typical resolution of a raster display is
1280 × 1204 with a possibility to reach
4096 × 4096 as the DVST. Raster displays
are very popular and nearly all recent
display research and development focus on
them. In raster displays, the display screen
area is divided horizontally and vertically
into a matrix of small elements called
picture elements or pixels. A pixel is the
smallest addressable area on a screen. An N
× Μ resolution defines a screen with N
rows and Μ columns. Each row defines a
scan line. A rasterization process is needed
in order to display either a shaded area or
graphics entities. In this process, the area or
entities are converted into their
corresponding pixels whose intensity and
color are controlled by the image display
system

The inability of the DVST to meet the increasing demands by various CAD/CAM
applications for colors, shaded images and animation motivated hardware designers to
continue searching for a solution. raster displays based on the standard television technology
began to emerge as a viable alternative. The drop in memory price due to advances in solid
states made large enough refresh buffers available to support high-resolution displays.
Intro & General Information

Construction Viewing Animation


(translate, rotate, scale, mirror) (projections, zooming) (processes, vibration)

Geometric Transformations

10/10/2022 13
Coordinate Systems
 In order to specify the geometry of a given solid, it is necessary to
use a variety of coordinate systems. Its Major classifications are:
 World Coordinate System: Also known as the "universe" or
sometimes "model" coordinate system. This is the base reference
system for the overall model, ( generally in 3D ), to which all other
model coordinates relate
 User Coordinate System: Also known as “working” coordinate
system. When it is difficult to define certain geometries using
WCS, In such cases user coordinate system can be defined relative
to the WCS.
 Display Coordinates: This refers to the actual coordinates to be
used for displaying the image on the screen.
Geometric Transformations
 Sometimes also called modeling transformations
 Geometric transformations: Changing an object’s
position (translation), orientation (rotation) or size
(scaling)
 Modeling transformations: Constructing a scene or
hierarchical description of a complex object
 Others transformations: reflection and shearing
operations

15
1. Geometric Transformations

 What is transformation?
> It is the backbone of computer graphics, enabling us to
manipulate the shape, size, and location of the object.
> Changing something to something else via rules.

 Why are they important to graphics?


> It can be used to effect the following changes in a geometric
object:
1. Change the location

2. Change the shape

3. Change the size


4. Rotate
2. Types of Transformations
i. Geometric/Object Transformation

> This transformation alters the coordinate values of the object. Basic

operations are scaling, translation, rotation and combination of one or

more of these basic transformations.


> Object transformation = Move (transform) an object in the 2D/3D space.

ii. Visual/ Coordinate System Transformation


> In this transformation there is no change in either the geometry or the coordinates of

the object. A copy of the object is placed at the desired sight, without changing the

coordinate values of the object.

> Coordinate system transformation = Move (transform) the coordinate system.

View the objects from the new coordinate system.


3. Types of Geometric Transformations

 Translation
 Rotation
 Scaling
 Reflection/Mirroring.

19
Translation
Translation is a rigid-body transformation (Euclidean) when
each entity of the model remains parallel, or each point
moves an equal distance in a given direction:
P* = P + d (for both 2D and 3D). In a scalar form (for 3D):
x * = x + xd
y y * = y + yd
B (10,8)
z = z + zd
*
C (11,7)
B* A (8,5)
C*
A*
O x
Question: Find the coordinates of vertices A*, B*,
and C* of the translated triangle.
The distance vector of translation: D = [-7 -4]T.
Verify that the lengths of the edges are unchanged.

10/10/2022 20
i. Translation - 2D

Moving an object is called a translation.

We translate a point by adding to the x and y coordinates,


respectively, the amount the point should be shifted in the x and y
directions.
We translate an object by translating each vertex in the object.
Basic 2D Geometric
Transformations
 2D Translation
P’
T

 x’ = x + tx , y’ = y + ty

 P’=P+T 22
Basic 2D Geometric
Transformations (cont.)
 2D Translation
 To move a line segment, apply the transformation
equation to each of the two line endpoints and
redraw the line between new endpoints
 To move a polygon, apply the transformation
equation to coordinates of each vertex and
regenerate the polygon using the new set of vertex
coordinates

23
Scaling
Scaling is used to change the size of an entity or a model.
P* = [S]P
sx 0 0
where sx, sy, and sz are the scaling
For general case [S] = 0 sy 0 ,factors in the X, Y, and Z directions
0 0 sz respectively.
If 0 < s < 1 - compression
If s > 1 - stretching
sx = sy = sz - uniform scaling, otherwise - non-uniform

y
Question: The larger circle is the scaled copy
O*(10,y*) of the smaller one. Can you say that we have a
R1 O(4,2) uniform scaling? Why? Define y* and R*.
R*

O
x
10/10/2022 24
ii. Scaling
> Changing the size of an object is called a scale. We scale an
object by scaling the x and y coordinates of each vertex in the
object.
Basic 2D Geometric
Transformations (cont.)
 2D Rotation
 Rotation axis
 Rotation angle
 rotation point or pivot point (xr,yr)

yr θ

xr

2D Geometric Transformations 26
Basic 2D Geometric
Transformations (cont.)
 2D Rotation
 If θ is positive  counterclockwise rotation
 If θ is negative  clockwise rotation
 Remember:
 cos(a + b) = cos a cos b - sin a sin b
 cos(a - b) = cos a sin b + sin a cos b

2D Geometric Transformations 27
Rotation
Rotation is a non-commutative transformation (depends on sequence).
Y

P*

P
𝜃 y*

𝛼 y

X
x*
Z
x

Question: Let the length of a major and minor


axes of an ellipse with the center on the origin
of the CS be 2a and 2b respectively, and - the
angle between the major axis and the x-axis.
Then, derive the expression of an ellipse in the
(O,x,y) system.

10/10/2022 28
iii. Rotation about the origin

ø Consider rotation about the origin by Θ degrees


ø Radius stays the same, angle increases by Θ.
Basic 2D Geometric
Transformations (cont.)
 2D Rotation
 At first, suppose the pivot point is at the origin
 x’=r cos(θ+Φ) = r cos θ cos Φ - r sin θ sin Φ
y’=r sin(θ+Φ) = r cos θ sin Φ + r sin θ cos Φ
 x = r cos Φ, y = r sin Φ
 x’=x cos θ - y sin θ
y’=x sin θ + y cos θ
(x’,y’)

r θ
r (x,y)
Φ
30
Basic 2D Geometric
Transformations
 2D Rotation
 P’=R·P

(x’,y’)

r θ
r (x,y)
Φ
31
3. Transformations as Matrices
Cont’d…
Example:
• Translate the rectangle (2, 2), (2, 8), (10, 8), (10, 2)

2 units along x-axis and 3 units along y-axis.


Cont’d…
Basic 2D Geometric
Transformations (cont.)
 2D Scaling
 Scaling is used to alter the size of an object
 Simple 2D scaling is performed by multiplying
object positions (x, y) by scaling factors sx and sy
x’ = x · sx
y’ = y · sx

35
Basic 2D Geometric
Transformations (cont.)
 2D Scaling
 Any positive value can be used as scaling factor
 Values less than 1 reduce the size of the object
 Values greater than 1 enlarge the object
 If scaling factor is 1 then the object stays unchanged
 If sx = sy , we call it uniform scaling
 If scaling factor <1, then the object moves closer to the
origin and If scaling factor >1, then the object moves
farther from the origin

x’ x
36
Basic 2D Geometric
Transformations (cont.)
 2D Scaling
 Why does scaling also reposition object?
 Answer: See the matrix (multiplication)
 Still no clue?

37
Basic 2D Geometric
Transformations (cont.)
 2D Scaling
 We can control the location of the scaled object by
choosing a position called the fixed point (xf,yf)
x’ – xf = (x – xf) sx y’ – yf = (y – yf) sy

x’=x · sx + xf (1 – sx)
y’=y · sy + yf (1 – sy)
 Polygons are scaled by applying the above formula
to each vertex, then regenerating the polygon using
the transformed vertices

38
Examples

39
Example:

 If the triangle A(1, 1), B(2, 1), C(1, 3) is scaled by a


factor 2, find the new coordinates of the triangle.
Cont’d…
Cont’d…
Example:
• Rotate the rectangle (0, 0), (2, 0), (2, 2), (0, 2) by 30o
ccw about its centroid and find the new coordinates
of the rectangle.
Summary
4. Homogeneous Coordinates
> In order to represent a translation as a matrix multiplication
operation we use 3 x 3 matrices and pad the points to become 3 x 1
matrices.
> This coordinate system (using three values to represent a 2D point) is
called homogeneous coordinates.
> Let the added extra coordinate be W, to a point: P (x, y, W).
> Two sets of homogeneous coordinates represent the same point if
they are a multiple of each other.
> If W ≠ 0 , divide by it to get Cartesian coordinates of point: (x/W,
y/W, 1).
> If W = 0, point is said to be at infinity.
Cont’d…

Transformation matrices for 2D translation are now 3x3.


5. Concatenation of transformation
Cont’d…
Properties of Translations
Homogeneous form of scale

Concatenation of scales
Ex. 1: Rotation of object about arbitrary point P (x, y) by θ

> Translate point (x, y) to origin by


(-x, -y)
> Rotate by θ
> Translate the point by (x, y)
6. Reflections/Mirroring
More Reflections
3 D - Rigid body transformations
 Methods for object modeling transformation in three dimensions
are extended from two dimensional methods by including
consideration for the z coordinate.
 Preserve lines, angles and distances.

# Generalize from 2D by including z


coordinate
# Straight forward for translation and
scale
# Rotation more difficult
# Homogeneous coordinates: 4
components
# Transformation matrices: 4×4
éléments.
3D Point:
 We will consider points as column vectors.

 Thus, a typical point with coordinates (x, y, z) is


represented as:

3D Point Homogenous Coordinate:


 A 3D point P is represented in homogeneous
coordinates by a 4-dim, Vector.
 We don't lose anything.

 The main advantage: it is easier to compose translation


and rotation.
 Everything is matrix multiplication.
3 D - Rigid body transformations
3 D - Rigid body transformations
i. 3D Translation
 In homogeneous coordinates, 3D transformations are represented by
4×4 matrixes:.
 P is translated to P' by:
 An object is translated in 3D

dimensional by transforming
each of the defining points of

the objects .
Cont’d…
# An object represented as a set of polygon surfaces, is translated by
translate each vertex of each surface and redraw the polygon
facets in the new position.
ii. 3D Rotation
 In general, rotations are specified by a rotation axis and an angle.
 In two-dimensions there is only one choice of a rotation axis that leaves
points in the plane.
 The easiest rotation axes are those that parallel to the coordinate axis.
 Positive rotation angles produce counterclockwise rotations about a
coordinate axis, if we are looking along the positive half of the axis toward the
coordinate origin.
Rotation about Z-axis:
:For z axis same as 2D Rotation about X-axis:
rotation:

P′ = Rz(θ) ⋅P P′ = Rx(θ) ⋅P
Cont’d…
• Y-axis rotation:
X’ cos(θ) 0 -sin(θ) 0
Y’ = 0 1 0 0
Z’ sin(θ) 0 cos(θ) 0
1 0 0 0 1
General 3D Rotations about axis // to Coordinate Axis

 Rotation axis parallel with coordinate axis (Example x axis):


iii. 3D Scaling

# About origin: changes the size of the object and repositions the
object relative to the coordinate original.

P′ = S ⋅ P
• Scale about any arbitrary point:
iV. 3D Reflections

 About an axis: equivalent to 180°rotation about that axis.


 About a plane: A reflection through the xy plane.

 A reflections through the xz and the yz planes are defined


similarly.
Exercise
 You sat in the car, and find the side mirror 40mm on your
right and 30mm in your front. You started your car and drove
200mm forward, turned 30 degrees to right, moved 200mm
forward again, and turned 45 degrees to the right, and
stopped.
 What is the position of the side mirror now, relative to where
you were sitting in the beginning?
Solution

# The side mirror position is locally (40, 30).


# The matrix of first driving forward 200mm is:
Cont’d…

 The matrix to turn to the right 30 deg and 45 degrees


(rotating -30 and -45 degrees about the origin) are:

The 3rd transformation is moving by


200mm along an axis oriented 60
degree with the x-axis.
Example
Example
Example
Example
Example
Example
n s ? ? ? ?
QS

You might also like