]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/3d-matrix-scalar/3d-matrix-scalar.factor
factor: trim more using lists.
[factor.git] / extra / benchmark / 3d-matrix-scalar / 3d-matrix-scalar.factor
1 USING: kernel math math.matrices math.matrices.extras
2 math.order math.vectors prettyprint sequences ;
3 IN: benchmark.3d-matrix-scalar
4
5 :: p-matrix ( dim fov near far -- matrix )
6     dim dup first2 min v/n fov v*n near v*n
7     near far <frustum-matrix4> ;
8
9 :: mv-matrix ( pitch yaw location -- matrix )
10     { 1.0 0.0 0.0 } pitch <rotation-matrix4>
11     { 0.0 1.0 0.0 } yaw   <rotation-matrix4>
12     location vneg <translation-matrix4> mdot mdot ;
13
14 :: 3d-matrix-scalar-benchmark ( -- )
15     f :> result!
16     100000 [
17         { 1024.0 768.0 } 0.7 0.25 1024.0 p-matrix :> p
18         3.0 1.0 { 10.0 -0.0 2.0 } mv-matrix :> mv
19         mv p mdot result!
20     ] times
21     result . ;
22
23 MAIN: 3d-matrix-scalar-benchmark