Adventures of The Cube Roland Miezianko CIS 581 Computer Graphics and Image Processing
Download
Report
Transcript Adventures of The Cube Roland Miezianko CIS 581 Computer Graphics and Image Processing
Adventures of The Cube
Roland Miezianko
CIS 581
Computer Graphics and Image Processing
Prof. Longin Jan Latecki
Roland Miezianko, CIS581
1
Objective
Construct a 3D object in Matlab (Cube)
Create and use Homogenous Coordinates
Compute all transformations:
•
•
•
•
Translation
Scaling
Rotation x,y,z-axis
Flyby
Roland Miezianko, CIS581
2
Construct the Cube, matrix data
Define matrix of vertices
• 8x3 matrix
Define matrix of faces
• 6x4 matrix
Define matrix of vertex and face colors
• 6x3 matrix
Roland Miezianko, CIS581
3
Construct the Cube, display
Construct cube using the patch
command
• patch('Vertices', v, 'Faces', f, 'FaceVertexCData',
fvc, 'FaceColor', 'flat', 'EdgeColor', 'none')
Set colors to be transparent
• alpha(.5);
Roland Miezianko, CIS581
4
Homogeneous Equations
Matlab vertices are defined as triplet
• N x 3 matrix
Must add additional column to the vertex
matrix (N x 4 matrix)
• Vw = [v vw]';
Roland Miezianko, CIS581
5
Matrix Operations
Matrix operation to translate, scale, and
rotate
• Rotate about x-axis example
rx = [
1
0
0
0
0
cos(xang)
sin(xang)
0
0
-sin(xang)
cos(xang)
0
0;
0;
0;
1];
Vw = [v vw]';
Vcomp = ( rx * Vw )';
Vnew = Vcomp(:,1:3);
Roland Miezianko, CIS581
6
The Movie
"Adventures of The Cube"
Roland Miezianko, CIS581
7