geomancy-0.4.1.0 / test / Support / Reference / Vec3.hs
module Support.Reference.Vec3 ( dot , cross , normalize ) whereimport Linear (V3(..))import Linear.Epsilon (Epsilon(..))dot :: Num a => V3 a -> V3 a -> adot (V3 a b c) (V3 d e f) = a * d + b * e + c * fcross :: Num a => V3 a -> V3 a -> V3 across (V3 a b c) (V3 d e f) = V3 (b * f - c * e) (c * d - a * f) (a * e - b * d)normalize :: (Floating a, Epsilon a) => V3 a -> V3 anormalize v = if nearZero q || nearZero (1 - q) then v else fmap (/ l) v where q = dot v v l = sqrt q