Traity!
This commit is contained in:
parent
a836e7f847
commit
9ce8da5f38
|
|
@ -86,19 +86,39 @@ mod riemann {
|
|||
pub diag: Vec2,
|
||||
}
|
||||
|
||||
impl Decomp2 {
|
||||
fn square(&self) -> Self {
|
||||
Self {
|
||||
ortho: self.ortho,
|
||||
diag: pow2(self.diag),
|
||||
}
|
||||
}
|
||||
|
||||
fn inverse(&self) -> Self {
|
||||
Self {
|
||||
ortho: self.ortho,
|
||||
diag: Vec2::from_s(1.0) / self.diag,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Decomp2> for Mat2 {
|
||||
fn from(value: Decomp2) -> Self {
|
||||
transpose(&value.ortho) * diagonal(value.diag) * value.ortho
|
||||
}
|
||||
}
|
||||
|
||||
type Tens2 = [Mat2; 2];
|
||||
|
||||
pub trait Metric {
|
||||
fn halfmetric(&self, pos: Vec2) -> Decomp2;
|
||||
|
||||
fn metric(&self, pos: Vec2) -> Mat2 {
|
||||
let h = self.halfmetric(pos);
|
||||
transpose(&h.ortho) * diagonal(pow2(h.diag)) * h.ortho
|
||||
self.halfmetric(pos).square().into()
|
||||
}
|
||||
|
||||
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
|
||||
self.halfmetric(pos).square().inverse().into()
|
||||
}
|
||||
|
||||
fn dmetric(&self, pos: Vec2) -> Tens2 {
|
||||
|
|
@ -114,8 +134,7 @@ mod riemann {
|
|||
}
|
||||
|
||||
fn globalize(&self, at: Vec2, v: Vec2) -> Vec2 {
|
||||
let h = self.halfmetric(at);
|
||||
transpose(&h.ortho) * diagonal(Vec2::from_s(1.0) / h.diag) * h.ortho * v
|
||||
Mat2::from(self.halfmetric(at).inverse()) * v
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user