Almost working shadows

This commit is contained in:
jgk
2021-06-30 00:35:41 +02:00
parent 3056e6384b
commit 357206f060
6 changed files with 46 additions and 20 deletions
+13 -5
View File
@@ -26,13 +26,13 @@ infixl 7 *.*.*
!z = z1 - z2
in (x, y, z)
{- | 3D scalar multiplication. -}
(*.*.*) :: Point3 -> Point3 -> Point3
(*.*.*) :: Float -> Point3 -> Point3
{-# INLINE (*.*.*) #-}
(x1, y1, z1) *.*.* (x2, y2, z2) =
a *.*.* (x2, y2, z2) =
let
!x = x1 * x2
!y = y1 * y2
!z = z1 * z2
!x = a * x2
!y = a * y2
!z = a * z2
in (x, y, z)
crossProd :: Point3 -> Point3 -> Point3
@@ -48,3 +48,11 @@ rotate3 a (x,y,z) = (x',y',z)
where
(x',y') = rotateV a (x,y)
magV3 :: Point3 -> Float
magV3 (x,y,z) = sqrt $ x^i + y^i + z^i
where
i = 2 :: Int
normalizeV3 :: Point3 -> Point3
normalizeV3 (0,0,0) = (0,0,0)
normalizeV3 p = (1 / magV3 p) *.*.* p