Code Monkey home page Code Monkey logo

Comments (4)

sebcrozet avatar sebcrozet commented on June 8, 2024

It looks like the printed isometry matrix is exactly the same as your initialization values?
Can you perhaps detail what value you would expect exactly?

from nalgebra.

JustinLiang avatar JustinLiang commented on June 8, 2024

It looks like the printed isometry matrix is exactly the same as your initialization values? Can you perhaps detail what value you would expect exactly?

So in the first example, the translation values I used as input are 3.7567515671, 6.8521933723, 3.7328615785. But after running the inverse twice I get 3.756751227372396, 6.852192677341882, 3.7328610282357473, here only the first 7 values are the same, ie. 3.756751 which suggest a truncation of f64 -> f32.

For the second example, the same thing is happening but just for the rotation values.

from nalgebra.

sebcrozet avatar sebcrozet commented on June 8, 2024

This the normal behavior of floating point operations. Inversion, axis_angle, as well as from_axis_angle are all subject to rounding errors due to some floating point multiplication and additions (as well as some trigonometry whenever an angle conversion is involved). So what you are seeing are the rounding errors inherent to floats rather than any f64 -> f32 truncation.

from nalgebra.

JustinLiang avatar JustinLiang commented on June 8, 2024

This the normal behavior of floating point operations. Inversion, axis_angle, as well as from_axis_angle are all subject to rounding errors due to some floating point multiplication and additions (as well as some trigonometry whenever an angle conversion is involved). So what you are seeing are the rounding errors inherent to floats rather than any f64 -> f32 truncation.

Hmmm, so when I take the matrix from the isometry matrix and use nalgebra Matrix to inverse I get perfect f64 precision. For example:

    let inv_matrix = isometry
        .to_matrix()
        .try_inverse()
        .expect("Pose cannot be inverted.")
        .try_inverse()
        .expect("Pose cannot be inverted.")
        .transpose();
    let rotation_matrix: Matrix3<f64> = Matrix3::new(inv_matrix[0], inv_matrix[1], inv_matrix[2], inv_matrix[4], inv_matrix[5], inv_matrix[6], inv_matrix[8], inv_matrix[9], inv_matrix[10]);
    let rotation = Rotation3::from_matrix_unchecked(rotation_matrix);
    let translation = Translation3::new(inv_matrix[3], inv_matrix[7], inv_matrix[11]);

    let isometry = IsometryMatrix3::from_parts(translation, rotation);
    
    println!("isometry matrix {:?}", isometry.to_matrix());
>>> isometry matrix [[0.8137976526999999, 0.46984630819999984, -0.34202012419999994, 0.0], [-0.44096961619999986, 0.8825640677999996, 0.16317591069999998, 0.0], [0.3785222768999999, 0.0180282984, 0.9254165291999996, 0.0], [3.756751567099999, 6.8521933722999995, 3.7328615784999997, 1.0]]

Here is how to easily reproduce https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f9f89bde7b9c87a5c27d2f052013e631

from nalgebra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.