Start work on crafting/combinations
This commit is contained in:
+10
-3
@@ -108,10 +108,17 @@ vNormal (V2 x y) = V2 y (negate x)
|
||||
vInverse :: Point2 -> Point2
|
||||
vInverse (V2 x y) = V2 (-x) (-y)
|
||||
{- | Normalize a vector safely: on (0,0) return (0,0). -}
|
||||
safeNormalizeV :: Point2 -> Point2
|
||||
squashNormalizeV :: Point2 -> Point2
|
||||
{-# INLINE squashNormalizeV #-}
|
||||
squashNormalizeV p
|
||||
| magV p == 0 = V2 0 0
|
||||
| otherwise = (1/magV p ) *.* p
|
||||
{- | Normalize a vector safely: on (0,0) return Nothing. -}
|
||||
safeNormalizeV :: Point2 -> Maybe Point2
|
||||
{-# INLINE safeNormalizeV #-}
|
||||
safeNormalizeV (V2 0 0) = V2 0 0
|
||||
safeNormalizeV p = (1/magV p ) *.* p
|
||||
safeNormalizeV p
|
||||
| magV p == 0 = Nothing
|
||||
| otherwise = Just $ (1/magV p ) *.* p
|
||||
{- | Magnitude of a vector. -}
|
||||
magV :: Point2 -> Float
|
||||
{-# INLINE magV #-}
|
||||
|
||||
Reference in New Issue
Block a user