# How to determine whether a point is inside a closed region?

cooooldog shared this question 5 years ago

:smiley_cat:

I have two questions for the curve below,which is created via the code:

Curve[9sin(2t) + 5sin(3t), 9cos(2t) - 5cos(3t), t, 0, 6.28319] 1. how to fill the closed region by the curve with solid color? the normal operation failed as indicated in the figure;

2. Is there Geogebra built-in functions which can help determine whether an arbitrarily given point is inside the closed pentacle region or not since it is not a convex region? 1

1. how to fill the closed region by the curve with solid color? the normal operation failed as indicated in the figure;

I think you first have to find the coordinates of the five intersection points of the curve.

So it will be necessary to resolve x(t1)=x(t2) & y(t1) = y(t2).

Maybe with some trigonometric formulas.

I don't know if GeoGebra can bring some approximations. 1

Hi,

2. Is there Geogebra built-in functions which can help determine whether an arbitrarily given point is inside the closed pentacle region or not since it is not a convex region?

with

B=PointPlusProche[a, A]

b = Distance[(0, 0), A] ≤ Distance[(0, 0), B] = IsInRegion[A, a]

https://ggbm.at/1389267 1

1. how to fill the closed region by the curve with solid color? the normal operation failed as indicated in the figure;

with 2 curves...

https://ggbm.at/1389269 1

with

B=PointPlusProche[a, A]

b = Distance[(0, 0), A] ≤ Distance[(0, 0), B] = IsInRegion[A, a]

This method bring a false answer if B is inside one of the 5 branchs

and more near the central pentagon than the exterior curve of this branch.

See IsinRegionfalse figure.

We can also fill the central almost pentagon by calculate the coordinates of the intersection points.

By zooming it's easy to approximate those coordinates.

I find t1 =3.680316 and t2 = 3.859508

Then i draw the curve between t1 and t2,

and rotate it 72°, 4 times.

You can see that the curve is a little bit inside the exact regular pentagon,

so just draw it and fill it.

https://ggbm.at/1389277 1

In fact it's not necessary to solve an equation to find coordinates of the intersection points :

A(0,-5) it's one of those points !

But this solution is not really one because the regular pentagon is more large

than the central region of the curve.

https://ggbm.at/1389281 1

:smiley_cat:

Curve[9sin(2t) + 5sin(3t), 9cos(2t) - 5cos(3t), t, 0, 6.28319]

Can i ask you where do you find this equation ?

Cuz i think we can approach the exact regular pentagon as close as we want

by changing integers 9,5, 2 and 3.

It will be a funny way to construct the regular pentagon 1

Hi,

This method bring a false answer if B is inside one of the 5 branchs

and more near the central pentagon than the exterior curve of this branch.

:flushed: Yes , you right !

An other way, with intersect...

https://ggbm.at/1389285 1

Yes beautiful 1

hello

but the problem continues in axis of symmetry near the inside pentagon

why is the intersection of curve and ray undefined? there is a bug?

saludos  1

The exact region of curved pentagon is too hard to be defined in a parametric curve, so the problem may be solved by assuming linear the pentagon sides, i.e. y(M)= y(F)= 2, instead of 2.02254.

Cheers

https://ggbm.at/1389301  1

hello

but the problem continues in axis of symmetry near the inside pentagon

why is the intersection of curve and ray undefined? there is a bug?

saludos

Oh my god ! Incredible

I don't find any reason of this problem. A bug ? 1

How GeoGebra calculate the intersection of two curves ?

Because the problem clearly happened when the line is orthogonal to the tangent of the curve

at the intersection point.

I try with the regular trifolium, same. 1

How GeoGebra calculate the intersection of two curves ?

This this case numerically (as the curve is not a polynomial) so it can't guarantee to get all the intersection points 1

I found part of the solution : there's no intersection between the line and the curve

because O=(0,0) is on the line. But i don't know why this belonging cause that.

See figure AsurAxe : intersection sometimes doesn't exist

(i reduce T interval for problem simplification and cause elimination)

On figure AsurAxe+décentré : intersection is here

https://ggbm.at/1389317 1

in fact ther'es no intersection because O is on the half-line which cut the curve.

the intersection between the entire line (name e on figure AsurAxe) and the curve

exist on figure AsurAxe 1

