dimforge / dimforge/nalgebra

na::partial_cmp is incorrect / confusing

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

Was writing some simple code using `nalgebra = "0.32.2"` and came across cases where `partial_cmp` was returning `None`. Is this an actual bug or is there some underlying mathematical "gotcha" where the partial cmp doesn't exist?

```rust
extern crate nalgebra as na;

fn main() {
pub type Pt2 = na::Point2;

// Succeeds
assert!(na::partial_cmp(&Pt2::new(0.0, 0.0), &Pt2::new(0.0, 0.0)).is_some());
assert!(na::partial_cmp(&Pt2::new(0.0, 0.0), &Pt2::new(0.0, 1.0)).is_some());
assert!(na::partial_cmp(&Pt2::new(1.0, 0.0), &Pt2::new(0.0, 0.0)).is_some());

// Fails
assert!(na::partial_cmp(&Pt2::new(1.0, 0.0), &Pt2::new(0.0, 1.0)).is_some());
assert!(na::partial_cmp(&Pt2::new(1.0, 0.0), &Pt2::new(0.0, 2.0)).is_some());
}
```

Edit: looking at the source it seems like it's checking that all axes have the same relationship. This is probably something that should be documented.

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.