% Script randTriangle
% Draw a random triangle and evaluate the user's guess of the centroid.

% Set up the window
close all         % Close all previous figure windows
figure            % Start a new figure window
hold on           % Keep the same set of axes (multiple plots on same axes)
axis equal        % unit lengths on x- and y-axis are equal
axis([0 10 0 10]) % x-axis limits [0,10], y-axis limits [0,10]

%%% Do not change the code above %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Modify the code below %%%%%%%%%%

% First point
x1=4;  y1=6;
plot(x1, y1, 'bo')          % blue circle

% Second point, connected to first point
x2=8.5;  y2=7;
plot(x2, y2, 'm+')          % magenta cross
plot([x1 x2],[y1 y2],'k:')  % black dotted line

% Third point, connected to the second
x3=8;  y3=1;
plot(x3, y3, 'rd')          % red diamond
plot([x2 x3],[y2 y3],'b')   % blue solid line (solid line is the default)

% User-clicked point
title('Click on the plot below')
[xu, yu]= ginput(1);
plot(xu, yu, 'k*')          % black asterisk
messageToShow= sprintf('You clicked at (%.1f,%.1f)', xu, yu);
title(messageToShow)




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Do not change the code below %%%

hold off