# Normal to an edge of a polygon, from a point inside the polygon

Suppose that I have a closed boundary that is represented by n points. Using these n points I construct a polygon with n sides. I have a point P(x,y) that lays inside the polygon.

I want to draw the normal from Point P to the edge/edges of polygon. Depending on the shape of the polygon, I can have multiple edges to which I can draw normals from point P. How shall I select the subset of edges (from all edges of polygon) that can be chosen to draw normal from point P?

• Quick clarification: by "draw normal from Point P to edge/edges of polygon", what you mean is to draw a normal from the point (let's call it S) in the edge that is the closest possible from P? – MAnd Feb 27 '16 at 18:09
• Clarification for comment asked by MAnd: First, I would like to know how many edges of polygon can be selected such that I can draw a normal from point P (inside of polygon) to the edge of polygon. Let us suppose that I get m such edges (out of total n edges of polygon). Out of these m edges, I will select the one edge that is nearest to point P. – abc Feb 27 '16 at 18:44

I construct a polygon with n sides. I have a point P(x,y) that is inside the polygon. I want to draw normal from Point P to edge/edges of polygon

For each edge:

1) finding a normal for a line-segment is is trivial.

2) but in your case, you also want to identify the point S that lays in that edge and is at the closest distance from P, so you can "put" the normal beginning at S and passing trough P. It means that when you find S, the line segment SP that goes from S to P coincides with the normal you are interested in.

How shall I select subset of edges (from all edges of polygon) that can be chosen to draw normal from point P

3) for each edge, you have to do the following. When you found the point S in the edge that is the closest from P, you made yourself a new line-segment available, which is SP.

4) so, test whether or not the line-segment SP intersects with any of the other edges (i.e. a simple line-segment vs. line-segment intersection test). If yes, then you know that the edge where S belong to, is not one you can chose a normal from that does not crosses other edges before hitting P or passing trough the exterior of the polygon.