Re: set manipulation
- To: mathgroup@smc.vnet.net
- Subject: [mg10831] Re: [mg10803] set manipulation
- From: Wouter Meeussen <w.meeussen.vdmcc@vandemoortele.be>
- Date: Tue, 10 Feb 1998 21:01:43 -0500
hi, try : In[1]:= 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}}; In[2]:=<<DiscreteMath`ComputationalGeometry` In[3]:=delval = DelaunayTriangulation[data2D]; make lists {{z[1,2],z[1,5],...},,,} with a dummy function z: In[9]:=o1=Apply[Thread[z[#1,#2]]&,delval,1]; now change indices to point coordinates : In[14]:=o2=o1/.z[u_ ,v_ ]:>w[data2D[[u]],data2D[[v]] ]; now replace dummy fiunction w by your angle formula, either ArcTan[x/y] ... In[15]:=o3=o2/.w[{x1_,y1_},{x2_,y2_}]:>ArcTan[(y2-y1)/(x2-x1)]; ... or ArcTan[x,y] , check the help file! In[16]:=o4=o2/.w[{x1_,y1_},{x2_,y2_}]:>ArcTan[(x2-x1),(y2-y1)]; if you want averages, add'm & count'm: In[17]:=o5=((Plus@@#)/Length[#])&/@ o4; finally, line'm up for presentation : In[18]:=o6 = Transpose[{Range[Length[o5]],o5}] Out[18]= {{1, -0.730339}, {2, -1.41916}, {3, 0.0795703}, {4, -0.426948}, {5, -0.349634}, {6, 0.454106}, {7, 0.221677}, {8, 0.190618}, {9, -0.345478}, {10, 0.523639}, {11, 1.23956}, {12, 0.310264}, {13, -0.621994}, {14, -0.103605}, {15, 0.608526}, {16, 1.97183}} have fun too ! wouter. At 00:58 05.02.98 -0500, Nilay Saha wrote: >Hello everyone, > I have a problem with data set manipulation. I have a data set; >data2D={{1.3,2.4},{1.4,5.6},{ ,},{ ,} }} ><<DiscreteMath`ComputationalGeometry` delval=DelaunayTriangulation. > > >The set delval gives the nearest neighbour of each of the data2D >points.Thus delval may look like: > >delval={{1,{2,5,6}}, > {2,{3,6,4}}, > {3,{2,4 1}}, > }} >In the set delval 1=ist point in data2D (i.e in above eg. {1.3,2.4}) > 2=2nd point > 3=3rd Point > and so on. >Thus 1st point has it's nearest neighbour as 2nd, 5th, 6th points. > > >Now I have to calculate the angle of the lines joining point 1 with it's >nearest neighbour, with the x-axis=> > >angle=TanInverse[y(2)-y(1)/(x(2)-x(1))], where for sake of explanation >point1={x(1),y(1)}, point2={x(2),y(2)} and so on for points 5,6. > This should be done for all the points of data2D. > > >Then I need to add the angles corresponding to each point and then find >the average . > So If anyone who could give a slight hint of how this sort of data >manipulation can be done , I would be extremely grateful , Thnking you, > >Yours Sincerely, >Nilay Saha >Kamerlingh Onnes Lab, >2300RA Leiden >Postbus: 9506, >The Netherlands. >Phone: >(0031)71 5275476. > > NV Vandemoortele Coordination Center Oils & Fats Applied Research Prins Albertlaan 79 Postbus 40 B-8870 Izegem (Belgium) Tel: +/32/51/33 21 11 Fax: +/32/51/33 21 75 vdmcc@vandemoortele.be