# Count the number of points of a polygon

Actually, this is a continuation of a previous post entitled "Count the number of corners of a polygon". Although I managed to count the number of points (i.e. saying corners) of each polygon the problem is that even a polygon may be approximately rectangular actually has more than four points because of the digitization process i.e. sometimes an approximate straight line consists of more than 2 points. How can I ignore the intermediate additional points that are not really needed for my purpose? Thanks.

• Did you try casting the polygon as an IPolycurve and calling Generalize? – Kirk Kuykendall Jun 9 '11 at 13:12
• You could check the angles formed at each point; if greater than a certain threshold, don't count that point. – Michael Todd Jun 9 '11 at 16:44
• Actually, I have already thought to do that but my new problem is that some angles are measured based on the exterior turn and not the interior of the polygon. For example, while actually an angle is 90 degrees I got 270 degrees. The thing is that I dont not know why this happens and which angles for each polygon have this mistake. I try to compare some polygons using a CAD system. Do you have an idea about this problem? – Demetris Jun 9 '11 at 19:13
• @Demetris, 90 degrees and 270 degrees both look the same, it depends if you measure clockwise or counter-clockwise. For the threshold you'll want to compare to 180 degrees to determine if you want to ignore. `bool ignore = Math.abs(angle - 180) > threshold` – Chris Aug 25 '11 at 12:16