Fixed: outerProduct was defined incorrectly for unmatched vecX types. E.g. outerProduct(vec2, vec4) did not succeed because the matrix return types were wrong. The computing function seemed fine. I used https://en.wikipedia.org/wiki/Outer_product as reference on what the number of columns/rows ''should'' be and fixed it so that it matches the description from wikipedia

Added: tests for outerProduct with unmatched vector dimensions (actually testing all combinations now)
This commit is contained in:
Paul Konstantin Gerke 2016-01-24 21:14:25 +01:00 committed by Christophe Riccio
parent b3b72527b1
commit 239cf70ade
2 changed files with 18 additions and 7 deletions

View File

@ -72,19 +72,19 @@ namespace detail
template <typename T, precision P> template <typename T, precision P>
struct outerProduct_trait<T, P, tvec2, tvec3> struct outerProduct_trait<T, P, tvec2, tvec3>
{ {
typedef tmat2x3<T, P> type; typedef tmat3x2<T, P> type;
}; };
template <typename T, precision P> template <typename T, precision P>
struct outerProduct_trait<T, P, tvec2, tvec4> struct outerProduct_trait<T, P, tvec2, tvec4>
{ {
typedef tmat2x4<T, P> type; typedef tmat4x2<T, P> type;
}; };
template <typename T, precision P> template <typename T, precision P>
struct outerProduct_trait<T, P, tvec3, tvec2> struct outerProduct_trait<T, P, tvec3, tvec2>
{ {
typedef tmat3x2<T, P> type; typedef tmat2x3<T, P> type;
}; };
template <typename T, precision P> template <typename T, precision P>
@ -96,19 +96,19 @@ namespace detail
template <typename T, precision P> template <typename T, precision P>
struct outerProduct_trait<T, P, tvec3, tvec4> struct outerProduct_trait<T, P, tvec3, tvec4>
{ {
typedef tmat3x4<T, P> type; typedef tmat4x3<T, P> type;
}; };
template <typename T, precision P> template <typename T, precision P>
struct outerProduct_trait<T, P, tvec4, tvec2> struct outerProduct_trait<T, P, tvec4, tvec2>
{ {
typedef tmat4x2<T, P> type; typedef tmat2x4<T, P> type;
}; };
template <typename T, precision P> template <typename T, precision P>
struct outerProduct_trait<T, P, tvec4, tvec3> struct outerProduct_trait<T, P, tvec4, tvec3>
{ {
typedef tmat4x3<T, P> type; typedef tmat3x4<T, P> type;
}; };
template <typename T, precision P> template <typename T, precision P>

View File

@ -101,7 +101,18 @@ int test_matrixCompMult()
int test_outerProduct() int test_outerProduct()
{ {
glm::mat4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec4(1.0f)); { glm::mat2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec2(1.0f)); }
{ glm::mat3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec3(1.0f)); }
{ glm::mat4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec4(1.0f)); }
{ glm::mat2x3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec2(1.0f)); }
{ glm::mat2x4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec2(1.0f)); }
{ glm::mat3x2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec3(1.0f)); }
{ glm::mat3x4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec3(1.0f)); }
{ glm::mat4x2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec4(1.0f)); }
{ glm::mat4x3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec4(1.0f)); }
return 0; return 0;
} }