% Construct a parallelogram:
% Given one fixed point, 1 randomly generated point, and 1 user-selected
% point, compute and draw a 4th point that would make a parallelogram.

% 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]
title('Click below in the graph area but not on the line')

% First vertex, show as a blue asterisk
x1=4; y1=3;
plot(x1, y1, 'b*')

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

% Second vertex
x2= 5;
y2= 8.5;
plot(x2, y2, 'b*')

% Connect vertices 1 and 2 with a black dotted line
plot([x1 x2], [y1 y2], 'k:')

% Get user-input third vertex and display it as a red circle
[x3, y3]= ginput(1);
plot(x3, y3, 'ro')
messageToPrint= sprintf('You made a mouse click at (%.1f,%.1f)', x3, y3);
title(messageToPrint)

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

hold off