[PR #235] [CLOSED] Core: Lerp overload with custom easing function. #257

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

📋 Pull Request Information

Original PR: https://github.com/ultimatepp/ultimatepp/pull/235
Author: @ismail-yilmaz
Created: 2/18/2025
Status: Closed

Base: masterHead: lerp_iteration


📄 Description

This PR does two things:

  1. Makes the existing Lerp function constexpr and marks it with noexcept
  2. Proposes a Lerp overload that can take 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.

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/235 **Author:** [@ismail-yilmaz](https://github.com/ismail-yilmaz) **Created:** 2/18/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `lerp_iteration` --- ### 📄 Description This PR does two things: 1) Makes the existing Lerp function `constexpr` and marks it with `noexcept` 2) Proposes a Lerp overload that can take 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. 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 2026-05-05 03:44:08 -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#257
No description provided.