|
Boost : |
From: rodolfo_at_[hidden]
Date: 2006-03-23 11:57:08
On Thu, Mar 23, 2006 at 10:51:42AM +0100, Theodore Papadopoulo wrote:
> On Wed, 2006-03-22 at 21:52 +0100, Janek Kozicki wrote:
> Euclidean::Point<N>
> Euclidean::Line<N> // not very different from projective
> line ??
> Euclidean::SemiLine<N>
> Euclidean::Segment<N>
> Euclidean::Simplex<N>
I like this way of representing them. And for instance, Point<2> can
be a specialization that adds members x and y, them being references to
coord[0] and coord[1], same thing with Point<3>.
As those geometry classes are (and will) be used a lot, the main usage
should be kept trivial and simple (or as others may say: KISS methodology).
using namespace euclidean;
template <unsigned D, class T>
struct point
{
T coord[D]; // someone wrote about a smallvector type...
};
template <class T>
struct point<2, T>
{
point() : x(coord[0]), y(coord[1]) {}
point(const T &_x, const T &_y) : x(coord[0]=_x), y(coord[1]=_y) {}
T coord[2];
T &x, &y;
};
something similar for rects
template <unsigned D, class T>
point<D, T> cross(const point<D, T> &pt1, const point<D, T> &pt2)
{
return // cross product, we should add specializations for each
// dimension
}
template <unsigned D, class T>
T dot(const point<D, T> &pt1, const point<D, T> &pt2)
{
return // same thing, specializations for each dimension
}
point<2,double> pt1(3,4); point<2> pt2(5,6);
point<2,double> pt3 = cross(pt1, pt2);
double d = dot(pt2, pt3);
rect<2,double> rc(p2, pt3);
double a = rc.area(); // or area(rc)?
[]s
Rodolfo Lima
_______________________________________________________
Novo Yahoo! Messenger com voz: Instale agora e faça ligações de graça.
http://br.messenger.yahoo.com/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk