added a method for getting the center of a grid cell

This commit is contained in:
Paolo Cignoni 2009-07-14 08:55:20 +00:00
parent 67ce5b52ce
commit a5cb113561
1 changed files with 16 additions and 6 deletions

View File

@ -158,17 +158,27 @@ public:
* @return b is the corresponding box in <ScalarType> coordinates
*/
inline void IPiToBox(const Point3i & pi, Box3x & b ) const
{
CoordType p;
{
CoordType p;
p[0] = ((ScalarType)pi[0])*voxel[0];
p[1] = ((ScalarType)pi[1])*voxel[1];
p[2] = ((ScalarType)pi[2])*voxel[2];
p += bbox.min;
b.min = p;
b.max = (p + voxel);
p += bbox.min;
b.min = p;
b.max = (p + voxel);
}
// Same of above but for the case that you just want to transform
/* Given a cell index return the center of the cell itself
* @param integer coordinates pi of the cell
* @return b is the corresponding box in <ScalarType> coordinates
*/inline void IPiToBoxCenter(const Point3i & pi, CoordType & c ) const
{
CoordType p;
IPiToPf(pi,p);
c = p + voxel/ScalarType(2.0);
}
// Same of IPiToPf but for the case that you just want to transform
// from a space to the other.
inline void IPfToPf(const CoordType & pi, CoordType &p ) const
{