Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matlab (given three points , how to find a circular arc. )

Subject: matlab (given three points , how to find a circular arc. )

From: Sam park

Date: 23 Nov, 2010 15:56:04

Message: 1 of 2

given three points , how to find a circular arc.

there is 3 points.

p1(x1,y1) p2(x2,y2) p3(x3,y3)


I have to find arc of the 3 point connection.

this is m-file.

=====================================
function case1(x1,y1,x2,y2,x3,y3)
 

 x21 = x2-x1; y21 = y2-y1;
 x31 = x3-x1; y31 = y3-y1;
 
 
 h21 = x21^2+y21^2; h31 = x31^2+y31^2;
 d = 2*(x21*y31-x31*y21);
 a = x1+(h21*y31-h31*y21)/d;
 b = y1-(h21*x31-h31*x21)/d;


 r = sqrt(h21*h31*((x3-x2)^2+(y3-y2)^2))/abs(d);

 
a1=atan((y1-b)/(x1-a))
a2=atan((y3-b)/(x3-a))

th=0;

if x1<a
a2 = a2 -2*pi;
end

r=sqrt((x1-a)^2+(y1-b)^2)

th = linspace( a1 , a2 , 1000);
D = (x2-x1)*(y2-y1);
if D > 0
    Px = a - r*cos(th);
    Py = b - r*sin(th);
elseif D < 0
   Px = a + r*cos(th);
   Py = b + r*sin(th);
elseif D==0
    if (x3-x1)*(y3-y1)>0
        Px = a - r*cos(th);
        Py = b - r*sin(th);
    else
        Px = a + r*cos(th);
       Py = b + r*sin(th);
   end
 
end


plot(Px,Py), grid on
=====================================
 I have failed this problem TT in matlab.
 For example, in this case (x1=x2) i type case1(3,4,3,6,6,5) In matlab<<<
. I cant obtain correct graph in matlab.

thanks for your effort
 

Subject: matlab (given three points , how to find a circular arc. )

From: Matt J

Date: 23 Nov, 2010 16:24:04

Message: 2 of 2

"Sam park" <ts10004ok@hanmail.net> wrote in message <icgo6k$22o$1@fred.mathworks.com>...
>
> I have failed this problem TT in matlab.
> For example, in this case (x1=x2) i type case1(3,4,3,6,6,5) In matlab<<<
> . I cant obtain correct graph in matlab.
=========

This appears to be the 4th time you've posted this question. It will be of no benefit to you to keep rebooting the discussion.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us