Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Geometry in a 2D periodic triangulation

Subject: CGAL users discussion list

List archive

[cgal-discuss] Geometry in a 2D periodic triangulation


Chronological Thread 
  • From: Daniel Duque <>
  • To:
  • Subject: [cgal-discuss] Geometry in a 2D periodic triangulation
  • Date: Wed, 13 Nov 2013 14:15:51 +0100

Hello,

I have finally been able to have a look at this exciting new feature of CGAL. I would love to say that I understand everything on the manual, but sadly this is not the case. At any rate, after building the periodic triangulation I get a list of vertices whose Cartesian coordinates are all within the original domain. Usually, there is only one covering, so there are just as many vertices as the points I used as input.

My question is: imagine I now want to compute geometrical stuff, say distances between all neighboring nodes. The triangulation build has the proper connectivity, so two vertices that are close to the edge of the domain and quite far apart may in fact be periodic neighbors. In order to do such a thing, I would do this kind of loop:

 for( Finite_edges_iterator ed=T.finite_edges_begin();
      ed!=T.finite_edges_end();
      ed++) {

    FT l2=per_dist2(v0->point(), v1->point());

// ... print out, collect stats, whatever

}

The "finite" I think can be dropped in this case. I have been careful not to compute the distance between the points, but a periodic distance, following what is called the minimum image convention:

// LL is the size of the periodic domain

FT per_dist(const FT& x1, const FT& x2) {
  FT dx=x1-x2;

  if(fabs(dx)>LL/2.0)
    if(dx>0)
      dx -= LL;
    else
      dx += LL;
  return dx;
}

FT per_dist2(const Point& P1, const Point& P2) {
  FT dx=per_dist(P1.x(),P2.x());
  FT dy=per_dist(P1.y(),P2.y());

  return dx*dx+dy*dy;
}

I would like to get some reassurance that what I am doing is correct. Not very elegant, perhaps, and even redundant (there may be some CGAL function that does just this), but in the end correct (all edges are taken into account just once, for example).

Thanks very much,

Daniel





Archive powered by MHonArc 2.6.18.

Top of Page