linear 1.11.2 → 1.11.3
raw patch · 10 files changed
+81/−4 lines, 10 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Linear.Perspective: ortho :: Floating a => a -> a -> a -> a -> a -> a -> M44 a
+ Linear.V: instance (Bounded a, Dim n) => Bounded (V n a)
+ Linear.V0: instance Bounded (V0 a)
+ Linear.V1: instance Bounded a => Bounded (V1 a)
+ Linear.V2: instance Bounded a => Bounded (V2 a)
+ Linear.V3: instance Bounded a => Bounded (V3 a)
+ Linear.V4: instance Bounded a => Bounded (V4 a)
Files
- CHANGELOG.markdown +4/−0
- linear.cabal +1/−1
- src/Linear/Affine.hs +1/−0
- src/Linear/Perspective.hs +39/−3
- src/Linear/V.hs +6/−0
- src/Linear/V0.hs +6/−0
- src/Linear/V1.hs +6/−0
- src/Linear/V2.hs +6/−0
- src/Linear/V3.hs +6/−0
- src/Linear/V4.hs +6/−0
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+1.11.3+------+* Fixed an issue with `UndecidableInstances` on GHC 7.6.3+ 1.11.2 ------ * Added `Linear.Perspective`.
linear.cabal view
@@ -1,6 +1,6 @@ name: linear category: Math, Algebra-version: 1.11.2+version: 1.11.3 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE
src/Linear/Affine.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE RankNTypes #-} #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
src/Linear/Perspective.hs view
@@ -13,6 +13,7 @@ ( lookAt , perspective , infinitePerspective+ , ortho ) where import Control.Lens hiding (index)@@ -23,7 +24,12 @@ import Linear.Metric -- | Build a look at view matrix-lookAt :: (Epsilon a, Floating a) => V3 a -> V3 a -> V3 a -> M44 a+lookAt+ :: (Epsilon a, Floating a)+ => V3 a -- ^ Eye+ -> V3 a -- ^ Center+ -> V3 a -- ^ Up+ -> M44 a lookAt eye center up = V4 (V4 (xa^._x) (xa^._y) (xa^._z) xd) (V4 (ya^._x) (ya^._y) (ya^._z) yd)@@ -37,7 +43,13 @@ zd = dot za eye -- | Build a matrix for a symmetric perspective-view frustum-perspective :: Floating a => a -> a -> a -> a -> M44 a+perspective+ :: Floating a+ => a -- ^ FOV+ -> a -- ^ Aspect ratio+ -> a -- ^ Near plane+ -> a -- ^ Far plane+ -> M44 a perspective fovy aspect near far = V4 (V4 x 0 0 0) (V4 0 y 0 0)@@ -50,7 +62,12 @@ w = -(2 * far * near) / (far - near) -- | Build a matrix for a symmetric perspective-view frustum with a far plane at infinite-infinitePerspective :: Floating a => a -> a -> a -> M44 a+infinitePerspective+ :: Floating a+ => a -- ^ FOV+ -> a -- ^ Aspect Ratio+ -> a -- ^ Near plane+ -> M44 a infinitePerspective fovy aspect near = V4 (V4 x 0 0 0) (V4 0 y 0 0)@@ -64,3 +81,22 @@ x = (2 * near) / (right - left) y = (2 * near) / (top - bottom) w = -2 * near++-- | Build an orthographic perspective matrix from 6 clipping planes+ortho+ :: Floating a+ => a -- ^ Left+ -> a -- ^ Right+ -> a -- ^ Bottom+ -> a -- ^ Top+ -> a -- ^ Near+ -> a -- ^ Far+ -> M44 a+ortho left right bottom top near far =+ V4 (V4 (2 / a) 0 0 (negate ((right + left) / a)))+ (V4 0 (2 / b) 0 (negate ((top + bottom) / b)))+ (V4 0 0 (-2 / c) ((far + near) / c))+ (V4 0 0 0 1)+ where a = right - left+ b = top - bottom+ c = far - near
src/Linear/V.hs view
@@ -292,3 +292,9 @@ instance Each (V n a) (V n b) a b where each = traverse {-# INLINE each #-}++instance (Bounded a, Dim n) => Bounded (V n a) where+ minBound = pure minBound+ {-# INLINE minBound #-}+ maxBound = pure maxBound+ {-# INLINE maxBound #-}
src/Linear/V0.hs view
@@ -226,3 +226,9 @@ instance MonadFix V0 where mfix _ = V0++instance Bounded (V0 a) where+ minBound = V0+ {-# INLINE minBound #-}+ maxBound = V0+ {-# INLINE maxBound #-}
src/Linear/V1.hs view
@@ -263,3 +263,9 @@ instance MonadFix V1 where mfix f = V1 (let V1 a = f a in a)++instance Bounded a => Bounded (V1 a) where+ minBound = pure minBound+ {-# INLINE minBound #-}+ maxBound = pure maxBound+ {-# INLINE maxBound #-}
src/Linear/V2.hs view
@@ -320,3 +320,9 @@ angle :: Floating a => a -> V2 a angle a = V2 (cos a) (sin a)++instance Bounded a => Bounded (V2 a) where+ minBound = pure minBound+ {-# INLINE minBound #-}+ maxBound = pure maxBound+ {-# INLINE maxBound #-}
src/Linear/V3.hs view
@@ -314,3 +314,9 @@ mfix f = V3 (let V3 a _ _ = f a in a) (let V3 _ a _ = f a in a) (let V3 _ _ a = f a in a)++instance Bounded a => Bounded (V3 a) where+ minBound = pure minBound+ {-# INLINE minBound #-}+ maxBound = pure maxBound+ {-# INLINE maxBound #-}
src/Linear/V4.hs view
@@ -341,3 +341,9 @@ (let V4 _ a _ _ = f a in a) (let V4 _ _ a _ = f a in a) (let V4 _ _ _ a = f a in a)++instance Bounded a => Bounded (V4 a) where+ minBound = pure minBound+ {-# INLINE minBound #-}+ maxBound = pure maxBound+ {-# INLINE maxBound #-}