On Wed, Jan 11, 2012 at 12:21 PM, Ben Gorte - LR <b.g.h.go...@tudelft.nl> wrote:
>   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?

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, but it should
make all algorithms which deal with triangles simpler (and faster).
If I needed to reverse the operation, and apply triangle based results
back on the original full set of points, I would save the intermediate
result from (XYZ i. xyz)

I am also not sure if the explicit ~. in the first line saves any
measurable time.

> Furthermore I have an ugly verb mkstar that does:
>
>   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.

It looks like you are locating a point in space and then finding some
associated triangles, but I do not know which triangles you are
getting (I cannot inspect your data to find that).

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

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 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.

Note that if you have reason for independent points to be located at
the same spot, and you want connections from a triangle using one of
those instances to be connected with all triangles using any of the
other instances you would change the first line to:

  ids=. i.~x

But I do not know if any of this was relevant to your efforts.

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to