![Page 1: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/1.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Lab 9: 3D & ProjectionsLab 9: 3D & ProjectionsBasicsBasics
![Page 2: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/2.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Tutorial contents
Introduction to ProjectionsBasic ConceptsProjection Types and Matrix
OrthographicPerspective
Solve Examples
![Page 3: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/3.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Introduction to Projections
We live in a 3D world but the screen where the rendered objects appear is a 2D space. Thus, we need to convert somehow our 3D world to 2D.
The operation which does this conversion is called projection.
When Programming we focus on 2 main types of projections Orthographic – casts parallel rays of light from the scene to projection plane Perspective – casts angled rays of light from the scene to projection plane
Perspective projection generates a realistic effect since our vision works the same way
![Page 4: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/4.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Basic Concepts
camera coordinatesystem
viewport coordinatesystem
device/screencoordinate system
![Page 5: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/5.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Projection Type - Orthographic
r0 – a vector pointing from world origin to Projection plane origin
r – object point vector (from world origin to P)
P – object point P’ – projected point U – view direction Z’ – distance from P to P’ along U r’ – P’ coordinates in word CS u1,u2 – projected image main axis
x’,y’ – P’ coordinate in image CS
P P’
![Page 6: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/6.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Projection Matrix - Orthographic
When U is Orthogonal to u1 and u2 we can simplify the equations to get the matrix
If U is not orthogonal (like in oblique parallel) we must use the equations given in the lecture
1
2
0
0
0
0 0 0 1 0 0 0 1
x
yOrthographic
z
u r
u I rM
u r
0 2 0 1 0 1 2
1 2 2 1 1 2
( )( ) ( )( ) ( )( )' , ' , '
( ) ( ) ( )
r r u u r r u u r r u uX Y Z
u u u u u u u u u
![Page 7: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/7.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Projection Type - Perspective
rv – eye coordinates
Other vectors defined above
![Page 8: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/8.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Projection Matrix
By selecting rv=r0+du
We can use the matrix form
We can see that d causes a scaling effect
1
2
0 0 0 0
0 0 0 0
0 0 0 0
0 0 1 0 0 0 1 0 0 0 1
x
yPerspective
z
d u r
d u I rM
d u r
d
![Page 9: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/9.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
Given a cube in 3D spacex = [0 1 1 0 0 0 1 1 0 0 1 1 1 1 0 0]-0.5;
y = [0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1]-0.5;
z = [0 0 0 0 0 1 1 1 1 1 1 0 0 1 1 0]-0.5;
We wish to find the isometric projection so we can see the cube in a 2D plane
![Page 10: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/10.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
From the lectures – Isometric projection
The rotation around y axis is φ=45 The rotation around x axis is θ=35.2
![Page 11: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/11.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
Plot the 3D space for visualization
%plot cube in 3D space
Figureh=figure('NumberTitle','off','Name','3D space',...
'Position',[200 300 500 500]);
line(x,y,z);
view(3);
daspect([1,1,1]);
set(gca,'XLabel',text('string','X'),'YLabel',text('string','Y'),'ZLabel',text('string','Z'));
![Page 12: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/12.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
Task:
Define the projection matrix
![Page 13: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/13.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
Solution:
Set the projection matrix
MIsometric=[cosd(phi) 0 sind(phi) 0; sind(teta)*sind(phi) cosd(teta) -sind(teta)*cosd(phi) 0;...
-sind(phi)*cosd(teta) sind(teta) cosd(teta)*cosd(phi) 0;0 0 0 1];
Task
Convert to homogeneous coordinates[m,n] = size(x);
x4d = [x(:),y(:),z(:),ones(m*n,1)]'; %homographic coordinates
![Page 14: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/14.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
Solution
Convert to homogeneous coordinates[m,n] = size(x);
x4d = [x(:),y(:),z(:),ones(m*n,1)]'; %homographic coordinates
![Page 15: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/15.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
Task
Calculate the points location in 2D and plot
![Page 16: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/16.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
Solution
Calculate the points location in 2D and plot
%project to 2D
x2d = MIsometric*x4d;
x2 = zeros(m,n); y2 = zeros(m,n);
x2(:) = x2d(1,:);
y2(:) = x2d(2,:);
Figureh=figure('NumberTitle','off','Name','2D space',...
'Position',[800 300 500 500]);
plot(x2,y2)
set(gca,'XLim',[-1 1],'YLim',[-1 1],'XLabel',text('string','u1'),'YLabel',text('string','u2'));
![Page 17: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/17.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
Output – Question : Why is there a difference?
![Page 18: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/18.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Solve Examples
Answer: which view is MATLAB default? Probably not isometric
![Page 19: Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 9: 3D & Projections Basics](https://reader030.vdocument.in/reader030/viewer/2022032523/56649d825503460f94a680e6/html5/thumbnails/19.jpg)
Technion - Israel Institute of TechnologyFaculty of Mechanical Engineering
Laboratory for CAD & Lifecycle Engineering
Notes and References
This is not (!!!) the way to use projections in MATLAB This is just an illustrated example of how projections work.
Mathworks Documentation Center - http://www.mathworks.com/help/documentation-center.html