More tests + GUI
[ltsps.git] / drawRoute.m
blob482f08c59259ce1bbf28239583135e1cb581b593
1 function drawRoute (route, coordsMatrix)
2     % drawRoute
3     % description: draws a given TSP route on the figure.
4     % author: Laurens Van Houtven <lvh@laurensvh.be>
5     % date: 4 Oct 2008
6     
7     % Find the length of the route.
8     routeDims = size(route);
9     routeLen = routeDims(2);
10     
11     % Extract coordinate vectors for easy access.
12     xSourceCoords = coordsMatrix(:,2);
13     ySourceCoords = coordsMatrix(:,3);
14     
15     % Initialize drawing vectors for speed.
16     xDrawCoords = zeros(routeLen);
17     yDrawCoords = zeros(routeLen);
18     
19     for i = 1:routeLen
20         % Where are we?
21         thisVertex = route(i);
22         
23         % Add the coordinates of this vertex to the draw vector.
24         xDrawCoords(i) = xSourceCoords(thisVertex);
25         yDrawCoords(i) = ySourceCoords(thisVertex);
26     end
27     
28     % Plot the two drawvectors with a yellow line between them.
29     plot(xDrawCoords, yDrawCoords, 'Color', 'blue');
30     
31     % Draw it on the current frame.
32     hold on;
33     drawnow;
34 end