Performance tweaks

This commit is contained in:
2021-09-18 15:38:46 +01:00
parent 2d8f1089a1
commit 80aa67015c
10 changed files with 194 additions and 160 deletions
+12 -14
View File
@@ -12,23 +12,21 @@ infixl 7 *.*.*
{- | 3D coordinate-wise addition. -}
(+.+.+) :: Point3 -> Point3 -> Point3
{-# INLINE (+.+.+) #-}
(+.+.+) = (+)
--(x1, y1, z1) +.+.+ (x2, y2, z2) =
-- let
-- !x = x1 + x2
-- !y = y1 + y2
-- !z = z1 + z2
-- in (x, y, z)
V3 x1 y1 z1 +.+.+ V3 x2 y2 z2 =
let
!x = x1 + x2
!y = y1 + y2
!z = z1 + z2
in V3 x y z
{- | 3D coordinate-wise subtraction. -}
(-.-.-) :: Point3 -> Point3 -> Point3
{-# INLINE (-.-.-) #-}
(-.-.-) = (-)
--(x1, y1, z1) -.-.- (x2, y2, z2) =
-- let
-- !x = x1 - x2
-- !y = y1 - y2
-- !z = z1 - z2
-- in (x, y, z)
V3 x1 y1 z1 -.-.- V3 x2 y2 z2 =
let
!x = x1 - x2
!y = y1 - y2
!z = z1 - z2
in V3 x y z
{- | 3D scalar multiplication. -}
(*.*.*) :: Float -> Point3 -> Point3
{-# INLINE (*.*.*) #-}