Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fNN::lerp #90296

Merged
merged 1 commit into from
Oct 26, 2021
Merged

Remove fNN::lerp #90296

merged 1 commit into from
Oct 26, 2021

Conversation

CAD97
Copy link
Contributor

@CAD97 CAD97 commented Oct 26, 2021

Lerp is surprisingly complex with multiple tradeoffs depending on what guarantees you want to provide (and what you're willing to drop for raw speed), so we don't have consensus on what implementation to use, let alone what signature - t.lerp(a, b) nicely puts a, b together, but makes dispatch to lerp custom types with the same signature basically impossible, and major ecosystem crates (e.g. nalgebra, glam) use a.lerp(b, t), which is easily confusable. It was suggested to maybe provide a Lerp<T> trait and t.lerp([a, b]), which could be implemented by downstream math libraries for their types, but also significantly raises the bar from a simple fNN method to a full trait, and does nothing to solve the implementation question. (It also raises the question of whether we'd support higher-order bezier interpolation.)

The only consensus we have is the lack of consensus, and the general temperature is that we should just remove this method (giving the method space back to 3rd party libs) and revisit this if (and likely only if) IEEE adds lerp to their specification.

If people want a lerp, they're probably already using (or writing) a math support library, which provides a lerp function for its custom math types and can provide the same lerp implementation for the primitive types via an extension trait.

See also previous Zulip discussion

cc @clarfonthey (original PR author), @m-ou-se (original r+), @scottmcm (last voice in tracking issue, prompted me to post this)

Closes #86269 (removed)

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 26, 2021
@rust-log-analyzer

This comment has been minimized.

@m-ou-se
Copy link
Member

m-ou-se commented Oct 26, 2021

This sounds reasonable.

@clarfonthey I'd like to hear your thoughts on this.

@Mark-Simulacrum
Copy link
Member

r=me on the implementation

@clarfonthey
Copy link
Contributor

It's honestly disappointing to see things end up this way but I think I agree for now. If we see a standard IEEE lerp definition then we can add it back in.

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 26, 2021

📌 Commit 6b449b4 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 26, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 26, 2021
Remove fNN::lerp

Lerp is [surprisingly complex with multiple tradeoffs depending on what guarantees you want to provide](rust-lang#86269 (comment)) (and what you're willing to drop for raw speed), so we don't have consensus on what implementation to use, let alone what signature - `t.lerp(a, b)` nicely puts `a, b` together, but makes dispatch to lerp custom types with the same signature basically impossible, and major ecosystem crates (e.g. nalgebra, glium) use `a.lerp(b, t)`, which is easily confusable. It was suggested to maybe provide a `Lerp<T>` trait and `t.lerp([a, b])`, which _could_ be implemented by downstream math libraries for their types, but also significantly raises the bar from a simple fNN method to a full trait, and does nothing to solve the implementation question. (It also raises the question of whether we'd support higher-order bezier interpolation.)

The only consensus we have is the lack of consensus, and the [general temperature](rust-lang#86269 (comment)) is that we should just remove this method (giving the method space back to 3rd party libs) and revisit this if (and likely only if) IEEE adds lerp to their specification.

If people want a lerp, they're _probably_ already using (or writing) a math support library, which provides a lerp function for its custom math types and can provide the same lerp implementation for the primitive types via an extension trait.

See also [previous Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/lerp.20API.20design)

cc `@clarfonthey` (original PR author), `@m-ou-se` (original r+), `@scottmcm` (last voice in tracking issue, prompted me to post this)

Closes rust-lang#86269 (removed)
This was referenced Oct 26, 2021
@scottmcm
Copy link
Member

@clarfonthey This is still something I'd also still like in the abstract to have -- I think it's good functionality -- it's just the semantic and interface uncertainty pushing me this way for now.

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 26, 2021
…askrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#90296 (Remove fNN::lerp)
 - rust-lang#90302 (Remove unneeded into_iter)
 - rust-lang#90303 (Add regression test for issue 90164)
 - rust-lang#90305 (Add regression test for rust-lang#87258)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@clarfonthey
Copy link
Contributor

Yeah, mostly the same opinion. I do hope that in the future we see some widespread standardisation of a lerp operation, considering how ubiquitous it is.

@bors bors merged commit 8871fe8 into rust-lang:master Oct 26, 2021
@rustbot rustbot added this to the 1.58.0 milestone Oct 26, 2021
@CAD97 CAD97 deleted the rip-lerp branch October 26, 2021 23:38
finnbear referenced this pull request in SoftbearStudios/mk48 Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking Issue for fNN::lerp
9 participants