
Boost : 
Subject: Re: [boost] Preview 3 of the Geometry Library
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 20081016 15:57:34
Simonson, Lucanus J wrote:
>
> How can you model a rectangle that is not axis aligned and is still a
> rectangle? The only way I can thing of is to model it is width, height,
> center point and rotation. If you snap its corners to the coordinate
> grid it will, in general, no longer be a rectangle. Similar to the
> circle, I like rectangle, prism and hyperprism for 2D, 3D and ND
> rectangles. While nonaxisaligned rectangles could be useful, you have
> the option of modeling them as polygons with 4 vertices that are as
> nearly rectangular as you can make them within your coordinate system.
>
In my domain we call this an oriented bounding box.
Typically in 2d its represented by a center point, x and y axis vectors,
width and height.
Something like:
template< typename T >
struct obb
{
point<T,2> center;
vector<T,2> x_axis, y_axis;
T width, height;
};
You could also represent it at 3 points I think.
Although I suppose in your domain where you use mostly integers these
definitions might not be workable.
 Michael Marcin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk