Thread Subject: How to find the point of intersection from two 2d curves?

Subject: How to find the point of intersection from two 2d curves?

From: James

Date: 1 Apr, 2009 22:35:03

Message: 1 of 5

here is my equations for my curves, they are actually arcs of circles.

x3=([-1:0.01:1]*8)+1;
ypos3=(((8^2)-((x3-1).^2)).^0.5);

x2=([-1:0.01:1]*5)+8.5;
ypos2=((5^2)-((x2-8.5).^2)).^0.5;

I want to find the coordinates where they cross over using a code rather than just looking at my graph.

Looking at the graph...
plot(x2,ypos2,'r')
plot(x3,ypos3,'g')
the coordinates are about (7.35, 4.86)

any ideas what to do?

Subject: How to find the point of intersection from two 2d curves?

From: Matt Fig

Date: 1 Apr, 2009 23:09:01

Message: 2 of 5

Since you have the equations, you could use fzero.

f1 = @(x) (((8^2)-((x-1).^2)).^0.5)
f2 = @(x) ((5^2)-((x-8.5).^2)).^0.5;

pt = fzero(@(x) f1(x)-f2(x),7) % The x-coord
coord = [pt,f1(pt)] % The coordinates.

Subject: How to find the point of intersection from two 2d curves?

From: Walter Roberson

Date: 2 Apr, 2009 01:49:21

Message: 3 of 5

James wrote:
> here is my equations for my curves, they are actually arcs of circles.
>
> x3=([-1:0.01:1]*8)+1;
> ypos3=(((8^2)-((x3-1).^2)).^0.5);
>
> x2=([-1:0.01:1]*5)+8.5;
> ypos2=((5^2)-((x2-8.5).^2)).^0.5;
>
> I want to find the coordinates where they cross over using a code rather than just looking at my graph.
>
> Looking at the graph...
> plot(x2,ypos2,'r')
> plot(x3,ypos3,'g')
> the coordinates are about (7.35, 4.86)
>
> any ideas what to do?

Putting it through the symbolic solver and using 17/2 instead of 8.5, and using
sqrt() instead of raising to the decimal power 0.5, the exact intersection
is at x = 147/20 which is 7.35 . Substituting back into the first formula,
the y coordinateis sqrt(9471)/20, which is about 4.865953144.

Subject: How to find the point of intersection from two 2d curves?

From: Matt Fig

Date: 2 Apr, 2009 03:09:01

Message: 4 of 5

Walter Roberson <roberson@hushmail.com> wrote in message
> Putting it through the symbolic solver and using 17/2 instead of 8.5, and using
> sqrt() instead of raising to the decimal power 0.5, the exact intersection
> is at x = 147/20 which is 7.35 . Substituting back into the first formula,
> the y coordinateis sqrt(9471)/20, which is about 4.865953144.


Funny, that is the same thing I got using fzero, as shown above.

Subject: How to find the point of intersection from two 2d curves?

From: Walter Roberson

Date: 2 Apr, 2009 15:26:29

Message: 5 of 5

Matt Fig wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message
>> Putting it through the symbolic solver and using 17/2 instead of 8.5, and using
>> sqrt() instead of raising to the decimal power 0.5, the exact intersection
>> is at x = 147/20 which is 7.35 . Substituting back into the first formula,
>> the y coordinateis sqrt(9471)/20, which is about 4.865953144.
 
> Funny, that is the same thing I got using fzero, as shown above.

Using fzero, you got an x that was 7.35 to within the search
tolerance; using the symbolic solver showed the x was _exactly_ 7.35 .
No concern about "suppose we'd had quadruple precision arithmetic,
how would the result change" and so on.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
fzero Matt Fig 1 Apr, 2009 20:24:17
line James 1 Apr, 2009 18:40:20
intersection James 1 Apr, 2009 18:40:20
curve James 1 Apr, 2009 18:40:20
of James 1 Apr, 2009 18:40:20
cross James 1 Apr, 2009 18:40:20
interp1 James 1 Apr, 2009 18:40:20
point James 1 Apr, 2009 18:40:20
rssFeed for this Thread

Contact us at files@mathworks.com