Re: [Jts-topo-suite-user] Triangulating polygons?
Brought to you by:
dr_jts
From: Martin D. <mtn...@te...> - 2010-04-24 21:40:53
|
Yes you are missing something obvious.... 8^) Use GeometricShapeFactory.setCentre, rather than setBase I just tried this in your code and it produces the angles you'd expect - interiorAngle starting from 0, increasing up to 2PI, and decreasing back down to 0. Ian, at some point can you post your Java code port of the Manocha C code for the Seidel algorithm? And I can't get the link to the extended C code for handling holes to work - did you manage to find that code? Martin Ian Turton wrote: > On Fri, Apr 23, 2010 at 10:51 PM, Michael Bedward > <mic...@gm...> wrote: > >> Thanks for the tip Martin. I'll try implementing the second idea. >> >> Ian, have you already tried the C code ? I'll defer looking at it >> until after having a go myself. >> > > I've made a start but generating monotone polygons is harder than it > looks - I'm having problems with angles - the algorithm calls for > determining if the interior angle is less than PI so I was using > Angle.interiorAngle(c1,c2,c3) but it never seems to return a value > > PI, so I never end up with any merge points. > > Am I missing something obvious? > > I tried out the following > > public void testAngle() { > GeometricShapeFactory gsf = new GeometricShapeFactory(); > final Coordinate center = new Coordinate(1,1); > gsf.setBase(center); > gsf.setSize(1); > gsf.setNumPoints(360); > Polygon circle = gsf.createCircle(); > Coordinate[] c = circle.getCoordinates(); > Coordinate start = circle.getExteriorRing().getStartPoint().getCoordinate(); > int i=0; > for(Coordinate cc:c) { > System.out.println(i); > i++; > System.out.println("interior "+Angle.interiorAngle(start, center, cc)); > System.out.println("orientatedBetween > "+Angle.angleBetweenOriented(start, center, cc)); > System.out.println("acute "+Angle.isAcute(start, center, cc)+" > "+Angle.isObtuse(start, center, cc)); > } > } > > and all the way around the circle I get acute angles and the two > angles are always the same. > > Ian > |