Skip to content

Modern Math Lerp

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Math Library › Math Library › Lerp

Lerp

Returns the point a fraction t of the way from a to b; t is not clamped.

Syntax

Lerp( a, b, t )

Examples

#import "std/numeric"
using numeric

'' Linear interpolation: t = 0 gives a, t = 1 gives b
print Lerp( 0.0, 10.0, 0.0 ) '' 0
print Lerp( 0.0, 10.0, 0.5 ) '' 5
print Lerp( 0.0, 10.0, 1.0 ) '' 10

'' t is NOT clamped, so it extrapolates outside 0..1 -- Clamp it first
'' if that is not what you want
print Lerp( 0.0, 10.0, 2.0 ) '' 20

Library: Math Library
Category: Math Library
Documented under: Nothing Becomes A Keyword

Clone this wiki locally