There’s faster ways to do it, but you could always just compare each vertex to every other vertex at first. From the description of your app, it sounds unlikely that the complexity will cause any issues.

What in particular are you having trouble with? Do you know how to calculate distance? What language are you using?

Hi friends,

I am trying to write an program for drawing 2D polygons(convex or non-convex)) with mouse.what exactly i am doing is first i will draw an triangle with 3 assigned vertices and by one mouse click get one vertex ,then by finding nearest two vertices of previous triangle i want to add new triangle. I am not getting idea to find nearest vertices .Please can anyone help ?