[Bf-blender-cvs] [04496a2e01f] soc-2021-adaptive-cloth: float2x2: inverse
ishbosamiya
noreply at git.blender.org
Mon Sep 6 11:47:40 CEST 2021
Commit: 04496a2e01f34a48e838cafe742bbbd2fe789ead
Author: ishbosamiya
Date: Sun Sep 5 10:55:38 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB04496a2e01f34a48e838cafe742bbbd2fe789ead
float2x2: inverse
===================================================================
M source/blender/blenlib/BLI_float2x2.hh
===================================================================
diff --git a/source/blender/blenlib/BLI_float2x2.hh b/source/blender/blenlib/BLI_float2x2.hh
index 9bf27d50d49..dd7ebe06826 100644
--- a/source/blender/blenlib/BLI_float2x2.hh
+++ b/source/blender/blenlib/BLI_float2x2.hh
@@ -215,6 +215,19 @@ struct float2x2 {
return {q, lambda};
}
+ float2x2 inverse() const
+ {
+ const auto a = this->ptr()[0][0];
+ const auto b = this->ptr()[1][0];
+ const auto c = this->ptr()[0][1];
+ const auto d = this->ptr()[1][1];
+
+ const auto det = a * d - b * c;
+ BLI_assert(det != 0.0);
+
+ return float2x2(d, -c, -b, a) * (1.0 / det);
+ }
+
uint64_t hash() const
{
uint64_t h = 435109;
More information about the Bf-blender-cvs
mailing list