Posted 21 September 2009 - 04:40 AM
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 ?
Posted 21 September 2009 - 05:15 AM
What in particular are you having trouble with? Do you know how to calculate distance? What language are you using?
Posted 22 September 2009 - 05:12 PM
What if you clicked inside a triangle ? , finding the nearest vertices ??
this doesn't make sense unless you give a ref system , nearest to what ? your current point ? this is a large topic , normally you would use a kdtree to see which couple of point is nearest to another , i think you are overcomplcating the problem.
I would do like this, click on a point, you enter in a subroutine where the program expects to click on another screen coordinat, once you click it , repeat unti the last point is connected to the first within a range tollerance, before accepting the point i would check for self intersecting lines.
Posted 23 September 2009 - 03:30 AM
Of course, the user could enter a complex (self intersecting) polygon, but what you do with that is up to you and your application.
Posted 27 September 2009 - 04:17 PM
First Click on point(save index )
----Points indexed----(by connection)
then lookup the points location(x,y)..
if the polygon is growing as attached to a preexisting side, use relative distance to side midpoint, if not ignore,
treat the distacne pClick/(pMidpoint), pMouse as radius for the circumscribed circle, or inscribed which ever you prefer, refresh to screen the resulting polygons.
(i'd post code but that is not my intelectual property anymore..this bit is safe however)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users