Adventures of The Cube Roland Miezianko CIS 581
Adventures of The Cube Roland Miezianko CIS 581 Computer Graphics and Image Processing Prof. Longin Jan Latecki Roland Miezianko, CIS 581 1
Objective b Construct a 3 D object in Matlab (Cube) b Create and use Homogenous Coordinates b Compute all transformations: • • Translation Scaling Rotation x, y, z-axis Flyby Roland Miezianko, CIS 581 2
Construct the Cube, matrix data b Define matrix of vertices • 8 x 3 matrix b Define matrix of faces • 6 x 4 matrix b Define matrix of vertex and face colors • 6 x 3 matrix Roland Miezianko, CIS 581 3
Construct the Cube, display b Construct cube using the patch command • patch('Vertices', v, 'Faces', f, 'Face. Vertex. CData', fvc, 'Face. Color', 'flat', 'Edge. Color', 'none') b Set colors to be transparent • alpha(. 5); Roland Miezianko, CIS 581 4
Homogeneous Equations b Matlab vertices are defined as triplet • N x 3 matrix b Must additional column to the vertex matrix (N x 4 matrix) • Vw = [v vw]'; Roland Miezianko, CIS 581 5
Matrix Operations b Matrix operation to translate, scale, and rotate • Rotate about x-axis example rx = [ 1 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, CIS 581 6
The Movie "Adventures of The Cube" Roland Miezianko, CIS 581 7
- Slides: 7