
From: "Olivier Grant" <olivier.grant@gmail.com> On 9/20/06, Walter Landry <wlandry@ucsd.edu> wrote:
This seems wrong. If I want to add a vector2d to a vector3d, then I should have to do it manually. Otherwise, it should be a type error.
it depends how you see the problem I suppose. A 2D vector is just a 3D vector with z == 0. A 3D vector is a 4D vector with w == 1. And so on by extension. Since these vector classes are not supposed to be used in a polymorphic way, each argument of a function call is well-known by the user - or at least should be :) - so I would not raise an exception in the case of the use of two vectors with different dimensions.
But a 2D vector is NOT just a 3D vector with z = 0!! It might sit in a subspace of a 3D vector space, but not necessarily in the z=0 plane. It could just as easily be a 2D vector in the x - 2y + 3z = 0 plane. Certainly do it this way if you want to - maybe it makes perfect sense for your particular application. But I'd never want to see something like this standardized in BOOST. It just ain't right. :) Also, if a 2D vector is a 3D vector with z=0, and a 3D vector is a 4D vector with w=1, "and so on by extension", then how would a 4D vector compare with a 5D vector? I don't get the extension. When you first posted your example, I assumed you'd made a typo when you set w=1, but now I think you did that on purpose. Why wouldn't w=0? - James Jones Administrative Data Mgmt. Webmaster 375 Raritan Center Pkwy, Suite A Data Architect Edison, NJ 08837