> > 6!:2 'e =. (i.1+_1{0{t) e. ~. 0{t' NB. which points are used (and which > > ones > aren't) > > Why do you care about points which are not used in triangles?
Good point. The motivation was to prevent inconsistencies with other things that are derived from the same input data. But I will reconsider it. > In other words, rather than working with xyz directly, I think I would > instead use: > XYZ=: xyz #~ (i.#xyz) e.~.,tri > TRI=: tri { XYZ i. xyz > I do not know how long this would take for your dataset, It is certainly affordable: 6!:2 'XYZ=: xyz #~ (i.#xyz) e.~.,tri' 0.144449 6!:2 'TRI=: tri { XYZ i. xyz' 7.32666 $xyz 1093414 3 $XYZ 1088670 3 > > mkstar >3{t > > 14660 14657 14659 40048 14663 7898 25668 40141 14660 > > mkstar >4{t > > 25669 34100 25668 40231 25761 14701 34457 > > I do not understand what mkstar does. >3{t 3 14660 14657 3 40141 14660 3 25668 40141 3 14663 7898 3 40048 14663 3 7898 25668 3 14657 14659 3 14659 40048 is the set of triangles where point 3 is involved. Each triangle is counter-clockwise and the set of triangles is unordered. Now, mkstar >3{t 14660 14657 14659 40048 14663 7898 25668 40141 14660 collects all the other points from the above list and puts them in an order that goes counter-clockwise around our point 4. They form a close loop around the point (first=last). This in contrast with: >4{t 4 25761 14701 4 14701 34457 4 40231 25761 4 25669 34100 4 34100 25668 4 25668 40231 mkstar >4{t 25669 34100 25668 40231 25761 14701 34457 as point 4 is at the edge of the dataset . Now it matters where the list starts (you may conclude that points 25669 and 34457 are also at the edge of the dataset). > That said, point coordinates to canonical point index: > > XYZ i. y NB. y is a point or a list of points > > point coordinates to all point indices: > > I. XYZ *./"1@e. y NB. y is probably a single point > > Note that if this second expression gives you multiple values for any > single point, I would be tempted to change my original definition of > XYZ and, as a consequence, my original definition of TRI: > > XYZ=: ~.xyz #~ (i.#xyz) e.~.,tri > TRI=: tri { XYZ i. xyz It is the same with my data. > Anyways... triangle indices for triangles which refer to a point index > (or to a list of point indices): > > I. TRI +./"1@e. y NB. y is a point index or a list of point indices > > Note that you can also do a transitive closure to find sets of > connected triangles (which may or may not be interesting, depending on > your data set). This will become very interesting after I segment my data (according to terrain, building, vegetation etc.), to see what is/is not connected. But for the time being everything is connected. > This could probably be improved, but it gives the basic idea: > > triclos=: 4 :0 > ids=. i.#x > whilst. -. old -: ids do. > old=. ids > ids=. (3 #"0 <./"1 y { ids) y} ids > end. > (<./"1 y { ids) </. y > ) > > XYZ triclose TRI > > The result is the fewest possible boxes of triangles where all > triangles within a box can be reached using edges of other triangles > in that box. Thanks! ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm