Boost logo

Boost :

From: Deane Yang (deane_yang_at_[hidden])
Date: 2004-11-07 15:24:22

First, although I know nearly nothing about GUI libraries, I suspect
that there are much more important things to discuss than whether
a Point is the same thing as a Vector.

Still, I can't resist trying to help clarify things a little.
I will stick to two dimensions.

A Point and a Vector have the same internal representation,
namely an ordered pair of doubles or floats. In that sense,
both are the same.

However, their public interfaces are different. A Vector will
have the following operations:

Vector operator+(Vector v, Vector w);
Vector operator-(Vector v, Vector w);
Vector operator(Vector v, double scalar);
Vector operator-(Vector v);

And, maybe also
double length(Vector v);
double inner_product(Vector v, Vector w);

A Point, however, should have only the following operations:
Point operator+(Point p, Vector v);
Point operator-(Point p, Vector v);
Vector operator-(Point p, Point q);

And, maybe also
double distance(Point p, Point q);

A Point is NOT the same geometric object as a Vector,
even though both have the same internal representation.

Physicists understand this very clearly. They always draw
a point as a dot and a vector as an arrow.

Mathematically, the set of Vectors is the same set as the
set of Points. But operationally they are very different.
In mathematics we call the set of Vectors a "vector space"
and the set of Points an "affine space".

The beauty of object-oriented programming languages is that they
are able to capture this difference and use it to help insure
the correctness of a program and catch coding errors.

But when all is said and done, I can think of much worse sins
than pretending that a Point is the same thing as a Vector.

Boost list run by bdawes at, gregod at, cpdaniel at, john at