]> gitweb.factorcode.org Git - factor.git/commitdiff
send bilerp upstream to spawn
authorJoe Groff <arcata@gmail.com>
Sat, 9 May 2009 16:43:04 +0000 (11:43 -0500)
committerJoe Groff <arcata@gmail.com>
Sat, 9 May 2009 16:43:04 +0000 (11:43 -0500)
basis/math/vectors/vectors-tests.factor
basis/math/vectors/vectors.factor
extra/terrain/terrain.factor

index b4b12d619b8c5b17af0f29864c09b292ca0e95dd..968af6a3aa6159fa2956d88a65ebdf906e5d9b95 100644 (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
index eb203a5f12be9372cb01626195715de1d6358e09..17f6c39f044d59e3bc2389d59f1d5e2984d6f274 100644 (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 ;
 
index 083b162c015c4e2ac945407b2611a7741d32d2fb..d58aa4ec30b0d1048c89900b7f52d24933ad5b1c 100644 (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 + ]