Lichtso / geometric_algebra

Generate(d) custom libraries for geometric algebras
MIT License
46 stars 8 forks source link

Implement exponential map for translator #2

Closed jim-ec closed 2 years ago

jim-ec commented 2 years ago

The logarithm of a translator is a line with only degenerate components (e01, e02, e03). I called it an Ideal Line (name is taken from klein) as it is a line at infinity (a translation is a rotation around a line at infinity). The exponential of an Ideal Line is a translator again. Implementing Ln and Exp for Translator and IdealLine allows to write code generic over motor-like types.

#[test]
fn foo() {
    let b = ppga3d:: IdealLine { g0: simd::Simd32x3 {
        f32x3: [1.0, 2.0, 3.0]
    } };

    // A translator by 1 e1 units, 2 e2 units and 3 e3 units.
    let t = b.exp();

    // A translator by 0.5 e1 units, 1 e2 units and 1.5 e3 units.
    let t_half = t.powf(0.5);

    let b_half = t_half.ln();

    unsafe { assert_eq!(
        b_half.g0.f32x3,
        [0.5, 1.0, 1.5]
    ) };
}
Lichtso commented 2 years ago

Sorry for answering late, just saw it, did not receive a notification for some reason.

Anyway, thanks for the contribution. I suspect a similar thing is possible for ppga2d as well, right?