Point/ Circle/ Segment

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Point/ Circle/ Segment

Emerson Carride
In CGAL has a function that returns if a given point is inside or outside or in boundary of a circle.

I want to know if CGAL has a function that returns if a given segment is tangent to a circle or divided the circle into two parts?




--
Emerson Amade Carride
Matemática Aplicada e Computação Científica
Instituto de Ciências Matemáticas e Computação
USP - São Carlos
tel: (16) 3411 0877; (11) 4538 3315 ; cel: (11) 71289888
Reply | Threaded
Open this post in threaded view
|

Re: Point/ Circle/ Segment

Pedro Machado Manhães de Castro
Hi,

The answer is no.

However:

You could do that by:

Check whether the supporting line of your segment and the circle intersect (with do_intersect). If it does not intersect, then the segment is completely outside or inside the circle (if it does interest you, you can find which of those two cases are applied by checking whether one end point is inside the circle or not). Otherwise, you check whether the squared_distance between the center and the supporting line is equal to the squared_radius of the circle or not. If yes, then you project the center onto the supporting line of the segment and check if the segment contains that point (with Has_on_2) (I am assuming that a 'tangent segment' is the one such that its supporting line is tangent to the circle + the segment intersects the circle). And now, if the distance is not equal to the radius, check whether both end points of the segment are outside/on the circle or not (so you are able to decide whether it divides or not the circle).

Search the manual index for Has_on_2, Do_intersect_2, Has_on_bounded_side_2, Intersect_2 and squared_distance.

Cheers,
Pedro Machado

On Wed, Nov 12, 2008 at 8:22 PM, Emerson Carride <[hidden email]> wrote:
In CGAL has a function that returns if a given point is inside or outside or in boundary of a circle.

I want to know if CGAL has a function that returns if a given segment is tangent to a circle or divided the circle into two parts?




--
Emerson Amade Carride
Matemática Aplicada e Computação Científica
Instituto de Ciências Matemáticas e Computação
USP - São Carlos
tel: (16) 3411 0877; (11) 4538 3315 ; cel: (11) 71289888

Reply | Threaded
Open this post in threaded view
|

Re: Point/ Circle/ Segment

Sylvain Pion
Administrator
Pedro Machado Manhães de Castro a écrit :
> The answer is no.

No, the answer to the first question is yes.  RTFM:
http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Kernel_23_ref/Class_Circle_2.html

As for the relative position of a segment wrt a circle, there are more cases to
distinguish, and you may need to do something along the lines of what Pedro suggests.
See squared_distance(), between the center and the segment and/or the endpoints
or the supporting line.
http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Kernel_23_ref/Function_squared_distance.html

> However:
>
> You could do that by:
>
> Check whether the supporting line of your segment and the circle
> intersect (with do_intersect). If it does not intersect, then the
> segment is completely outside or inside the circle (if it does interest
> you, you can find which of those two cases are applied by checking
> whether one end point is inside the circle or not). Otherwise, you check
> whether the squared_distance between the center and the supporting line
> is equal to the squared_radius of the circle or not. If yes, then you
> project the center onto the supporting line of the segment and check if
> the segment contains that point (with Has_on_2) (I am assuming that a
> 'tangent segment' is the one such that its supporting line is tangent to
> the circle + the segment intersects the circle). And now, if the
> distance is not equal to the radius, check whether both end points of
> the segment are outside/on the circle or not (so you are able to decide
> whether it divides or not the circle).
>
> Search the manual index for Has_on_2, Do_intersect_2,
> Has_on_bounded_side_2, Intersect_2 and squared_distance.
>
> Cheers,
> Pedro Machado
>
> On Wed, Nov 12, 2008 at 8:22 PM, Emerson Carride <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     In CGAL has a function that returns if a given point is inside or
>     outside or in boundary of a circle.
>
>     I want to know if CGAL has a function that returns if a given
>     segment is tangent to a circle or divided the circle into two parts?
>
>
>
>
>     --
>     Emerson Amade Carride
>     Matemática Aplicada e Computação Científica
>     Instituto de Ciências Matemáticas e Computação
>     USP - São Carlos
>     tel: (16) 3411 0877; (11) 4538 3315 ; cel: (11) 71289888
>
>


--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Point/ Circle/ Segment

Pedro Machado Manhães de Castro

No, the answer to the first question is yes.  RTFM:
http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Kernel_23_ref/Class_Circle_2.html

I thought that he asked only 1 question:

>   I want to know if CGAL has a function that returns if a given
>   segment is tangent to a circle or divided the circle into two parts?

and declared that:

>   In CGAL has a function that returns if a given point is inside or
>   outside or in boundary of a circle.

Does I misunderstood?

Pedro Machado



As for the relative position of a segment wrt a circle, there are more cases to
distinguish, and you may need to do something along the lines of what Pedro suggests.
See squared_distance(), between the center and the segment and/or the endpoints
or the supporting line.
http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Kernel_23_ref/Function_squared_distance.html

However:

You could do that by:

Check whether the supporting line of your segment and the circle intersect (with do_intersect). If it does not intersect, then the segment is completely outside or inside the circle (if it does interest you, you can find which of those two cases are applied by checking whether one end point is inside the circle or not). Otherwise, you check whether the squared_distance between the center and the supporting line is equal to the squared_radius of the circle or not. If yes, then you project the center onto the supporting line of the segment and check if the segment contains that point (with Has_on_2) (I am assuming that a 'tangent segment' is the one such that its supporting line is tangent to the circle + the segment intersects the circle). And now, if the distance is not equal to the radius, check whether both end points of the segment are outside/on the circle or not (so you are able to decide whether it divides or not the circle).

Search the manual index for Has_on_2, Do_intersect_2, Has_on_bounded_side_2, Intersect_2 and squared_distance.

Cheers,
Pedro Machado

On Wed, Nov 12, 2008 at 8:22 PM, Emerson Carride <[hidden email] <mailto:[hidden email]>> wrote:

   In CGAL has a function that returns if a given point is inside or
   outside or in boundary of a circle.

   I want to know if CGAL has a function that returns if a given
   segment is tangent to a circle or divided the circle into two parts?




   --    Emerson Amade Carride
   Matemática Aplicada e Computação Científica
   Instituto de Ciências Matemáticas e Computação
   USP - São Carlos
   tel: (16) 3411 0877; (11) 4538 3315 ; cel: (11) 71289888



--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss