On Wed, May 6, 2015 at 6:32 PM, Adam Wulkiewicz
2015-05-07 2:25 GMT+02:00 Emil Dotchevski
: 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
::r<I>(vec); qvm::m_traits ::r (mat);
See: http://www.revergestudios.com/boost-qvm/accessing_matrix_elements_reference.... http://www.revergestudios.com/boost-qvm/accessing_vector_elements_and_swizzl... http://www.revergestudios.com/boost-qvm/accessing_quaternion_elements_refere... 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. Emil