Skip to content

Commit aa3df26

Browse files
koolkapmrdoob
authored andcommitted
adding the lerp to Math class mrdoob#9728 (mrdoob#9767)
* adding the lerp to Math class mrdoob#9728 Adding the precise interpolation from point x to y using factor t. * Adding the documentation for Lerp function Adding the lerp in doc support
1 parent dddfcc6 commit aa3df26

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/api/math/Math.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ <h3>[method:Float radToDeg]( [page:Float radians] )</h3>
7575
Converts radians to degrees
7676
</div>
7777

78+
<h3>[method:Float lerp]( [page:Float x], [page:Float y], [page:Float t] )</h3>
79+
<div>
80+
x -- Start point. <br />
81+
y -- End point. <br />
82+
t -- Closed unit interval from [0,1].
83+
</div>
84+
<div>
85+
Returns a value interpolated from two known points based on the interval.<br/><br/>
86+
87+
[link:https://en.wikipedia.org/wiki/Linear_interpolation Wikipedia]
88+
</div>
89+
7890
<h3>[method:Float smoothstep]( [page:Float x], [page:Float min], [page:Float max] )</h3>
7991
<div>
8092
x -- The value to evaluate based on its position between min and max. <br />

src/math/Math.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ _Math = {
7070

7171
},
7272

73+
//https://en.wikipedia.org/wiki/Linear_interpolation
74+
75+
lerp: function( x, y, t ){
76+
77+
return ( 1 - t ) * x + t * y;
78+
},
79+
7380
// http://en.wikipedia.org/wiki/Smoothstep
7481

7582
smoothstep: function ( x, min, max ) {

0 commit comments

Comments
 (0)