dimforge / dimforge/nalgebra

`Rotation3::from_matrix` : Yields improper solution for certain matrices

Open
#1,187 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

Hello, I have found that the `from_matrix` call yields a significantly incorrect result for the following sample input:

```rust
fn test_rotation_matrix() {
let rot = Rotation3::from_matrix(&Matrix3::new(
1.0, 0.0, 0.0,
0.0, -1.0, 0.0,
0.0, 0.0, -1.0,
));
let identity = Rotation3::from_euler_angles(0.0, 0.0, 0.0);
approx::assert_abs_diff_ne!(rot, identity, epsilon = 1e-8);
}
```

Yielding the following error:
```
left = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
right = [[1.0, 0.0, -0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
```

Where I would expect the result:
```
[
[1.0, 0.0, 0.0],
[0.0, -1.0, 0.0],
[0.0, 0.0, -1.0]
]
```

In the meantime I am using `from_matrix_unchecked` to get around this.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.