dimforge / dimforge/nalgebra

The behavior of na::clamp on vectors is strange.

Open
#438 5 comments 1 reaction 0 assignees View on GitHub
enhancement P-medium
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

See also the conversation #434.

It appears the `na::clamp` function is based on the comparison operators which themselves rely on the `PartialOrd` trait. However those comparison operators don't return a sensible value whenever the two vectors being compared are actually not comparable (`partial_cmp` returns `None`).

One solution to avoid confusion is to make it so `na::clamp` works only on scalars, and add a `.clamp` method to the vectors/matrices.

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.