### Tags: article, curves, gmxnospam, higor, intersection, itgt, ltpan, matlab, point, programming, todaysummary, wrotegt

# find intersection point between two curves

On Programmer » Matlab

5,372 words with 4 Comments; publish: Fri, 09 May 2008 23:57:00 GMT; (20078.13, « »)

In article <pan.2006.10.02.10.25.50.736681.matlab.todaysummary.com.gmxNOSPAM.it>,

higor.matlab.todaysummary.com.gmxNOSPAM.it wrote:

> Hi,

> i have 2 curves (in polar coordinates), the first is:

> thea=-rho*k+q

> where k and q are constant

> and the second is in parametric form:

> t=[pi/2:3/2*pi]

> rho=n/pi*cos(t).*t

> theta=-pi+3/4*sin(t).*sin(t/2).^12

> i put this on a system substituting rho of the second equation in the

> first and then theta of the second in the first so i have an equation in t

> like this:

> -n/pi*cos(t)*t*k+q+pi-3/4*sin(t)*sin(t/2)^12=0

> i created a Anonymous Function in this way:

> myfunc=.matlab.todaysummary.com.(t)(-n/pi*cos(t)*t*k+q+pi-3/4*sin(t)*sin(t/2)^12)

> and solved it with

> fzero(myfunc,temp)

> with temp between pi/2 and 3/2*pi but the value returned by fzero bigger

> then times 2*pi, and if i substitute the returned value on

> rho=n/pi*cos(t).*t i got a rho that don't match with the function plotted.

> Any ideas?

> Tanks

> Igor

--

Just entering a single scalar 'temp' which lies between pi/2 and 3/2*pi

doesn't guarantee that 'fzero' will only search there. To do that, you

must enter a two-element vector for 'temp' as [pi/2,3/2*pi].

Even so, based my observation of the plot of your parametric curve and

depending on the values of 'n', 'k', and 'q', 'fzero' could find any one

of up to four solutions or none at all for your equation. You might not

get the one you want.

Note that whatever solution you get will have a negative value for 'rho'

if 'n' is positive because cos(t) is negative in your range of 't'.

Roger Stafford

*http://matlab.todaysummary.com/q_matlab_17817.html*

All Comments

Leave a comment...

- 4 Comments
- On Mon, 02 Oct 2006 19:44:39 +0000, Roger Stafford wrote:
> In article <pan.2006.10.02.10.25.50.736681.matlab.todaysummary.com.gmxNOSPAM.it>,

> higor.matlab.todaysummary.com.gmxNOSPAM.it wrote:

>

> --

> Just entering a single scalar 'temp' which lies between pi/2 and 3/2*pi

> doesn't guarantee that 'fzero' will only search there. To do that, you

> must enter a two-element vector for 'temp' as [pi/2,3/2*pi].

> Even so, based my observation of the plot of your parametric curve and

> depending on the values of 'n', 'k', and 'q', 'fzero' could find any one

> of up to four solutions or none at all for your equation. You might not

> get the one you want.

> Note that whatever solution you get will have a negative value for 'rho'

> if 'n' is positive because cos(t) is negative in your range of 't'.

> Roger Stafford

Tanks for the reply,

i also tried with [pi/2,3/2*pi] but i got this error:

fzero(myfunc,[pi/2,3/2*pi])

? Error using ==> fzero

The function values at the interval endpoints must differ in sign.

the value for 'k', 'q' and 'n' that i used are:

k=w/vm (where w=2.7*10^-6 and vs=5*10^-4)

q=pi/4

n=150

so resulting function are:

myfunc=.matlab.todaysummary.com.(t)(-n/pi*cos(t)*t*w/vm+pi/4+pi-3/4*sin(t)*sin(t/2)^12);

i know that it can give me 0 ore more solution for 't', i want all 't'

where it is between pi/2 and 3/2*pi. there are another way to do this?

Tanks

Igor

#1; Fri, 09 May 2008 23:58:00 GMT

- On Mon, 02 Oct 2006 19:44:39 +0000, Roger Stafford wrote:
- On Tue, 03 Oct 2006 10:12:24 +0200, higor wrote:
> On Mon, 02 Oct 2006 19:44:39 +0000, Roger Stafford wrote:

>

> Tanks for the reply,

> i also tried with [pi/2,3/2*pi] but i got this error:

> fzero(myfunc,[pi/2,3/2*pi])

> ? Error using ==> fzero

> The function values at the interval endpoints must differ in sign.

> the value for 'k', 'q' and 'n' that i used are:

> k=w/vm (where w=2.7*10^-6 and vs=5*10^-4)

> q=pi/4

> n=150

> so resulting function are:

> myfunc=.matlab.todaysummary.com.(t)(-n/pi*cos(t)*t*w/vm+pi/4+pi-3/4*sin(t)*sin(t/2)^12);

> i know that it can give me 0 ore more solution for 't', i want all 't'

> where it is between pi/2 and 3/2*pi. there are another way to do this?

> Tanks

> Igor

Hum... i tried to plot this function with ezplot and it result always

positive and never equal to zero... i think there are something wrong...

#2; Fri, 09 May 2008 23:59:00 GMT

- On Tue, 03 Oct 2006 10:12:24 +0200, higor wrote:
- take a look at
<http://www.geometrictools.com/Documentation.html>

maybe you find your answer

#3; Sat, 10 May 2008 00:00:00 GMT

- take a look at
- On Tue, 03 Oct 2006 05:01:50 -0400, mut ante wrote:
> take a look at

> <http://www.geometrictools.com/Documentation.html>

> maybe you find your answer

I found the mismatch, it was in the curve definition, now there are:

thea=-rho*k+q

t=[pi/2:3/2*pi]

rho=-n/pi*cos(t).*t

theta=3/4*sin(t).*sin(t/2).^12

so the intersection result:

myfunc=.matlab.todaysummary.com.(t)(n/pi*cos(t)*t*w/vm+pi/8-3/4*sin(t)*sin(t/2)^12)

and the fzero seams to find the right 't'.

Tnaks .matlab.todaysummary.com. all

Igor

#4; Sat, 10 May 2008 00:01:00 GMT

- On Tue, 03 Oct 2006 05:01:50 -0400, mut ante wrote: