File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,6 +40,18 @@ namespace systems::leal::vector_math {
4040 return toReturn;
4141 }
4242
43+ Mat<DATA_TYPE,COLS,ROWS> transpose () const {
44+ Mat<DATA_TYPE,COLS,ROWS> toReturn;
45+
46+ int ownIndex=0 ;
47+ for (int a=0 ; a<COLS; a++)
48+ for (int b=0 ; b<ROWS; b++) {
49+ toReturn.data [COLS*b + a] = this ->data [ownIndex];
50+ ownIndex++;
51+ }
52+
53+ return toReturn;
54+ }
4355
4456 };
4557
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ namespace systems::leal::vector_math
4242 static Matrix4<DATA_TYPE> rotateX (DATA_TYPE angle);
4343 static Matrix4<DATA_TYPE> rotateY (DATA_TYPE angle);
4444 static Matrix4<DATA_TYPE> rotateZ (DATA_TYPE angle);
45+
4546
4647 };
4748
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ TEST(Matrix4Float, mul) {
4343 EXPECT_EQ (Matrix4<float >::identity ()*Matrix4<float >(1 ), Matrix4<float >(1 ));
4444}
4545
46+ TEST (Matrix4Float, transpose) {
47+ EXPECT_EQ (Matrix4<float >::identity ().transpose (), Matrix4<float >::identity ());
48+ }
49+
4650TEST (Matrix4Double, constructors) {
4751 EXPECT_EQ (sizeof (Matrix4<double >), 128 );
4852 EXPECT_EQ (Matrix4<double >::identity (), Matrix4<double >::identity ());
@@ -59,6 +63,10 @@ TEST(Matrix4Double, mul) {
5963 EXPECT_EQ (Matrix4<double >::identity ()*Matrix4<double >(1 ), Matrix4<double >(1 ));
6064}
6165
66+ TEST (Matrix4Double, transpose) {
67+ EXPECT_EQ (Matrix4<double >::identity ().transpose (), Matrix4<double >::identity ());
68+ }
69+
6270int main (int argc, char **argv) {
6371 testing::InitGoogleTest (&argc, argv);
6472 return RUN_ALL_TESTS ();
You can’t perform that action at this time.
0 commit comments