Topic 3 - Basic Concepts of Graphics Programming
Topic 3 - Basic Concepts of Graphics Programming
Resource Persons
DEPARTMENT OF INDUSTRIAL AND MANUFACTURING ENGINEERING,
NED UNIVERSITY OF ENGINEERING AND TECHNOLOGY, KARACHI. Dr. Muhammad Wasif
Assistant Professor
OBJECTIVES
Following are the objectives of this topic;
EXPECTATIONS
Following are the expectations from participants
10
z
P
TYPE OF COORDINATE SYSTEM Z
z
Cartesian Coordinates: based on distances along the R P
three dimensions) - P(x, 𝑦, 𝑧) or θ Z
Polar Coordinates: based on radial distance, angle on R
a plan and distance along z – P(R, 𝜃, 𝑧) or Polar Coordinate System
11
CARTESIAN COORDINATES
z
x y
12
POLAR COORDINATES
z
13
POLAR COORDINATES
14
z
P
TYPE OF COORDINATE SYSTEM Z
z
Cartesian Coordinates: based on distances along the R P
three dimensions) - P(x, 𝑦, 𝑧) or θ Z
Polar Coordinates: based on radial distance, angle on R
a plan and distance along z – P(R, 𝜃, 𝑧) or Polar Coordinate System
15
z
P
TYPE OF COORDINATE SYSTEM Z
z
Cartesian Coordinates: based on distances along the R P
three dimensions) - P(x, 𝑦, 𝑧) or θ Z
Polar Coordinates: based on radial distance, angle on R
a plan and distance along z – P(R, 𝜃, 𝑧) or Polar Coordinate System
16
IN-CLASS ACTIVITY-3.1
A point in space is represented by P(6,4,11) in millimeters. z
Determine the equivalent point in Polar and Spherical P
Coordinate Systems. 11
Important Note: Perform it on a separate paper and keep
in notes, this activity will be submitted in assignment file at x 4 6 y
the end of semester. Keep your copy for your record and Cartesian Coordinate System
examination preparation.
Polar Coordinate P(R, 𝜃, 𝑧) = P(7.211mm,33.7°,11mm)
Spherical Coordinate P(R, 𝜃, 𝜑) = P(7.211mm,33.7°,55.75°)
17
IN-CLASS ACTIVITY-3.2
A point in space is represented by P(12mm,60°,30°).
Determine the equivalent point in Cartesian and Polar
R P
Coordinate Systems.
φ
Important Note: Perform it on a separate paper and keep θ
in notes, this activity will be submitted in assignment file at R
the end of semester. Keep your copy for your record and Spherical Coordinate System
examination preparation.
Cartesian Coordinate P(x, 𝑦, 𝑧) = P(5.192mm, 9, 6mm)
Polar Coordinate P(R, 𝜃, 𝑧) = P(12mm,60°,6mm)
18
MATLAB FUNCTION
function y1=trancs(n,x)
% Enter n=1 if input is in Carterian coordinte r=sqrt(y1(1)^2+y1(2)^2+x(3)^2);
% Enter n=2 if input is in Polar coordinte si=acosd(x(1)/r);
% Enter n=3 if input is in Spehrical coordinte fprintf('Polar in Carterian coorinate is :
% Use function cc=trancs(1,[2 3 4]) (%f,%f,%f)',y1(1),y1(2),x(3));
% where [2 3 4] represents coordinate, output is in same format fprintf('\nPolar in Spherical coorinate is:
if n==1 (%f,%f,%f)\n',x(1),x(2),si);
R=sqrt(x(1)^2+x(2)^2); elseif n==3
theta=asind(x(2)/R); y1(3)=x(1).*sind(x(3));
si=atand(x(3)/R); r=x(1).*cosd(x(3));
fprintf('Cartesian in Polar coorinate is : y1(1)=r.*cosd(x(2));
(%f,%f,%f)',R,theta,x(3)); y1(2)=r.*sind(x(2));
fprintf('\nCartesian in Spherical coorinate is: fprintf('Spherical in Carterian coorinate is :
(%f,%f,%f)\n',R,theta,si); (%f,%f,%f)',y1(1),y1(2),y1(3));
elseif n==2 fprintf('\nSpherical in Polar coorinate is :
y1(1)=x(1).*cosd(x(2)); (%f,%f,%f)\n',x(1),x(2),y1(3));
y1(2)=x(1).*sind(x(2)); end
19
20
21
22
23
24
25
26
27
28
PROJECTIONS IN DESIGN
PROJECTIONS
PARALLEL
PERSPECTIVE
(parallel projectors)
(converging projectors)
One point
Orthographic Oblique
(projectors not perpendicular to (one principal
(projectors perpendicular vanishing point)
to view plane) view plane)
Two point
Axonometric General (Two principal
Multiview vanishing point)
(view plane (view plane not parallel
parallel to principal to principal planes) Cavalier
planes) Three point
(Three principal
Cabinet vanishing point)
29
ASSIGNMENT - 1
Assignment - 1
30
31
xv
screen Ov
zv
From similar triangle
S
Xs Xv
• Distances Xs and Ys are along the horizontal and vertical directions along the screen. L Zv
• Equations states that the larger the value of Zv, will increase the size of image i.e. the S
lengths Xs and Ys. Ys Yv
• Therefore the nearer object looks larger as compared to the same distant object. L Zv
32
xv
screen Ov
zv
Xs Xv
Ys Yv
• No effect on size of distant or nearer objects.
• When the viewing plane is perpendicular to the viewing direction, it is called orthographic view.
• When the viewing plane is not perpendicular to the viewing direction, it is called oblique view.
33
HOMOGENOUS COORDINATES
A 3D coordinate “P” can be represented by P(x,y,z) in a
3D 3 space.
It can also be represented by P(wx,wy,wz,w), where
w≠0, in 4 space, specifying a finite space, this
representation is called homogenous coordinate of a
point.
Diving all coordinates by “w”, point P(wx,wy,wz,w) can
also be specified as P(x,y,z,1).
© DR. MUHAMMAD WASIF (ASSISTANT PROFESSOR - IMD, NED UET) 34
34
PROJECTION CALCULATIONS z
Coordinate y
value in MCS World Viewing
y Model
Model Coordinate Coordinate
Coordinate
Transformation System System
System x
Coordinate OM
value in WCS
Viewing Ov Viewsite x
Transformation
Coordinate z y
value in vCS
v Device
Projection v OW x Coordinate
Transformation
Projection in Virtual System
Image
VCS Coordinate
OD u
Viewing System
Projection in z
DCS OV u Screen
Viewpoint
© DR. MUHAMMAD WASIF (ASSISTANT PROFESSOR - IMD, NED UET) 35
35
PROJECTION CALCULATIONS
The procedure of calculating projections points;
The coordinate of points in MCS are transformed to WCS
using the model transformation.
The coordinate of the points in WCS are transformed to
vCS using the viewing transformation.
The coordinate of the points in vCS are transformed to VCS
using the viewing transformation (Xs and Ys).
Finally, the point in VCS are transformed to the DCS using
the device driver routine.
© DR. MUHAMMAD WASIF (ASSISTANT PROFESSOR - IMD, NED UET) 36
36
WINDOW
It defines the region in space that will be projected onto the display
monitor.
The visible region, called viewing volume.
To simplify the viewing volume, it is cut by near and far planes.
37
VIEWPORTS
It is an area to which the viewing volume
defined by the window is mapped.
Mapping will involve a translation and a scaling
to take into account the deviation of the
viewport center from the center of the display
monitor and the size difference between the
window and the viewport.
The Xs and Ys are to scaled to the projection in
the viewport.
38
REFERENCES
1. e-Design Computer-Aided Engineering Design by Kuang-Hua Chang,
Elsevier, 2015
2. Principals of CAD/CAM/CAE by Kunwoo Lee, Wesley Longman, Inc.
3. Mastering CAD/CAM by Ibrahim Zeid, McGraw-Hill
Science/Engineering/Math, 2008.
39