dimforge / dimforge/nalgebra

Certain unit quaternions produce invalid rotation matrices

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

Description

Case in point, take this quaternion:

```rust
let q = UnitQuaternion::new_normalize(Quaternion::new(
0.1045170328727042,
-0.6993398242910853,
0.10451703287270421,
0.6993398242910854,
));
```
then convert it to rotation matrix:
```rust
dbg!(q.to_rotation_matrix());
```

You'll likely get:

```
[
[
-1.6653345369377348e-16,
0.0,
-1.0000000000000002,
],
[
-0.2923716936184902,
-0.9563047593579446,
2.7755575615628914e-17,
],
[
-0.9563047593579445,
0.29237169361849025,
1.6653345369377348e-16,
],
]
```

Notice that the last component of the first row is less than -1. This will create issues (of the NAN variety) if, say, this matrix is then converted to Euler angles.

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.