# Boost :

Subject: Re: [boost] Preview 3 of the Geometry Library
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-10-16 19:02:59

Simonson, Lucanus J wrote:
> Bruno wrote:
>> Indeed it's something that should be done, we had a quick discussion
>> about that with Barend and decided to postpone that for now. This kind
>> of subject is never easy. For example, I'd like to rename circle into
>> hypersphere or nsphere, but then we'll also have to clarify the
>> meaning of some algorithms. For example what we currently call the
>> area of a circle is actually the volume of an hypershere<2>...
>
> My preference would be to have a circle data type, a sphere data type
> and a hypersphere data type. Only the hypersphere would be
> parameterized on dimension. The user would pick the object that is
> named for what they want. If a user wants a circle they are going to be
> frustrated and confounded that we provide them nsphere<2>.

circle would just be a typedef for nsphere<2>.
Still, that has issues, since you will only be able to use that in 2D
space. So if you want to use a 'circle' in 3D, it won't work, since it
needs to know in which plan the circle is.

You might as well use CSG to intersect a sphere with a plan and
construct a circle in 3D.
By the way, I think the geometry library will need to consider CSG at a
point or another so that intersection can always return something, at
least combinations with spheres. Unless it is chosen to approximate
spheres to polyhedrons to avoid the issue.

> How can you model a rectangle that is not axis aligned and is still a
> rectangle?

I think the minimal representation just needs three points (while an
aligned one requires only two), whatever the dimension, but I'm not sure
Of course, you can choose to represent it as a quadrilateral, i.e. a
polygon with 4 points and no holes.

I fail to see how it not being axis-aligned makes its existence as a
rectangle more difficult.
Considering 2D, take for example that non axis-aligned rectangle
(actually square because I'm lazy) defined by those points, in direct order:
(0, 1), (1, 0), (0, -1), (-1, 0)

Yes, that can model a rectangle that's not axis aligned, even if the
coordinate systems is made with integers.

> 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.

I don't really see how it stops being a rectangle once rotated.
Are you thinking in terms of pixels maybe, because straight lines that
are not axis-aligned aren't straight when rendered as pixels?

> Similar to the
> circle, I like rectangle, prism and hyperprism for 2D, 3D and ND
> rectangles. While non-axis-aligned 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.

Rectangles have some nice proprieties regular quadrilateral do not have,
so you might be able to use more efficient algorithms by making use of a
rectangle (meta-)type (or concept) instead of a quadrilateral one.