packages feed

Vec-Transform 1.0.0 → 1.0.1

raw patch · 2 files changed

+20/−5 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Vec.LinAlg.Transform3D: rotationLookAt :: (Floating a) => Vec3 a -> Vec3 a -> Vec3 a -> Mat44 a

Files

Vec-Transform.cabal view
@@ -1,5 +1,5 @@ name: Vec-Transform-version: 1.0.0+version: 1.0.1 cabal-version: >=1.2.3 build-type: Simple license: BSD3
src/Data/Vec/LinAlg/Transform3D.hs view
@@ -11,6 +11,8 @@ -- | -- Some 4x4 transformation matrices, using a right handed coordinate system. -- These matrices are used by multiplying vectors from the right.+--+-- The projection matrices will produce vectors in a left handed coordinate system, i.e. where z goes into the screen. -----------------------------------------------------------------------------  module Data.Vec.LinAlg.Transform3D (@@ -21,6 +23,7 @@     rotationVec,     rotationEuler,     rotationQuat,+    rotationLookAt,     scaling,     perspective,     orthogonal,@@ -88,14 +91,26 @@                  2*(x*z-y*w), 2*(x*w+y*z), 1-2*x^2-2*y^2, 0,                  0, 0, 0, 1] +-- | A 4x4 rotation matrix for turning toward a point. Useful for targeting a camera to a specific point.+rotationLookAt :: Floating a+               => Vec3 a -- ^ The up direction, not necessary unit length or perpendicular to the view vector+               -> Vec3 a -- ^ The viewers position+               -> Vec3 a -- ^ The point to look at+               -> Mat44 a+rotationLookAt up' pos target = transpose $ homVec left :. homVec up :. homVec forward :. homPoint 0 :. ()+    where+        forward = normalize $ pos - target+        left = normalize $ up' `cross` forward+        up = forward `cross`left+ -- | A 4x4 scaling matrix scaling :: Num a => Vec3 a -> Mat44 a scaling = diagonal . homPoint --- | A perspective projection matrix for a right handed coordinate system looking down negative z+-- | A perspective projection matrix for a right handed coordinate system looking down negative z. This will project far plane to @z = +1@ and near plane to @z = -1@, i.e. into a left handed system. perspective :: Floating a-            => a -- ^ Near plane clipping distance-            -> a -- ^ Far plane clipping distance+            => a -- ^ Near plane clipping distance (always positive)+            -> a -- ^ Far plane clipping distance (always positive)             -> a -- ^ Field of view of the y axis, in radians             -> a -- ^ Aspect ratio, i.e. screen's width\/height             -> Mat44 a@@ -109,7 +124,7 @@         r = aspect*t         l = -r --- | An orthogonal projection matrix for a right handed coordinate system looking down negative z+-- | An orthogonal projection matrix for a right handed coordinate system looking down negative z. This will project far plane to @z = +1@ and near plane to @z = -1@, i.e. into a left handed system. orthogonal :: Fractional a            => a -- ^ Near plane clipping distance            -> a -- ^ Far plane clipping distance