Add a dedicated function for metric inverse
This commit is contained in:
parent
641b13149f
commit
8e943df809
|
|
@ -78,6 +78,7 @@ impl Metric for Coil {
|
||||||
|
|
||||||
mod riemann {
|
mod riemann {
|
||||||
use glm::*;
|
use glm::*;
|
||||||
|
use glm::ext::pow2;
|
||||||
use num_traits::identities::Zero;
|
use num_traits::identities::Zero;
|
||||||
|
|
||||||
pub struct Decomp2 {
|
pub struct Decomp2 {
|
||||||
|
|
@ -95,6 +96,11 @@ mod riemann {
|
||||||
transpose(&h.ortho) * diagonal(h.diag * h.diag) * h.ortho
|
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 {
|
fn dmetric(&self, pos: Vec2) -> Tens2 {
|
||||||
part_deriv(|p| self.metric(p), pos, 1.0e-3)
|
part_deriv(|p| self.metric(p), pos, 1.0e-3)
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +147,7 @@ mod riemann {
|
||||||
|
|
||||||
fn krist(space: &impl Metric, pos: Vec2) -> Tens2 {
|
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)
|
// Γ^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 d = space.dmetric(pos);
|
||||||
let mut ret: Tens2 = [Mat2::zero(); 2];
|
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]))
|
// ret[i][l][k] = sum((m) => .5f * g[m][i] * (d[k][l][m] + d[l][k][m] - d[m][k][l]))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user