# Geometry :

Subject: [ggl] Point/Box in Box Test (Border Cases - 3D)
Date: 2011-06-28 05:54:12

Hi,

does boost.geometry currently provide a way to do "geometry1 within
geometry2" tests including border cases?

-------------------------------------------------------------------

That's my basic question! If required - more details of what I want
to do:

1) Test whether a point lies in a box including being on the border
based on the boost::geometry::within function.

Example: boost::geometry::within(Point3D(0, 0, 0),
Box3D(Point3D(0, 0, 0), Point3D(1, 1, 1)) delivers false.

The test succeeds for points that are within the box but not on the
border.

I am aware that boost::geometry::intersects works for point-in-box
tests including border cases but has two drawbacks:
i) It seems to be 30% slower for point-in-box tests.
ii) I would like to use the same call to boost::geometry for
box-in-box, point-in-box or even polygon in polygon tests
(boost::within does allow this, although its return values
aren't as desired).

2) Test whether a box lies within a box, including being on the border?

Trivial example:
const Box3D box(Point3D(0,0,0), Point3D(1, 1, 1));
boost::geometry::within(box, box) delivers false.

The test succeeds for boxes that are within the given box but do not
touch the border.

3) What about point/polygon in polygon tests with respect to border
cases? I haven't tested them yet...

The data structures that I use in the above examples:

// Create custom point type.
struct Point3D {
float x, y, z;

Point3D() : x(0.0), y(0.0), z(0.0) {}

Point3D(float a, float b, float c) : x(a), y(b), z(c) {}
};

// Create custom box type.
struct Box3D {
Box3D() : origin(Point3D(0.0, 0.0, 0.0)),
size(Point3D(0.0, 0.0, 0.0)) {}

Box3D(Point3D a, Point3D b) : origin(a), size(b) {}

Point3D origin, size;
};

// Register custom types.
BOOST_GEOMETRY_REGISTER_POINT_3D(Point3D, float,
boost::geometry::cs::cartesian, x, y, z)
BOOST_GEOMETRY_REGISTER_BOX(Box3D, Point3D, origin, size);

Best regards,
Frank

Geometry list run by mateusz at loskot.net