Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] distance from periodic_point to point

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] distance from periodic_point to point


Chronological Thread 
  • From: Manuel Caroli <>
  • To:
  • Subject: Re: [cgal-discuss] distance from periodic_point to point
  • Date: Tue, 18 May 2010 18:14:38 +0200

Hi Ariel,

sorry for the late answer, I somehow missed your question.

Unfortunately I don't see any better solution than the function you posted below. The problem is that your point p1 is not part of the triangulation, so there is no implicit way to find out how it has to be translated in order to be located close to the given cell.

best

Manuel


On 13/05/10 08:18, Ariel Keselman wrote:

Dear all,

I need to calculate the distance from a point to the
vertices of the cell that contains it, in a periodic
Delaunay triangulation. This is done to interpolate
a function with the inverse distance method.

The most obvious way to do this, and the one I
implemented, is to take the periodic_point from the
cell, and then calcule dx,dy,dz between the
periodic_point and the point. In those directions
where the difference is too large, (say,>box_len/2)
the point is translated by box_len. Here is the
function I use:

inline const tvc
periodic_r(const PDT& T, const tch& ch,
const unsigned int i, const tpt& p1) {

const double blen2=T.domain().xmax()/2.0;
const tpt p2=T.point(ch,i);
const tvc rv(p1,p2);
bool needs_trans=false;
int ox=0,oy=0,oz=0;
if (rv.x()>=blen2) {
needs_trans=true;
ox=+1;
}
if (rv.y()>=blen2) {
needs_trans=true;
oy=+1;
}
if (rv.z()>=blen2) {
needs_trans=true;
oz=+1;
}
if (!needs_trans) return rv;
const tpp tpp1(p1,PDT::Offset(ox,oy,oz));
const tpt tp1=T.point(tpp1);
const tvc trv(tp1,p2);
return trv;
}

My question is, is there a way to do this more efficient?
This function increases the time of the main loop by
0.1 secs, which is about 5%. It just feels this should
be a one-liner, but being new to CGAL, I can't see how
to improve it...

Thanks in advance,
Ariel.





Archive powered by MHonArc 2.6.16.

Top of Page