Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

[cgal-discuss] distance from periodic_point to point


Chronological Thread 
  • From: Ariel Keselman <>
  • To:
  • Subject: [cgal-discuss] distance from periodic_point to point
  • Date: Wed, 12 May 2010 23:18:17 -0700 (PDT)


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.

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/distance-from-periodic-point-to-point-tp2197187p2197187.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.16.

Top of Page