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
+2 -2
View File
@@ -83,11 +83,11 @@ rotateV r (V2 x y) = V2
{-# INLINE rotateV #-}
-- | Convert degrees to radians
degToRad :: Float -> Float
degToRad d = d * pi / 180
degToRad d = d * pi / 180
{-# INLINE degToRad #-}
-- | Convert radians to degrees
radToDeg :: Float -> Float
radToDeg r = r * 180 / pi
radToDeg r = r * 180 / pi
{-# INLINE radToDeg #-}
-- | Normalize an angle to be between 0 and 2*pi radians
normalizeAngle :: Float -> Float
+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 (*.*.*) #-}