dimforge / dimforge/nalgebra

euler_angles_ordered returns surprising results on gimbal lock (strange sign)

Open
#1,482 0 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

Consider the following example:

```rust
Rotation3::from_euler_angles(0., -90f64.to_radians(), 45f64.to_radians())
.euler_angles_ordered(
[
UnitVector3::new_normalize(Vector3::z()),
UnitVector3::new_normalize(Vector3::y()),
UnitVector3::new_normalize(Vector3::x()),
],
false,
)
```

The expected result is:

```rust
([0.7853981633974483, -1.5707963267948966, 0.0], false)
```

However, the actual result is:

```rust
([-0.7853981633974483, -1.5707963267948966, 0.0], false)
```

Notice the yaw sign is inverted.

Outside gimbal lock (so at pitch = -89.9 for example), the sign is as expected, so there's a weird discontinuity here.

At apex gimbal lock (so pitch = 90.0) the angle is also as expected.

It seems the yaw is multiplied redundantly by the sign of the pitch here.

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.