
Hello, The QVM library has been in the review queue for a some time waiting for a review manager. I've been receiving occasional support requests from random people, and I remember there was at least some initial interest when I proposed the library years ago, but nobody has volunteered to be the review manager yet. This is a library for working with (Q)uaternions and statically-sized (V)ectors and (M)atrices, it's the kind of high level library that is useful to video game programers working with 3D graphics. It's unique (AFAIK) feature is that it uses a type traits system that allows all library functions to operate on 3rd-party types, making it easy to integrate types from different other math libraries into a single type-safe environment. It also has functions that can map vectors as matrices or matrix rows/columns as vectors, or even present mutable transposed view to any matrix, all without creating temporary objects. The documentation and source code can be found here: http://www.revergestudios.com/boost-qvm/ Anyone takers? :) -- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode

Hi Emil, Emil Dotchevski wrote:
Hello,
The QVM library has been in the review queue for a some time waiting for a review manager. I've been receiving occasional support requests from random people, and I remember there was at least some initial interest when I proposed the library years ago, but nobody has volunteered to be the review manager yet.
This is a library for working with (Q)uaternions and statically-sized (V)ectors and (M)atrices, it's the kind of high level library that is useful to video game programers working with 3D graphics.
It's unique (AFAIK) feature is that it uses a type traits system that allows all library functions to operate on 3rd-party types, making it easy to integrate types from different other math libraries into a single type-safe environment. It also has functions that can map vectors as matrices or matrix rows/columns as vectors, or even present mutable transposed view to any matrix, all without creating temporary objects.
The documentation and source code can be found here: http://www.revergestudios.com/boost-qvm/
Anyone takers? :)
I'd like to be a review manager of QVM, however I don't have enough free time at the moment. I predict that the situation should be different for around a month or two. So if until that time you didn't find someone else I'd volunteer. Regards, Adam

On Fri, Jun 6, 2014 at 3:32 AM, Adam Wulkiewicz
I'd like to be a review manager of QVM, however I don't have enough free time at the moment. I predict that the situation should be different for around a month or two. So if until that time you didn't find someone else I'd volunteer.
Thanks Adam! Emil

Hi Emil,
Apologies for being yet another random support requester :) I use GLM
http://www.g-truc.net/project-0016.html#menu here and there and boost
quite a bit; replacing the GLM dependency with boost::QVM is therefore
attractive, assuming it is approved. As a GLM user, I have a couple
questions:
Would I have to use QVM with my own matrix type if I want to feed a QVM
matrix to glUniformMatrix4fv without a temp copy? With GLM, I do this
using, for example, glUniformMatrix4fv(fooLoc, 1, GL_FALSE,
glm::value_ptr(fooMatrix)).
If I do have to make my own matrix type, does QVM depend on matrices being
stored as a 2D arrays rather than flat arrays addressed internally using
the usual data[row*width + col] (or data[col*height + row], if you prefer)?
Thanks,
Erik
On Thu, Jun 5, 2014 at 10:38 PM, Emil Dotchevski
Hello,
The QVM library has been in the review queue for a some time waiting for a review manager. I've been receiving occasional support requests from random people, and I remember there was at least some initial interest when I proposed the library years ago, but nobody has volunteered to be the review manager yet.
This is a library for working with (Q)uaternions and statically-sized (V)ectors and (M)atrices, it's the kind of high level library that is useful to video game programers working with 3D graphics.
It's unique (AFAIK) feature is that it uses a type traits system that allows all library functions to operate on 3rd-party types, making it easy to integrate types from different other math libraries into a single type-safe environment. It also has functions that can map vectors as matrices or matrix rows/columns as vectors, or even present mutable transposed view to any matrix, all without creating temporary objects.
The documentation and source code can be found here: http://www.revergestudios.com/boost-qvm/
Anyone takers? :)
-- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On Fri, Jun 6, 2014 at 11:50 AM, Erik H
Hi Emil,
Apologies for being yet another random support requester :) I use GLM http://www.g-truc.net/project-0016.html#menu here and there and boost quite a bit; replacing the GLM dependency with boost::QVM is therefore attractive, assuming it is approved. As a GLM user, I have a couple questions:
Ha, I didn't mean to imply that I'm annoyed by support questions. :)
Would I have to use QVM with my own matrix type if I want to feed a QVM matrix to glUniformMatrix4fv without a temp copy? With GLM, I do this using, for example, glUniformMatrix4fv(fooLoc, 1, GL_FALSE, glm::value_ptr(fooMatrix)).
If a matrix type stores its values as anything but a 1-dimensional
array in column-major order, you can't (portably) feed it into
glUniformMatrix4fv without a temporary; at least it'd require a cast,
which in theory may not work on some platform.
The solution if you use QVM is to define your own matrix type that
stores the values as an array internally, which would let you pass it
to OpenGL without a temp:
struct gl_mat4
{
float el[16];
};
Then you specialize the m_traits type from the QVM library to enable
the appropriate matrix operations for objects of type gl_mat4:
template <>
struct m_traits

