Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenlib/BLI_float2x3.hh24
-rw-r--r--source/blender/blenlib/BLI_float3x2.hh4
-rw-r--r--source/blender/blenlib/CMakeLists.txt2
-rw-r--r--source/blender/blenlib/intern/BLI_float2x3.cc38
-rw-r--r--source/blender/blenlib/intern/BLI_float3x2.cc22
5 files changed, 72 insertions, 18 deletions
diff --git a/source/blender/blenlib/BLI_float2x3.hh b/source/blender/blenlib/BLI_float2x3.hh
index ce0523d2d9c..1236b25f174 100644
--- a/source/blender/blenlib/BLI_float2x3.hh
+++ b/source/blender/blenlib/BLI_float2x3.hh
@@ -20,14 +20,15 @@
#include "BLI_float2.hh"
#include "BLI_float2x2.hh"
#include "BLI_float3.hh"
-#include "BLI_float3x2.hh"
namespace blender {
+struct float3x2;
+
/**
* A 2x3 column major matrix.
*
- * float3x3::values[i] is the ith column of the matrix.
+ * float2x3::values[i] is the ith column of the matrix.
*
* |m00 m10 m20|
* |m01 m11 m21|
@@ -78,22 +79,7 @@ struct float2x3 {
return result;
}
- friend float2x2 operator*(const float2x3 &a, const float3x2 &b)
- {
- float2x2 result;
-
- result.ptr()[0][0] = a.ptr()[0][0] * b.ptr()[0][0] + a.ptr()[1][0] * b.ptr()[0][1] +
- a.ptr()[2][0] * b.ptr()[0][2];
- result.ptr()[0][1] = a.ptr()[0][1] * b.ptr()[0][0] + a.ptr()[1][1] * b.ptr()[0][1] +
- a.ptr()[2][1] * b.ptr()[0][2];
-
- result.ptr()[1][0] = a.ptr()[0][0] * b.ptr()[1][0] + a.ptr()[1][0] * b.ptr()[1][1] +
- a.ptr()[2][0] * b.ptr()[1][2];
- result.ptr()[1][1] = a.ptr()[0][1] * b.ptr()[1][0] + a.ptr()[1][1] * b.ptr()[1][1] +
- a.ptr()[2][1] * b.ptr()[1][2];
-
- return result;
- }
+ friend float2x2 operator*(const float2x3 &a, const float3x2 &b);
friend float2x3 operator*(const float2x2 &a, const float2x3 &b)
{
@@ -164,6 +150,8 @@ struct float2x3 {
return res;
}
+ float3x2 transpose() const;
+
uint64_t hash() const
{
uint64_t h = 435109;
diff --git a/source/blender/blenlib/BLI_float3x2.hh b/source/blender/blenlib/BLI_float3x2.hh
index 1b4731f701c..12b6f18e8b9 100644
--- a/source/blender/blenlib/BLI_float3x2.hh
+++ b/source/blender/blenlib/BLI_float3x2.hh
@@ -23,6 +23,8 @@
namespace blender {
+struct float2x3;
+
/**
* A 3x2 column major matrix.
*
@@ -160,6 +162,8 @@ struct float3x2 {
return res;
}
+ float2x3 transpose() const;
+
uint64_t hash() const
{
uint64_t h = 435109;
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 5cf53c00128..e79bdb3096b 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -44,6 +44,8 @@ set(SRC
intern/BLI_dial_2d.c
intern/BLI_dynstr.c
intern/BLI_filelist.c
+ intern/BLI_float2x3.cc
+ intern/BLI_float3x2.cc
intern/BLI_ghash.c
intern/BLI_ghash_utils.c
intern/BLI_heap.c
diff --git a/source/blender/blenlib/intern/BLI_float2x3.cc b/source/blender/blenlib/intern/BLI_float2x3.cc
new file mode 100644
index 00000000000..bf3ae086f43
--- /dev/null
+++ b/source/blender/blenlib/intern/BLI_float2x3.cc
@@ -0,0 +1,38 @@
+#include "BLI_float2x3.hh"
+#include "BLI_float3x2.hh"
+
+namespace blender {
+
+float2x2 operator*(const float2x3 &a, const float3x2 &b)
+{
+ float2x2 result;
+
+ result.ptr()[0][0] = a.ptr()[0][0] * b.ptr()[0][0] + a.ptr()[1][0] * b.ptr()[0][1] +
+ a.ptr()[2][0] * b.ptr()[0][2];
+ result.ptr()[0][1] = a.ptr()[0][1] * b.ptr()[0][0] + a.ptr()[1][1] * b.ptr()[0][1] +
+ a.ptr()[2][1] * b.ptr()[0][2];
+
+ result.ptr()[1][0] = a.ptr()[0][0] * b.ptr()[1][0] + a.ptr()[1][0] * b.ptr()[1][1] +
+ a.ptr()[2][0] * b.ptr()[1][2];
+ result.ptr()[1][1] = a.ptr()[0][1] * b.ptr()[1][0] + a.ptr()[1][1] * b.ptr()[1][1] +
+ a.ptr()[2][1] * b.ptr()[1][2];
+
+ return result;
+}
+
+float3x2 float2x3::transpose() const
+{
+ float3x2 result;
+
+ result.ptr()[0][0] = this->ptr()[0][0];
+ result.ptr()[0][1] = this->ptr()[1][0];
+ result.ptr()[0][2] = this->ptr()[2][0];
+
+ result.ptr()[1][0] = this->ptr()[0][1];
+ result.ptr()[1][1] = this->ptr()[1][1];
+ result.ptr()[1][2] = this->ptr()[2][1];
+
+ return result;
+}
+
+} // namespace blender
diff --git a/source/blender/blenlib/intern/BLI_float3x2.cc b/source/blender/blenlib/intern/BLI_float3x2.cc
new file mode 100644
index 00000000000..38b6c29687d
--- /dev/null
+++ b/source/blender/blenlib/intern/BLI_float3x2.cc
@@ -0,0 +1,22 @@
+#include "BLI_float3x2.hh"
+#include "BLI_float2x3.hh"
+
+namespace blender {
+
+float2x3 float3x2::transpose() const
+{
+ float2x3 res;
+
+ res.ptr()[0][0] = this->ptr()[0][0];
+ res.ptr()[0][1] = this->ptr()[1][0];
+
+ res.ptr()[1][0] = this->ptr()[0][1];
+ res.ptr()[1][1] = this->ptr()[1][1];
+
+ res.ptr()[2][0] = this->ptr()[0][2];
+ res.ptr()[2][1] = this->ptr()[1][2];
+
+ return res;
+}
+
+} // namespace blender