diff --git a/src/bin/flat.rs b/src/bin/flat.rs index 597b29f..3b374e0 100644 --- a/src/bin/flat.rs +++ b/src/bin/flat.rs @@ -78,6 +78,7 @@ impl Metric for Coil { mod riemann { use glm::*; + use glm::ext::pow2; use num_traits::identities::Zero; pub struct Decomp2 { @@ -95,6 +96,11 @@ mod riemann { transpose(&h.ortho) * diagonal(h.diag * h.diag) * h.ortho } + fn invmetric(&self, pos: Vec2) -> Mat2 { + let h = self.halfmetric(pos); + transpose(&h.ortho) * diagonal(Vec2::from_s(1.0) / pow2(h.diag)) * h.ortho + } + fn dmetric(&self, pos: Vec2) -> Tens2 { part_deriv(|p| self.metric(p), pos, 1.0e-3) } @@ -141,7 +147,7 @@ mod riemann { fn krist(space: &impl Metric, pos: Vec2) -> Tens2 { // Γ^i_k_l = .5 * g^i^m * (g_m_k,l + g_m_l,k - g_k_l,m) - let g = inverse(&space.metric(pos)); // с верхними индексами + let g = &space.invmetric(pos); // с верхними индексами let d = space.dmetric(pos); let mut ret: Tens2 = [Mat2::zero(); 2]; // ret[i][l][k] = sum((m) => .5f * g[m][i] * (d[k][l][m] + d[l][k][m] - d[m][k][l]))