Skip to content

Vector2/4.Lerp do not always return value2 when amount is 1 #35529

@tannergooding

Description

@tannergooding

Vector2.Lerp(value1, value2, amount) and Vector4.Lerp(value1, value2, amount) are currently implemented as value1 + (value2 - value1) * amount. However, due to floating-point rounding error this will not always return value2 when amount == 1.0f.

These should be updated to use the same algorithm as Vector3.Lerp(value1, value2, amount) which is (value1 * (1.0f - amount)) + (value2 * amount). This algorithm correctly accounts for the rounding error and also allows the algorithm to be freely optimized using FusedMultiplyAdd when available.

Metadata

Metadata

Assignees

Labels

area-System.Numericsbreaking-changeIssue or PR that represents a breaking API or functional change over a previous release.bughelp wanted[up-for-grabs] Good issue for external contributors

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions