dimforge / dimforge/nalgebra

Quaternion's Hash and Eq are incompatible

Open
#583 6 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

`Quaternion` implements `Eq`, but it's `eq` implementation is incompatible with it's `Hash::hash` implementation.

The `eq` implementation considers `w + xi + yj + zk` and `-w - xi - yj - zk` equal because they represent the same rotation, whereas the `hash` implementation does not.

I think the mistake is the `eq` implementation. `-1` is not equal to `1`. These are two different quaternions, that just happen to represent the same rotation, if we use them for that. I think `eq` should be "equal quaternion" instead of "equal rotation". (Just like `Real::two_pi()` should not compare equal to `0.0`, even though they represent the same rotation.)

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.