Determining two lines in MATLAB
Posted
by
Sanyi
on Stack Overflow
See other posts from Stack Overflow
or by Sanyi
Published on 2010-12-27T12:20:12Z
Indexed on
2010/12/27
16:53 UTC
Read the original article
Hit count: 196
Hi! I am making the game planarity in MATLAB, and i am stuck where the program have to determine that is there any lines that are in inscision with each other. Any ideas how could the program find the inscision points. Heres my source for the game:
> clear;
clc;
a=1;
b=10;
x=floor(rand(5,1)*(b-a+1)+a);
y=floor(rand(5,1)*(b-a+1)+a);
fig1=figure;
set(fig1,'Color','w','Position',[100 100 500 500])
plot(x,y,'o','MarkerSize',12,'MarkerFaceColor','r');
axis([0 11 0 11]);
axis off
grid on;
hold on;
FirstPlayerLines=[];
SecondPlayerLines=[];
for a1=1:+1:2
for a2=5:-1:2
plot([x(a1) x(a2)],[y(a1) y(a2)],'Color','black','LineWidth',3);
end
end
waitforbuttonpress
© Stack Overflow or respective owner