Emil Dotchevski wrote:
If a matrix type stores its values as anything but a 1-dimensional array in column-major order, you can't (portably) feed it into glUniformMatrix4fv without a temporary; at least it'd require a cast, which in theory may not work on some platform.
Actually, a two-dimensional array is guaranteed to be laid out linearly in memory. The rest of the message still stands though.

On Fri, Jun 6, 2014 at 1:39 PM, Peter Dimov
Emil Dotchevski wrote:
If a matrix type stores its values as anything but a 1-dimensional array in column-major order, you can't (portably) feed it into glUniformMatrix4fv without a temporary; at least it'd require a cast, which in theory may not work on some platform.
Actually, a two-dimensional array is guaranteed to be laid out linearly in memory. The rest of the message still stands though.
You need a cast, and my understanding is that that makes your code not portable because it violates the strict aliasing rule. This is purely theoretical, obviously, in practice it'll most likely work. Anyway, if you want to use a 2D array and cast it to 1D array, there is nothing in the QVM library that would get in your way. -- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode

Emil Dotchevski wrote:
You need a cast, and my understanding is that that makes your code not portable because it violates the strict aliasing rule.
For float v[4][4], &v[0][0] is not a cast and gives you a float* p such that the elements are in [p+0, p+16). A reinterpret_cast to float(&)[16] is an interesting theoretical question. I think that it doesn't violate the aliasing rules, but g++ is in the habit of disagreeing with such statements.

On Fri, Jun 6, 2014 at 3:00 PM, Emil Dotchevski
On Fri, Jun 6, 2014 at 11:50 AM, Erik H
wrote: Hi Emil,
Apologies for being yet another random support requester :) I use GLM http://www.g-truc.net/project-0016.html#menu here and there and boost quite a bit; replacing the GLM dependency with boost::QVM is therefore attractive, assuming it is approved. As a GLM user, I have a couple questions:
Ha, I didn't mean to imply that I'm annoyed by support questions. :)
Would I have to use QVM with my own matrix type if I want to feed a QVM matrix to glUniformMatrix4fv without a temp copy? With GLM, I do this using, for example, glUniformMatrix4fv(fooLoc, 1, GL_FALSE, glm::value_ptr(fooMatrix)).
If a matrix type stores its values as anything but a 1-dimensional array in column-major order, you can't (portably) feed it into glUniformMatrix4fv without a temporary; at least it'd require a cast, which in theory may not work on some platform.
The solution if you use QVM is to define your own matrix type that stores the values as an array internally, which would let you pass it to OpenGL without a temp:
struct gl_mat4 { float el[16]; };
Then you specialize the m_traits type from the QVM library to enable the appropriate matrix operations for objects of type gl_mat4:
template <> struct m_traits
{ static int const rows = 4; static int const cols = 4; typedef float scalar_type; template
static scalar_type r( gl_mat4 const & m ) { return m.el[C*4+R]; } template static scalar_type & w( gl_mat4 & m ) { return m.el[C*4+R]; } static scalar_type ir( int r, int c, gl_mat4 const & m ) { return m.el[c*4+r]; } static scalar_type & iw( int r, int c, gl_mat4 & m ) { return m.el[c*4+r]; } };
Now if you want to pass a gl_mat4 to glUniformMatrix4fv, you just do m.el, yet you get all matrix operations automatically working for gl_mat4 objects, including if you mix them with other matrix types, e.g. the ones that come from the 3D engine you use, or the physics simulation library you use, etc.
HTH, Emil
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thanks for the comprehensive response! That's awesome! It works as you say with GL, and additionally I had no problem using the same tricks to make a boost::numpy view of QVM matrix :) QVM should be a shoo-in, in my opinion. -Erik
participants (5)
-
Adam Wulkiewicz
-
Emil Dotchevski
-
Emil Dotchevski
-
Erik H
-
Peter Dimov