math.matrices: move normal word from gpu.demos.bunny and reverse sign
parent
cdb52119a0
commit
3dbb8e6153
|
@ -103,7 +103,7 @@ USING: math.matrices math.vectors tools.test math ;
|
|||
[ { 1 0 0 } ] [ { 0 1 0 } { 0 0 1 } cross ] unit-test
|
||||
[ { 0 1 0 } ] [ { 0 0 1 } { 1 0 0 } cross ] unit-test
|
||||
[ { 0.0 -0.707 0.707 } ] [ { 1.0 0.0 0.0 } { 0.0 0.707 0.707 } cross ] unit-test
|
||||
|
||||
[ { 0 -2 2 } ] [ { -1 -1 -1 } { 1 -1 -1 } cross ] unit-test
|
||||
[ { 1 0 0 } ] [ { 1 1 0 } { 1 0 0 } proj ] unit-test
|
||||
|
||||
[ { { 4181 6765 } { 6765 10946 } } ]
|
||||
|
|
|
@ -114,6 +114,9 @@ IN: math.matrices
|
|||
[ [ { 1 2 0 } vshuffle ] [ { 2 0 1 } vshuffle ] bi* v* ]
|
||||
[ [ { 2 0 1 } vshuffle ] [ { 1 2 0 } vshuffle ] bi* v* ] 2bi v- ; inline
|
||||
|
||||
:: normal ( vec1 vec2 vec3 -- vec4 )
|
||||
vec2 vec1 v- vec3 vec1 v- cross normalize ; inline
|
||||
|
||||
: proj ( v u -- w )
|
||||
[ [ v. ] [ norm-sq ] bi / ] keep n*v ;
|
||||
|
||||
|
|
|
@ -616,10 +616,14 @@ STRUCT: simd-struct
|
|||
|
||||
! Test cross product
|
||||
[ float-4{ 0.0 0.0 1.0 0.0 } ] [ float-4{ 1.0 0.0 0.0 0.0 } float-4{ 0.0 1.0 0.0 0.0 } cross ] unit-test
|
||||
[ float-4{ 0.0 0.0 1.0 0.0 } ] [ float-4{ 1.0 0.0 0.0 0.0 } float-4{ 0.0 1.0 0.0 0.0 } [ { float-4 float-4 } declare cross ] compile-call ] unit-test
|
||||
[ float-4{ 0.0 -1.0 0.0 0.0 } ] [ float-4{ 1.0 0.0 0.0 0.0 } float-4{ 0.0 0.0 1.0 0.0 } cross ] unit-test
|
||||
[ float-4{ 0.0 -1.0 0.0 0.0 } ] [ float-4{ 1.0 0.0 0.0 0.0 } float-4{ 0.0 0.0 1.0 0.0 } [ { float-4 float-4 } declare cross ] compile-call ] unit-test
|
||||
|
||||
[ double-4{ 0.0 0.0 1.0 0.0 } ] [ double-4{ 1.0 0.0 0.0 0.0 } double-4{ 0.0 1.0 0.0 0.0 } cross ] unit-test
|
||||
[ double-4{ 0.0 0.0 1.0 0.0 } ] [ double-4{ 1.0 0.0 0.0 0.0 } double-4{ 0.0 1.0 0.0 0.0 } [ { double-4 double-4 } declare cross ] compile-call ] unit-test
|
||||
[ double-4{ 0.0 -1.0 0.0 0.0 } ] [ double-4{ 1.0 0.0 0.0 0.0 } double-4{ 0.0 0.0 1.0 0.0 } cross ] unit-test
|
||||
[ double-4{ 0.0 -1.0 0.0 0.0 } ] [ double-4{ 1.0 0.0 0.0 0.0 } double-4{ 0.0 0.0 1.0 0.0 } [ { double-4 double-4 } declare cross ] compile-call ] unit-test
|
||||
|
||||
! CSSA bug
|
||||
[ 4000000 ] [
|
||||
|
|
|
@ -119,10 +119,6 @@ UNIFORM-TUPLE: loading-uniforms
|
|||
100000 <uint-vector>
|
||||
(parse-bunny-model) ; inline
|
||||
|
||||
:: normal ( a b c -- normal )
|
||||
c a v-
|
||||
b a v- cross normalize ; inline
|
||||
|
||||
:: calc-bunny-normal ( a b c vertexes -- )
|
||||
a b c [ vertexes nth vertex>> ] tri@ normal :> n
|
||||
a b c [ vertexes nth [ n v+ ] change-normal drop ] tri@ ; inline
|
||||
|
|
Loading…
Reference in New Issue