Table of Contents

Method Wlerp01

Namespace
Gamelogic.Extensions
Assembly
Gamelogic.Extensions.dll

Wlerp01(float, float, float)

Linearly interpolates between two values between 0 and 1 if values wrap around from 1 back to 0.

public static float Wlerp01(float v1, float v2, float t)

Parameters

v1 float

The first value in [0, 1).

v2 float

The second value in [0, 1).

t float

The interpolation factor.

Returns

float

The wrapped linear interpolation between v1 and v2.

Examples

float angleInRad1 = 1;
float angleInRad2 = 5;
float revolution = Mathf.PI * 2;
float interpolation = WLerp(angleInRad1 / revolution, angleInRad2 / revolution, 0.5f);

//interpolation == (5 + 1 + Mathf.PI * 2)/2 = 3 + Mathf.PI

Remarks

This is useful, for example, in lerping between angles.