J’ai ramené le problème à ce qui suit :

Sur la figure suivante, la courbe a est un cercle de centre (0,c) tracée de façon paramétrique.

B est un point quelconque du plan, C le point de a le plus proche de B.

Si c est différent de 0, l’autre intersection (E) de (DB) avec le cercle existe, quand on déplace B, la moitié du temps uniquement (pour un demi-cercle. Vous pouvez construire l’intersection avec l’autre demi-cercle sans problème. En fait tout se passe comme si il y avait non pas 1 courbe, mais 2).

Si c = 0 (c’est à dire quand la droite passe par (0,0)), cette intersection n’existe pas, pour la plupart des positions de B. Mais des fois elle apparaît furtivement.

Il n’y a pas ce problème avec un cercle tracé avec la commande Cercle.

https://ggbm.at/1389323 1

hello

to model the inside command for a point with an aprox polygon is easy

I did an applet in June of 2009 for a course of INTE (instituto nacional de tecnologias educativas del ministerio de educacion en España)

the course was absurdly eliminated off menu of INTE's courses

but you can acces to material in

my applet is at bottom of the page. you can translate the text with google.

then I wanted a similar method for parametric curve

the calculus is slow in my machine but it works well

and it is amazing (I think so)

test it please (points in special positions are interesting)

saludos

WARNING:

the PC may freeze and CPU can be heated

https://ggbm.at/1389327 1

I can't open your figure in the site /ite.educacion.es/

Does here in GeoGebraTube ?

You use a topology method ant the result is really great ! Thanks.

Is you definition of "degree" (integral of ((f(x) - x(A)) dg(x) - (g(x) - y(A)) df(x)) / ((f(x) - x(A))² + (g(x) - y(A))²)

between 0 and 2pi) means something else first in topology ?

Maybe it's also possible to calculate some others topologic indicators curve, as genre for example ?

In figure foro1, i see when A is (0,2)? Does exist a additional way to conclude that A is inside ?

Have a good day 1

I can't open your figure in the site /ite.educacion.es/

Does here in GeoGebraTube ?

because in 2009 we worked with java. can you open another applets changing the security options in JAVA? then you can do it also

saludos

PD: lo he bajado y te lo subo

note than the version in 2009 is very old

https://ggbm.at/1389329 1

I can't open your figure in the site /ite.educacion.es/

Does here in GeoGebraTube ?

You use a topology method ant the result is really great ! Thanks.

Is you definition of "degree" (integral of ((f(x) - x(A)) dg(x) - (g(x) - y(A)) df(x)) / ((f(x) - x(A))² + (g(x) - y(A))²)

between 0 and 2pi) means something else first in topology ?

Maybe it's also possible to calculate some others topologic indicators curve, as genre for example ?

In figure foro1, i see when A is (0,2)? Does exist a additional way to conclude that A is inside ?

Have a good day

what "A is inside" means? is not possible a path joining the point with a remote point or there is a sub_curve around the point? is the point in a laberynth inside or outside? both cases seems to me not possible actually for GG

