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:
Function to calculate radius from three points

Subject: Function to calculate radius from three points

From: Lee Hudson

Date: 14 Jul, 2006 12:06:31

Message: 1 of 6

Does anyone know if there is a MATLAB function that will calculate
the radius of a cirlce specified from three points in the perimeter?
For example,
x1,y1
x2,y2
x3,y3
Thanks,
Lee

Subject: Function to calculate radius from three points

From: ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford)

Date: 14 Jul, 2006 16:42:56

Message: 2 of 6

In article <ef3bc24.-1@webcrossing.raydaftYaTP>, "Lee Hudson"
<lee.hudson_2@philips.com> wrote:

> Does anyone know if there is a MATLAB function that will calculate
> the radius of a cirlce specified from three points in the perimeter?
> For example,
> x1,y1
> x2,y2
> x3,y3
> Thanks,
> Lee
------------------
  There is no single matlab function that will calculate it, but you can
make use of the geometrical theorem that the radius of a circumscribing
circle of a triangle is equal to the product of its three sides divided by
four times the triangle's area.

a = sqrt((x1-x2)^2+(y1-y2)^2); % The three sides
b = sqrt((x2-x3)^2+(y2-y3)^2);
c = sqrt((x3-x1)^2+(y3-y1)^2);
s = (a+b+c)/2;
A = sqrt(s*(s-a)*(s-b)*(s-c)); % Area of triangle
R = a*b*c/(4*A); % Radius of circumscribing circle

(Remove "xyzzy" and ".invalid" to send me email.)
Roger Stafford

Subject: Function to calculate radius from three points

From: Lee Hudson

Date: 14 Jul, 2006 13:21:29

Message: 3 of 6

Thanks a million, Roger, that will do the trick.
Regards,
Lee

Roger Stafford wrote:
>
>
> In article <ef3bc24.-1@webcrossing.raydaftYaTP>, "Lee Hudson"
> <lee.hudson_2@philips.com> wrote:
>
>> Does anyone know if there is a MATLAB function that will
> calculate
>> the radius of a cirlce specified from three points in the
> perimeter?
>> For example,
>> x1,y1
>> x2,y2
>> x3,y3
>> Thanks,
>> Lee
> ------------------
> There is no single matlab function that will calculate it, but
> you can
> make use of the geometrical theorem that the radius of a
> circumscribing
> circle of a triangle is equal to the product of its three sides
> divided by
> four times the triangle's area.
>
> a = sqrt((x1-x2)^2+(y1-y2)^2); % The three sides
> b = sqrt((x2-x3)^2+(y2-y3)^2);
> c = sqrt((x3-x1)^2+(y3-y1)^2);
> s = (a+b+c)/2;
> A = sqrt(s*(s-a)*(s-b)*(s-c)); % Area of triangle
> R = a*b*c/(4*A); % Radius of circumscribing circle
>
> (Remove "xyzzy" and ".invalid" to send me email.)
> Roger Stafford
>

Subject: Function to calculate radius from three points

From: joa

Date: 15 Jul, 2006 14:18:46

Message: 4 of 6

I posted a function to do that here a while ago.
http://mathforum.org/kb/message.jspa?messageID=4268996&tstart=0

r = 1/k


"Lee Hudson" <lee.hudson_2@philips.com> schreef in bericht
news:ef3bc24.-1@webcrossing.raydaftYaTP...
> Does anyone know if there is a MATLAB function that will calculate
> the radius of a cirlce specified from three points in the perimeter?
> For example,
> x1,y1
> x2,y2
> x3,y3
> Thanks,
> Lee

Subject: Function to calculate radius from three points

From: Karl

Date: 7 Apr, 2013 13:02:05

Message: 5 of 6

ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford) wrote in message <ellieandrogerxyzzy-1407060942560001@dialup-4.232.6.49.dial1.losangeles1.level3.net>...
> In article <ef3bc24.-1@webcrossing.raydaftYaTP>, "Lee Hudson"
> <lee.hudson_2@philips.com> wrote:
>
> > Does anyone know if there is a MATLAB function that will calculate
> > the radius of a cirlce specified from three points in the perimeter?
> > For example,
> > x1,y1
> > x2,y2
> > x3,y3
> > Thanks,
> > Lee
> ------------------
> There is no single matlab function that will calculate it, but you can
> make use of the geometrical theorem that the radius of a circumscribing
> circle of a triangle is equal to the product of its three sides divided by
> four times the triangle's area.
>
> a = sqrt((x1-x2)^2+(y1-y2)^2); % The three sides
> b = sqrt((x2-x3)^2+(y2-y3)^2);
> c = sqrt((x3-x1)^2+(y3-y1)^2);
> s = (a+b+c)/2;
> A = sqrt(s*(s-a)*(s-b)*(s-c)); % Area of triangle
> R = a*b*c/(4*A); % Radius of circumscribing circle
>
> (Remove "xyzzy" and ".invalid" to send me email.)
> Roger Stafford

I have a similar problem.
I need to calculate/approximate the radius of a path a vehicle is following. I have used the code provided by Roger Stafford which seems to work but I also need to separate between left and right hand corners. So the resulting cornering radius needs to be marked with a minus sign.
Any idea or code how to do that?

Subject: Function to calculate radius from three points

From: Roger Stafford

Date: 7 Apr, 2013 18:24:08

Message: 6 of 6

"Karl" wrote in message <kjrqod$huk$1@newscl01ah.mathworks.com>...
> ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford) wrote in message
> > There is no single matlab function that will calculate it, but you can
> > make use of the geometrical theorem that the radius of a circumscribing
> > circle of a triangle is equal to the product of its three sides divided by
> > four times the triangle's area.
> >
> > a = sqrt((x1-x2)^2+(y1-y2)^2); % The three sides
> > b = sqrt((x2-x3)^2+(y2-y3)^2);
> > c = sqrt((x3-x1)^2+(y3-y1)^2);
> > s = (a+b+c)/2;
> > A = sqrt(s*(s-a)*(s-b)*(s-c)); % Area of triangle
> > R = a*b*c/(4*A); % Radius of circumscribing circle
> >
> > Roger Stafford
>
> I have a similar problem.
> I need to calculate/approximate the radius of a path a vehicle is following. I have used the code provided by Roger Stafford which seems to work but I also need to separate between left and right hand corners. So the resulting cornering radius needs to be marked with a minus sign.
> Any idea or code how to do that?
- - - - - - - - - -
  To do that, use a formula which gives a "signed" area for the triangle containing the three points. If the order of travel is through (x1,y1), next through (x2,y2), and finally through (x3,y3) in that order, the formula would be

 A = 1/2*det([x1,x2,x3;y1,y2,y3;1,1,1]); % Signed area

This will be positive for a left turn and negative for a right turn. Its absolute value can be shown to be identically equal to the one I gave above for A.

Roger Stafford

Tags for this Thread

No tags are associated with 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