diff --git a/basis/math/matrices/matrices.factor b/basis/math/matrices/matrices.factor index 4a76a20598..8f75cb9442 100644 --- a/basis/math/matrices/matrices.factor +++ b/basis/math/matrices/matrices.factor @@ -122,7 +122,9 @@ IN: math.matrices PRIVATE> -: cross ( vec1 vec2 -- vec3 ) [ [ i ] [ j ] [ k ] 2tri ] keep 3sequence ; +: cross ( vec1 vec2 -- vec3 ) + [ [ { 1 2 1 } vshuffle ] [ { 2 0 0 } vshuffle ] bi* v* ] + [ [ { 2 0 0 } vshuffle ] [ { 1 2 1 } vshuffle ] bi* v* ] 2bi v- ; inline : proj ( v u -- w ) [ [ v. ] [ norm-sq ] bi / ] keep n*v ; diff --git a/basis/math/vectors/vectors.factor b/basis/math/vectors/vectors.factor index 81af5c12d2..63564f064d 100644 --- a/basis/math/vectors/vectors.factor +++ b/basis/math/vectors/vectors.factor @@ -96,6 +96,7 @@ PRIVATE> :: vbroadcast ( u n -- v ) u length n u nth u like ; : vshuffle-elements ( u perm -- v ) + over length 0 pad-tail swap [ '[ _ nth ] ] keep map-as ; : vshuffle-bytes ( u perm -- v )