optimization - Optimizing this haskell linear algebra code -
I have this Haskell code to test the collision between size (it depends on linear and lens packages) < / P>
Import Linear Hide (Trace) Import Control. Lens. Gator ((^.)) Type Vec3 = V3 Float Data Triangular = Tri Vec3 Vec3 Vec3 Data Box = Box Vec3 Vec3 - | A Primitive Colloidal Access in 3D Class :: A -> [VAC3] - | Back to all potentially different axes, generalized - | Project of the shape on the general axis, a 1D line segment project :: a -> Vec3 - & gt; (Float, float) intersection :: (colloid A, collide b) => A - & gt; B - & gt; Bull A B = Hesiolap pierces all the axes where axs = axes a ++ axes b - line segments overlap? Overlap (L, R) (L ', R') = L '& lt; = R & amp; Amp; R '& gt; = L isoverlap ax = project an ax 'overlap' project b ax {- # special intersects :: box -> Tri - & gt; Bull # -} Examples are colloid tri where - normal normal and edge normals {- # inline axis # -} axis (triangular quark) = map normal (face: edges) where face = (q ^ - ^ r) `cross' ( S ^ - ^ r) Edges = map (face `cross`) [q ^ - ^ r, r ^ - ^ s, s ^ - ^ q] {- # inline project # -} Project (tri qrs) ax = (Minimum progs, maximum propose) where projs = map (dot ax) [q, r, s] example collide box where {- #inline axes # -} axes _ = base -it axis combine! {- # Inline Project # -} Project (Box AB) ax @ (V3XY) = (minimum LR, maximum LR) - There are 4 possible points depending on the direction of ax - apply only partially x and Y constructor in C 'and D' (C ',' D '). X * y & gt; 0 = (v3 (a ^. _ X) (a ^. Y), v3 (b ^. X) (b ^. Y)) - SIM X and Y | Otherwise = (v3 (a ^. _ X) (b ^ y), v3 (b ^. _ X) (a ^. Y)) - different x and y (c, d). X * z & gt; 0 = (c '(a ^. Z), d' (b ^. Z)) - SIM x and z | Otherwise = (c '(b ^. _z), d' (a ^. Z)) - different x and z (l, r) = (c`dot`h, d`ot`h)
to call -addump-simpl
, but they do not provide any clue. What am I missing?
Comments
Post a Comment