MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: DelaunayTriangulation[] output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83231] Re: DelaunayTriangulation[] output
  • From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
  • Date: Thu, 15 Nov 2007 05:45:50 -0500 (EST)
  • References: <fhegn1$m6p$1@smc.vnet.net>

Here is one way of doing approximately what you want based on the 
documentation for the Computational Geometry Package.

Set up the package and an example set of data.

<< ComputationalGeometry`
data2D={{4.4,14},{6.7,15.25},{6.9,12.8},{2.1,11.1},{9.5,14.9},{13.2,11.9},{10.3,12.3},{6.8,9.5},{3.3,7.7},{0.6,5.1},{5.3,2.4},{8.45,4.7},{11.5,9.6},{13.8,7.3},{12.9,3.1},{11,1.1}};
delval=DelaunayTriangulation[data2D];

Here is my quick and dirty extraction of triangles. I take each adjacency 
list and partition it into overlapping pairs, then prepend the reference 
node to form a triple, then sort the resulting triple (in preparation for 
the Union later), then flatten all these triples into a flat list of 
triples, then do a Union to eliminate common triples, leaving you with a 
list of triples that are the triangles that you wanted.

triangles=Flatten[Map[MapThread[(Prepend[#2,#1]//Sort)&,{Table[#[[1]],{Length[#[[2]]]}],Partition[#[[2]],2,1,{1,1}]}]&,delval],1]//Union

Compare the graphics in the following two outputs:

PlanarGraphPlot[data2D]
Graphics[GraphicsComplex[data2D,Line[triangles]]]

You see that the results are nearly the same except at the boundary. I hope 
this gets you near to what you wanted.

Steve Luttrell
West Malvern

"Dominick" <pd20012000 at yahoo.com> wrote in message 
news:fhegn1$m6p$1 at smc.vnet.net...
> Hi guys I was wondering if you could                      help me with a 
> couple of problems im having.                    I'm writing a program 
> that when given two images it creates a morph in between them.The 
> algorithm im implementing uses control points i choose on the image and 
> them triangulates the the images using those control points.I then use the 
> subsquent triangles to create a 1 to 1 correspondance between the 2 
> images. Im using the DelaunayTriangulation[] command  to do the 
> triangulation for me.Well my problem is the output of 
> DelaunayTriangulation. I need a triangle list ie;
>
>
>                           i  j k
>                           1  5 2
>                           2  3 7
>                           . . .
>
>
>       where i,j,k are the vertices of the triangle
>  but DelaunayTriangulation outputs an adjacency list ie
>
>
>
>      { {i,{points that are connected to i},..}
>
>
> I was wondering if anyone knew how to convert this list to the triangle 
> based list i need.If i get this figured out then 90%+ of the program is 
> done.I appreciate any help.
> 




  • Prev by Date: Re: packages/notation/errors
  • Next by Date: Help needed with new Export (v. 6)
  • Previous by thread: Re: DelaunayTriangulation[] output
  • Next by thread: Re: DelaunayTriangulation[] output