- marked as enhancement
Initializing matrices from row vectors
It would be nice to construct matrix instances using a 1D std::initializer_list
containing the row vectors as opposed to only 2D or nested std::initializer_list
s containing the scalar elements.
Comments (3)
-
reporter -
Hi Matthias!
Thanks for the suggestion. If I get the idea correctly, an alternative feature would be to provide a view that combines several vectors into a matrix, which could be used for both initialization and assignment. Could you please provide a short code example for which context you have in mind? Thanks again,
Best regards,
Klaus!
-
reporter My use cases are mostly related to transformations.
E.g., given a normal vector n, compute a tangent vector t and bitangent vector b and finally construct a transformation matrix from the resulting coordinate frame:
const blaze::StaticVector< float, 3u, blaze::rowVector > n_world = ...; // Obtain the normal vector. const blaze::StaticVector< float, 3u, blaze::rowVector > t_world = ...; // Compute the tangent vector. const blaze::StaticVector< float, 3u, blaze::rowVector > b_world = ...; // Compute the bitangent vector. const blaze::StaticMatrix< float, 3u, 3u, blaze::columnMajor > tangent_to_world = { t_world, b_world, n_world }; // Construct a 3x3 (rotation) transformation matrix. // ... or even more flexible ... const blaze::StaticMatrix< float, 4u, 4u, blaze::columnMajor > tangent_to_world = { t_world, b_world, n_world, { 0.0f, 0.0f, 0.0f, 1.0f } }; // Construct a 4x4 affine transformation matrix.
It is possible to use a view as well, but that requires an initialization and does not allow const.
- Log in to comment