[PR #267] Core: Lerp overload with custom easing function #277

Open
opened 2026-05-05 03:44:39 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ultimatepp/ultimatepp/pull/267
Author: @ismail-yilmaz
Created: 5/6/2025
Status: 🔄 Open

Base: masterHead: lerp_iteration


📝 Commits (2)

  • 55a238c Core: Lerp overload with custom easing function
  • 59c9e5f Merge branch 'ultimatepp:master' into lerp_iteration

📊 Changes

2 files changed (+29 additions, -2 deletions)

View changed files

📝 uppsrc/Core/Util.h (+11 -1)
📝 uppsrc/Core/src.tpp/MathUtil_en-us.tpp (+18 -1)

📄 Description

This PR does two things:

  1. Makes the existing Lerp function constexpr and marks it with noexcept
  2. Proposes a Lerp overload that takes a custom easing function. This easing function can easily be used to achieve different effects, such as bounce-in/bounce-out, ease-in/ease-out, etc. Overload can work with large types (vectors and matrices with properly defined operators)

An example easing function (bounce out) can look like this:

constexpr double BounceOut(double t) noexcept // Piecewise quadratic function to create a bouncing effect.
{
	if(t < 4.0 / 11.0)
		return (121.0 * t * t) / 16.0;
	if(t < 8.0 / 11.0)
		return (363.0 / 40.0 * t * t) - (99.0 / 10.0 * t) + 17.0 / 5.0;
	if(t < 9.0 / 10.0)
		return (4356.0 / 361.0 * t * t) - (35442.0 / 1805.0 * t) + 16061.0 / 1805.0;
	return (54.0 / 5.0 * t * t) - (513.0 / 25.0 * t) + 268.0 / 25.0;
}

This patch does and should not break anything.

P.s.: While the C++17 standard implicity assumes that a constexpr function is hinting inline, I explicitly added them for clarity.

Please review.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ultimatepp/ultimatepp/pull/267 **Author:** [@ismail-yilmaz](https://github.com/ismail-yilmaz) **Created:** 5/6/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `lerp_iteration` --- ### 📝 Commits (2) - [`55a238c`](https://github.com/ultimatepp/ultimatepp/commit/55a238c53c059616af78b13627c9ca405de2fc44) Core: Lerp overload with custom easing function - [`59c9e5f`](https://github.com/ultimatepp/ultimatepp/commit/59c9e5f61f821edc3288a47c1969c366bcdfe65c) Merge branch 'ultimatepp:master' into lerp_iteration ### 📊 Changes **2 files changed** (+29 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `uppsrc/Core/Util.h` (+11 -1) 📝 `uppsrc/Core/src.tpp/MathUtil_en-us.tpp` (+18 -1) </details> ### 📄 Description This PR does two things: 1) Makes the existing Lerp function `constexpr` and marks it with `noexcept` 2) Proposes a Lerp overload that takes a custom easing function. This easing function can easily be used to achieve different effects, such as bounce-in/bounce-out, ease-in/ease-out, etc. Overload can work with large types (vectors and matrices with properly defined operators) An example easing function (bounce out) can look like this: ``` constexpr double BounceOut(double t) noexcept // Piecewise quadratic function to create a bouncing effect. { if(t < 4.0 / 11.0) return (121.0 * t * t) / 16.0; if(t < 8.0 / 11.0) return (363.0 / 40.0 * t * t) - (99.0 / 10.0 * t) + 17.0 / 5.0; if(t < 9.0 / 10.0) return (4356.0 / 361.0 * t * t) - (35442.0 / 1805.0 * t) + 16061.0 / 1805.0; return (54.0 / 5.0 * t * t) - (513.0 / 25.0 * t) + 268.0 / 25.0; } ``` This patch does and should not break anything. P.s.: While the C++17 standard implicity assumes that a constexpr function is hinting inline, I explicitly added them for clarity. Please review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror added the
pull-request
label 2026-05-05 03:44:39 -06:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/ultimatepp#277
No description provided.