% ShowNearInclude
% Checks the instance methods Nearest and Include
clc
clear
close all
figure
plot([-5 5],[0 0],':k',[0 0],[-5 5],':k')
axis equal square
title('Click in the Vertices of the Triangle...','fontsize',18)
hold on
[x,y] = ginput(3);
% Create and display the triangle...
T = Triangle(Point(x(1),y(1)),Point(x(2),y(2)),Point(x(3),y(3)));
T.Show('k')
title(' Click in a point P.. ','fontsize',18)
% Create and display the point P...
[x,y] = ginput(1);
P = Point(x,y);
P.Show('g')
% Compute and display Q, the closest point on the perimeter of T to P...
Q = T.Nearest(P);
Q.Show('r')
% Comment on the inclusion of P
if T.Include(P)
xlabel(' P is inside the triangle ','fontsize',18)
else
xlabel(' P is outside the triangle','fontsize',18)
end