Given a set of xyz points, I want to find clusters of points that have the smallest variation in the z value. Basically how to find the flattest area of a collection of points.

# How to find the flattest area of a poly surface in rhino?

**RadovanG**(Radovan Grmusa) #2

The question is how flat “flattest area” has to be?

Some other condition is necessary to determine which points will satisfy"flatest area" / “smallest variation” condition.

For example minimum number of points to be included in resulting set or some other condtion…

Lets say you have * n* values of z-coordinates, stored in and arrazy z, so

**is z-coordinate for**

*z[i]***.**

*point[i]*Let

**be any number of points, then you ca calculate**

*m***for such set of points.**

*variance*For different set of

**points you will get different value of variance, lowest value means smallers variation.**

*m*You can iterate this computation for different

**m**(m => 2 to n ) and you will find for evrey

**set of point vith minimum variance. Lowes variance will be = 0 if you have at least 2 points with same**

*m**value.*

**z**Efficient algorithm can be written if list of points is sorted with ascending value of

**coordinate.**

*z*I hope that this helps…

R