% ShowSeparation
% Illustrates the instance method DiffSide in the point class
clc
clear
close all
figure
plot([-5 5],[0 0],':k',[0 0],[-5 5],':k')
axis equal square
hold on
% Create two points and display the line that goes through them...
P1 = Point(4,1);
P1.Show('k')
P2 = Point(-3,-3);
P2.Show('k')
plot([-5 5],[-3-8/7 1+4/7],'k')
% Generate random points and see if they are separated by the line...
for k=1:10
Q = Point(-5+10*rand(),-5+10*rand());
R = Point(-5+10*rand(),-5+10*rand());
if Q.DiffSide(R,P1,P2)
Q.Show('g')
R.Show('g')
title(' Separated ','fontsize',18)
else
Q.Show('r')
R.Show('r')
title(' Not Separated ','fontsize',18)
end
pause(2)
if k<10
Q.Show('w')
R.Show('w')
end
end