1
0
Fork 0

Added toPoly method (this should probably be a makePolygon in utils).

This commit is contained in:
david 2002-07-23 14:32:01 +00:00
parent 881fc4ad73
commit 14488cda6a
2 changed files with 20 additions and 0 deletions

View file

@ -70,4 +70,15 @@ Rectangle::isOverlapping (const Rectangle &r) const
(max.y() >= _min.y()) && (min.y() <= _max.y()));
}
const FGPolygon
Rectangle::toPoly () const
{
FGPolygon poly;
poly.add_node(0, _min);
poly.add_node(0, Point3D(_max.x(), _min.y(), 0));
poly.add_node(0, _max);
poly.add_node(0, Point3D(_min.x(), _max.y(), 0));
return poly;
}
// end of rectangle.cxx

View file

@ -14,6 +14,8 @@
#include <simgear/compiler.h>
#include <simgear/math/point3d.hxx>
#include <Polygon/polygon.hxx>
/**
* A simple rectangle class for bounding rectanglees.
@ -118,6 +120,13 @@ public:
*/
virtual bool isOverlapping (const Rectangle &r) const;
/**
* Create a polygon representation of this rectangle.
*
* @return A four-vertex polygon representing this rectangle.
*/
virtual const FGPolygon toPoly () const;
private:
Point3D _min;
Point3D _max;