send bilerp upstream to spawn

db4
Joe Groff 2009-05-09 11:43:04 -05:00
parent b0d7e38b2f
commit dd9af334a9
3 changed files with 7 additions and 1 deletions

View File

@ -14,3 +14,5 @@ USING: math.vectors tools.test ;
[ { 1.75 1.75 } ] [ { 1.0 2.5 } { 2.5 1.0 } 0.5 vnlerp ] unit-test
[ { 1.75 2.125 } ] [ { 1.0 2.5 } { 2.5 1.0 } { 0.5 0.25 } vlerp ] unit-test
[ 1.125 ] [ 0.0 1.0 2.0 4.0 { 0.5 0.25 } bilerp ] unit-test

View File

@ -41,6 +41,10 @@ IN: math.vectors
: set-axis ( u v axis -- w )
[ [ zero? 2over ? ] dip swap nth ] map-index 2nip ;
: bilerp ( aa ba ab bb {t,u} -- a_tu )
[ first lerp ] [ second lerp ] bi-curry
[ 2bi@ ] [ call ] bi* ;
: vlerp ( a b t -- a_t )
[ lerp ] 3map ;

View File

@ -155,7 +155,7 @@ TUPLE: terrain-world < world
pixel dim pixel-indices :> indices
indices [ pixels nth COMPONENT-SCALE v. 255.0 / ] map
first4 [ pixel-mantissa first lerp ] 2bi@ pixel-mantissa second lerp ;
first4 pixel-mantissa bilerp ;
: collide ( segment location -- location' )
[ [ first ] [ third ] bi 2array terrain-height-at PLAYER-HEIGHT + ]