 # Boost :

From: rodolfo_at_[hidden]
Date: 2006-03-23 13:54:01

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 and coord, 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), y(coord) {}
point(const T &_x, const T &_y) : x(coord=_x), y(coord=_y) {}
T coord;
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

_______________________________________________________
Yahoo! doce lar. Faça do Yahoo! sua homepage.
http://br.yahoo.com/homepageset.html