Ah! integral of ((f(x) - x(A)) dg(x) - (g(x) - y(A)) df(x)) / ((f(x) - x(A))² + (g(x) - y(A))² is the sum of infinity signed angles from curve to point

saludos 1

hello

a completely new method. integral is eliminated by another angular calculus and the calculus is faster simpler

the degree of curve is more clear. the points on curve is not supported but if you want it no problem

new example

change f and g for older examples

saludos

PD: if you like the course of inte you can donwload the applet changing html in link by ggb. example

you want see http://www.ite.educacion.es/formacion/materiales/123/cd/html/circ_p.html and java avoids you

podriamos enviar peticiones al [size=150]INTE [/size]para que recuperen los [size=150]cursos [/size]de [size=200]GeoGebra[/size]

saludos

https://ggbm.at/1389333 1

hello

a completely new method. integral is eliminated by another angular calculus and the calculus is faster simpler

the degree of curve is more clear. the points on curve is not supported but if you want it no problem

new example

change f and g for older examples

saludos

I test it and other too and it's really great.

Calculus faster simpler for this one ? Maybe not if you don't know the formula use in code :

sgn((u - A) ⊗ v), u, a(raices), v, da(raices)

where raices are Racines[p]

and p = atan2(g(x) - y(A),f(x) - x(A))...

Beautiful that it's possible to replace a integral by a finite sum extended to some roots.

(it's always possible?)

For that moment i translate the text of your first area polygon figure (thanks for the upload!)

If GeoGebra give a false polygone area, does exist a way to have the true ?

(maybe by changing weighted coefficient of the sum ?)

It's too bad that Patrick's method for the pentagram curve to decide even if or not a point is inside fail,

because it should work! GeoGebra programs for computate roots must be more effective.

In that point of view, the figure in my last post reveal how large is the problem :cry: 1

Hello,

@ mathmagic :

very interesting! Bravo and thank you. 1

hello

a completely new method. integral is eliminated by another angular calculus and the calculus is faster simpler

the degree of curve is more clear. the points on curve is not supported but if you want it no problem

new example

change f and g for older examples

saludos

I test it and other too and it's really great.

Calculus faster simpler for this one ? Maybe not if you don't know the formula use in code :

sgn((u - A) ⊗ v), u, a(raices), v, da(raices)

where raices are Racines[p]

and p = atan2(g(x) - y(A),f(x) - x(A))...

Beautiful that it's possible to replace a integral by a finite sum extended to some roots.

(it's always possible?)

For that moment i translate the text of your first area polygon figure (thanks for the upload!)

If GeoGebra give a false polygone area, does exist a way to have the true ?

(maybe by changing weighted coefficient of the sum ?)

It's too bad that Patrick's method for the pentagram curve to decide even if or not a point is inside fail,

because it should work! GeoGebra programs for computate roots must be more effective.

In that point of view, the figure in my last post reveal how large is the problem :cry:

si tu quieres puedo darte el proceso mental seguido para el calculo inicial y el cambio producido en el proceso

basicamente es que la integral inicial era la integral de una derivada

pero la explicacion te la puedo dar en español

mi ingles no llega a tanto

saludos 1

si tu quieres puedo darte el proceso mental seguido para el calculo inicial y el cambio producido en el proceso

basicamente es que la integral inicial era la integral de una derivada

pero la explicacion te la puedo dar en español

mi ingles no llega a tanto

Your explanation isnt too long (less than two pages) ? If yes, i want it.

I have a solution for Patrick’s method.

Let a : x = f(t) & y = g(t) the curve.

We first find the roots of : df(t) (x(A) - f(t)) + dg(t) (y(A) - g(t)) = 0.

Those solutions T correspond to the points a(T) of the curve where the normal passes through the point A.

Then it’s easy to have the point of the curve which is the closest to A (name B).

After, by solving an other classic equation, you can have all the intersection of the curve with the normal at B (*).

For finish, some of those points M must be eliminate : when B is on [AM] (with for example a geometric logic code).

(*) those two equations must be simplified before being input, otherwise GeoGebra partially solved them. Maybe that’s why some other figures fails.

https://ggbm.at/1389335 1

Interesting approach, the above one.

As shown below, I've tried to replicate it in a generalized form and have no idea why list3 produces only one output and min-value is undefined.

Please, Patrick/Rousseau (co-authors of the sheet), could you amend mine appropriately?

Thx&Cheers

https://ggbm.at/1389351  1

Hi,

why list3 produces only one output and min-value is undefined.

because Sequence get a list, no use {....} in {Sequence[...]}

same problem with Zip[...]

...

https://ggbm.at/1389353 1

So precious drift, Patrick! Now I can proceed to complete the sheet,

Thank you very much and cheers 1

I still need help.

The definition of p(x) seems in accordance with the original sheet, nevertheless errors erupt, as show. Thx in advance

https://ggbm.at/1389357  1

I'm afraid it's impossible to generalize.

Look graphs function of h and p.

When you move A, GeoGebra can't find all roots of those functions.

I don't know if is the reason of your last figure error, but it's certain that this failure prevent to finish.

If you want to complete the figure you need to simplified the expression of h and p

before input them in GeoGebra.

It's possible with the formula sin(a + b) = sin(a)cos(b) + sin(b)cos(a). 1

Yes, Rousseau, the att'd screenshot of comparison confirms the different behaviour of both sheets: yours and mine.

Unfortunately the loss of generalization strongly reduces the superb method of investigation: point inside/outside the given contour of a parametric curve.

Thanks a lot for your cooperation 