EMG 2504: CAD/CAM: Graphical Elements and Transformations

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

SoMMME

Department of Mechanical Engineering

EMG 2504: CAD/CAM

Graphical Elements and Transformations

James K. Kimotho
SoMMME
Department of Mechanical Engineering

Basic Graphical Elements

Graphics programming languages describe objects in terms of


basic geometric structures (building blocks) referred to as
output primitives.
These sets of output primitives are then grouped into more
complex structures.
Each output primitive is specified with input coordinate data
and other information about the way that object is to be
displayed.
In CAD these output primitives are the point, line, circle, arc,
polyline and area (rectangular, circular, etc).
These primitives are usually provided by the graphics software
which speeds up the process of generating the image.

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Straight Lines

A series of calculations is required to find all the appropriate


pixels to be lit between the two ends of a line.
Consider a point (x,y) which lies along a line from point (𝑥1 , 𝑦1 )
to point (𝑥2 , 𝑦2 ).
A ratio 𝑝 can be defined as

For similar triangles

Coordinates of a generalized point

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Straight Lines
The value of 𝑝 ranges between 0 and 1.
– 𝑝 = 0, 𝑡ℎ𝑒𝑛 𝑥 = 𝑥1 and 𝑦 = 𝑦1
– 𝑝 < 0, then the generalized point lies on the opposite side of
(𝑥1 , 𝑦1 ) from (𝑥2 , 𝑦2 )
– 𝑝 = 1, then 𝑥 = 𝑥2 and 𝑦 = 𝑦2
– 𝑝 > 1, then the generalized point lies on the opposite side of
(𝑥2 , 𝑦2 ) from (𝑥1 , 𝑦1 )
• This concept is useful when extending lines.
When calculating which pixels are to be lit, the values of ∆𝑥
and ∆𝑦 can be calculated by varying ratio 𝑝 in increments of
∆𝑝.

Whenever a draw line command is selected in a CAD


software, this calculation and the associated pixel fill are
followed.
Graphic elements and Transformations/ 07.06.2022
SoMMME
Department of Mechanical Engineering

Circle
Consider a circle of radius R in 2D plane centered at a point
with coordinates (𝑥1 , 𝑦1 )

The parametric form of the equation of a circle is given as;

If 𝜃 is sufficiently small an almost smooth curve is formed,


however a balance between time spend in processing the
routines and accuracy of the representation is needed.
Graphic elements and Transformations/ 07.06.2022
SoMMME
Department of Mechanical Engineering

Arc

An arc is fully described if its center, its radius and the angles
corresponding to the two end points are specified

This representation uses the same parametric


form as for a full circle, where the end points
are given by

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Graphical Transformations

All design models are set in a coordinate system. In computer


graphics, there are two coordinate systems:
1. the object coordinate system
2. the view coordinate system.
The object coordinate system is where the object is defined.
The view coordinate system defines the angle from which to
observe the object.
An object in the view coordinate system is at a position and
orientation different from that of the same object in the object
coordinate system.
Viewing an object from different directions and distances can
be achieved by moving the view coordinate system around
using coordinate system transformation.

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Graphical Transformations

There are three major transformations:


1. translation - involves moving a point (or the view coordinate
frame) linearly from an origin
2. rotation - an object is rotated about a point (origin)
3. scaling - in which an object is enlarged or reduced with reference
to a point.

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Translation

In pure linear transformation the separate translation values


𝑥, 𝑦 and 𝑧 can be added independently to each axis to achieve
the new translated coordinates

This can be represented in matrix form as;

Transformation
Matrix, 𝑇

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Scaling

Scaling is applied to each axis independently

In matrix form:

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Rotation

A 3D Rotation is treated as a series of 2D rotations

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Concatenation of Transformations
To combine all 3 transformations into one matrix, a
homogenous transformation is used.
A homogenous transformation matrix is a 4×4 matrix formed
by introducing a unit coordinate.
A point is represented by a 4D vector as:

Transformation matrices may be written as:

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Concatenation of Transformations

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Graphical Transformations

Example
– Point 𝐴 = 1 3 1 is translated by 𝑇𝑟 = 1 1 1 , rotated about
X-axis, 90𝑜 and then rotated about Y-axis 45𝑜 . What is the A' in
the coordinate frame?

Graphic elements and Transformations/ 07.06.2022


SoMMME
Department of Mechanical Engineering

Thank You
for
Your Kind Attention!
Dr.-Ing. James Kuria Kimotho Department of Mechanical Engineering
jkuria@eng.jkuat.ac.ke JKUAT
P.O. Box 62000-00200
Tel: Nairobi

You might also like