Engr 231 lab 5

Engr 231 lab 5 - Drexel University - ENGR 231 Linear...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Drexel University - ENGR 231 Linear Engineering Systems, Fall 2011 Copyright 2011, Drexel University Page 1 Lab 5 - Homogeneous Coordinate Transformations Goals: 1. Perform homogeneous coordinate transformations, as in section 2.7. 2. Display animations using transformations. Prelab - Drawing shapes with MATLAB As the title of the lab suggests, we will be applying the concepts of homogeneous coordinates from Lay, Section 2.7 , to perform some basic image transformations via MATLAB. However, before we may begin transforming basic images, we introduce the concept of drawing shapes and polygons with MATLAB. Shapes can be plotted in MATLAB by using the fill function. Similar to the plot function, this takes a set of coordinates and a color, and plots a 2D image. The coordinate pairs passed to the fill function however determine the vertices of a polygon. When the function is called, MATLAB will start at the first coordinate pair, draw a line segment to the next one, and so on until the last coordinate pair is reached. MATLAB will then draw a final segment to close the object and fill it with the specified color. Note the when using the fill command, the order of the points matter! Let’s examine the following example. Suppose we wanted to plot a red object with the following vertices: Vertex 1 2 3 X – Coordinates 0.0 0.5 1.0 Y – Coordinates 0.0 1.5 0.0 First, we form a matrix of all of the above points with the x -coordinates in the first row and y - coordinates in the second row. Each column thus represents a vertex coordinate pair in 2D ( again note that the order matters ). The actual code to do this and to then plot the object is shown below in Example 1. Ex 1: %% Plot the Three Above Vertices as a Red Polygon % Form the coordinate matrix triangle = [0 0.5 1.0 0 1.5 0.0]; % Call the fill function. First input is the x-values of the vertices % and second input is the y-values fill(triangle(1,:),triangle(2,:), 'r' ) axis equal Executing the code in Example 1 produces the following image:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Drexel University - ENGR 231 Linear Engineering Systems, Fall 2011 Copyright 2011, Drexel University Page 2 -0.5 0 0.5 1 1.5 0 0.5 1 1.5 Prelab Part 2 – Image Transformations in Homogeneous Coordinates Now suppose we wanted to transform the above image based on some of the concepts we learned about in Section 2.7. For instance, to performing a rotation about the origin we know that the transformation looks like: Rot( T
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Engr 231 lab 5 - Drexel University - ENGR 231 Linear...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online