Boost logo

Boost :

Subject: Re: [boost] Review Request: QVM (generic Quaternion, Vector and Matrix operations library)
From: Emil Dotchevski (emil_at_[hidden])
Date: 2015-05-06 22:13:54

On Wed, May 6, 2015 at 6:32 PM, Adam Wulkiewicz <adam.wulkiewicz_at_[hidden]>

> 2015-05-07 2:25 GMT+02:00 Emil Dotchevski <emildotchevski_at_[hidden]>:
> >
> > Q: Why doesn't QVM use [] or () to access vector and matrix elements?
> >
> > A: Because it's designed to work with user-defined types, and the C++
> > standard requires these operators to be members. Of course if a
> > user-defined type defines operator[] or operator() they are available for
> > use with other QVM functions, but the generic access defined by QVM uses
> > operator% instead.
> >
> >
> Emil, correct me if I'm wrong.
> For higher dimensions the user would be forced to use traits explicitly:
> qvm::v_traits<vec_t>::r<I>(vec);
> qvm::m_traits<mat_t>::r<R, C>(mat);


Note however that this is only needed when writing generic functions that
work with arbitrary quat/vec/mat types. Otherwise you can use whatever
syntax is appropriate for the types you use with QVM. For example one of
the 3D vector types I use looks like this: struct float3 { float x, y, z;
}, so typically I access its elements as v.x, v.y and v.z, rather than v%X,
v%Y and v%Z, though v%A<n> (A is a template) also works, and so do v%A0,
v%A1 and v%A2 (these are not templates.)

I can't think of a way to make this less ugly.


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