Solved

Please see my code and diagram... how do I find the coordinates of intersection of circles

Posted on 2009-04-07
8
316 Views
Last Modified: 2016-02-10
Please find below the code that results in the screenshot below.
How do I get Matlab to tell me the intersections of the two circles?

thanks in advance
clear % all variables

figure(1), hold off

set(gca,'FontSize',14) % adjust fontsize
 

text(0,10,'\leftarrow RX2 (x3,y3)=(0,10)','VerticalAlignment','middle','HorizontalAlignment','left')

text(0,0,'\leftarrow RX1 (x3,y3)=(0,0)','VerticalAlignment','middle','HorizontalAlignment','left')
 

center4=[0,0];

radius4=11;

N4=100; % number of points (circle resolution)

hold on

H=circle(center4,radius4,N4,'r-');
 

center5=[0,10];

radius5=1;

N5=100; % number of points (circle resolution)

hold on

H=circle(center5,radius5,N5,'r-');
 

center6=[0,0];

radius6=15;

N6=100; % number of points (circle resolution)

hold on

H=circle(center6,radius6,N6,'r-');
 

center7=[0,10];

radius7=5;

N7=100; % number of points (circle resolution)

hold on

H=circle(center7,radius7,N7,'r-');

Open in new window

screener.jpg
0
Comment
Question by:jtiernan2008
  • 4
  • 3
8 Comments
 
LVL 15

Expert Comment

by:yuk99
ID: 24090965
I can see it's from your discussion here:
http://www.experts-exchange.com/Other/Math_Science/Q_24296354.html

Do you really need a code for this? Can you see the intersections by eyes?

Let me give you this code, so you can set the intersections manually so see them clearly. Paste it at the end of your drawing code. You will see a cross cursor on the figure. Click on the circles intersections you need. When you finish press Enter.
You can change line color and width as well as marker type and size as you wish.
[x,y]=ginput;

plot(x,y,'ro-','linewidth',2,'markersize',10)

Open in new window

0
 
LVL 15

Expert Comment

by:yuk99
ID: 24091360
OK, if you really want to do it automatically, here is another fileexchange submission you need:
http://www.mathworks.com/matlabcentral/fileexchange/11837
0
 
LVL 1

Author Comment

by:jtiernan2008
ID: 24091452
thanks a million...

I dont think I am using the code correctly.

I have attached in the code box below. Can you please have a look and see what I am doing wrong?


clear % all variables

figure(1), hold off

set(gca,'FontSize',14) % adjust fontsize
 

text(0,10,'\leftarrow RX2 (x3,y3)=(0,10)','VerticalAlignment','middle','HorizontalAlignment','left')

text(0,0,'\leftarrow RX1 (x3,y3)=(0,0)','VerticalAlignment','middle','HorizontalAlignment','left')
 

center4=[0,0];

radius4=11;

N4=100; % number of points (circle resolution)

hold on

H=circle(center4,radius4,N4,'r-');
 

center5=[0,10];

radius5=1;

N5=100; % number of points (circle resolution)

hold on

H=circle(center5,radius5,N5,'r-');
 

center6=[0,0];

radius6=15;

N6=100; % number of points (circle resolution)

hold on

H=circle(center6,radius6,N6,'r-');
 

center7=[0,10];

radius7=5;

N7=100; % number of points (circle resolution)

hold on

H=circle(center7,radius7,N7,'r-');
 

[X0,Y0] = intersections(0,0,0,10,true)

Open in new window

0
 
LVL 15

Expert Comment

by:yuk99
ID: 24091505
No, X1, Y1,X2 and Y2 are not the centers of your circles. Those are vectors for X and Y data of your curves that are circles itself. You need to extract them from your circles. Here is the code for one circle.
Note as I found sometimes it actually misses an intersection when curves just touch each other.

H1=circle(center,radius,N);

X1=get(H1,'XData');

Y1=get(H1,'YData');

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:jtiernan2008
ID: 24091682
I tried as per the code box but the text is distorted and also is it possible to get the coordinates printed on the screen?
clear % all variables

figure(1), hold off

set(gca,'FontSize',14) % adjust fontsize
 

text(0,10,'\leftarrow RX2 (x3,y3)=(0,10)','VerticalAlignment','middle','HorizontalAlignment','left')

text(0,0,'\leftarrow RX1 (x3,y3)=(0,0)','VerticalAlignment','middle','HorizontalAlignment','left')
 

center4=[0,0];

radius4=11;

N4=100; % number of points (circle resolution)

hold on

H1=circle(center4,radius4,N4,'r-');
 

center5=[0,10];

radius5=1;

N5=100; % number of points (circle resolution)

hold on

H2=circle(center5,radius5,N5,'r-');
 

center6=[0,0];

radius6=15;

N6=100; % number of points (circle resolution)

hold on

H3=circle(center6,radius6,N6,'r-');
 

center7=[0,10];

radius7=5;

N7=100; % number of points (circle resolution)

hold on

H4=circle(center7,radius7,N7,'r-');
 

X1=get(H1,'XData');

Y1=get(H1,'YData');
 

X2=get(H2,'XData');

Y2=get(H2,'YData');
 

X3=get(H3,'XData');

Y3=get(H3,'YData');
 

X4=get(H4,'XData');

Y4=get(H4,'YData');
 

[X01,Y01] = intersections(X1,Y1,X2,Y2,1);

[X02,Y02] = intersections(X3,Y3,X4,Y4,1);
 

text(X01,Y01,'\leftarrow intersection', 'VerticalAlignment','middle','HorizontalAlignment','left')

text(X02,Y02,'\leftarrow intersection', 'VerticalAlignment','middle','HorizontalAlignment','left')

Open in new window

0
 
LVL 27

Accepted Solution

by:
d-glitch earned 250 total points
ID: 24091770
I think you might do a lot better with graph paper and a compass.
You should be able to see where the intersections are by eye well enough for this exercise.
You want to find enough points that you can draw the locus.  There is a predictable pattern.
The real goal is develop some intuition.  Matlab may be getting in the way.
0
 
LVL 15

Assisted Solution

by:yuk99
yuk99 earned 250 total points
ID: 24091869
d-glitch,
You are exactly right!!! :)
I didn't want to give the answer here originally. Just for the sake of the question.

jtiernan2008,
I appreciate your points and that you are trying to study Matlab. But I think your main purpose was to understand TOA principles.
0
 
LVL 1

Author Closing Comment

by:jtiernan2008
ID: 31618491
I am trying to learn both.
thanks for your help. I need to get graph paper and get working :)
thanks for your help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
fizzArray2 challenge 1 72
EvenOdd challenge 10 91
groupSumClump challenge 9 103
Re-position the objects 7 99
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now