From: Lucas campos on
Hi Everybody,

Could anyone tell me how to find the tangent between a point and a polygon?

Thanks

Lucas
From: Roger Stafford on
"Lucas campos" <campos.lucas(a)gmail.com> wrote in message <hs7tnq$lrl$1(a)fred.mathworks.com>...
> Hi Everybody,
>
> Could anyone tell me how to find the tangent between a point and a polygon?
>
> Thanks
>
> Lucas
- - - - - - -
The notion of a line being tangent to a polygon is alien to the very nature of polygons. You force me to speculate about what you really must mean.

My guess is that you want to find a line which runs through a given point and is tangent, ideally to a given perfectly smooth curve, except for the fact that the curve is being approximated by a discrete set of points and line segments connecting them and therefore forming a polygon. Do I guess correctly?

Provided your curve has a well-defined equation y = f(x) where f(x) can be differentiated, your line can be determined as the solution to an equation:

(f(x)-y0)/(x-x0) = f'(x) ,

where (x0,y0) is the given point, where (x,f(x)) is the point of tangency on the curve y = f(x), and where f'(x) is the derivative of f(x) with respect to x. When you find a solution x to this equation, you have found a point of tangency for a line from the point.

How you solve the equation depends much on the nature of f(x).

If you have no such equation y = f(x), then it becomes a matter of finding three consecutive points (x1,y1), (x2,y2), (x3,y3), on the polygon for which

(y1-y0)/(x1-x0)-((y2-y0)/(x2-x0)

and

(y2-y0)/(x2-x0)-((y3-y0)/(x3-x0)

are of opposite sign. Where this happens you can consider a line from (x0,y0) as approximately "tangent" at the point (x2,y2).

Roger Stafford
From: TideMan on
On May 10, 4:04 pm, "Roger Stafford"
<ellieandrogerxy...(a)mindspring.com.invalid> wrote:
> "Lucas campos" <campos.lu...(a)gmail.com> wrote in message <hs7tnq$lr...(a)fred.mathworks.com>...
> > Hi Everybody,
>
> > Could anyone tell me how to find the  tangent between a point and a polygon?
>
> > Thanks
>
> > Lucas
>
> - - - - - - -
>   The notion of a line being tangent to a polygon is alien to the very nature of polygons.  You force me to speculate about what you really must mean.
>
>   My guess is that you want to find a line which runs through a given point and is tangent, ideally to a given perfectly smooth curve, except for the fact that the curve is being approximated by a discrete set of points and line segments connecting them and therefore forming a polygon.  Do I guess correctly?
>
>   Provided your curve has a well-defined equation y = f(x) where f(x) can be differentiated, your line can be determined as the solution to an equation:
>
>  (f(x)-y0)/(x-x0) = f'(x) ,
>
> where (x0,y0) is the given point, where (x,f(x)) is the point of tangency on the curve y = f(x), and where f'(x) is the derivative of f(x) with respect to x.  When you find a solution x to this equation, you have found a point of tangency for a line from the point.
>
>   How you solve the equation depends much on the nature of f(x).
>
>   If you have no such equation y = f(x), then it becomes a matter of finding three consecutive points (x1,y1), (x2,y2), (x3,y3), on the polygon for which
>
>  (y1-y0)/(x1-x0)-((y2-y0)/(x2-x0)
>
> and
>
>  (y2-y0)/(x2-x0)-((y3-y0)/(x3-x0)
>
> are of opposite sign.  Where this happens you can consider a line from (x0,y0) as approximately "tangent" at the point (x2,y2).
>
> Roger Stafford

Alternatively, Roger, I speculate that the OP means normal, not
tangent.
That's the only thing that makes sense to me.
From: Roger Stafford on
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hs80k6$oh6$1(a)fred.mathworks.com>...
> .........
> If you have no such equation y = f(x), then it becomes a matter of finding three consecutive points (x1,y1), (x2,y2), (x3,y3), on the polygon for which
>
> (y1-y0)/(x1-x0)-((y2-y0)/(x2-x0)
>
> and
>
> (y2-y0)/(x2-x0)-((y3-y0)/(x3-x0)
>
> are of opposite sign. Where this happens you can consider a line from (x0,y0) as approximately "tangent" at the point (x2,y2).
>
> Roger Stafford

Added note: I would prefer to have written those last two expressions in the more robust form:

(y1-y0)*(x2-x0)-(y2-y0)*(x1-x0)

and

(y2-y0)*(x3-x0)-(y3-y0)*(x2-x0)

should be of opposite signs for (x2,y2) to be a point of "tangency".

Roger Stafford