AC-Vector 1.1.1 → 1.2.1
raw patch · 4 files changed
+43/−14 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Vector: (*<>) :: (Vector v) => Scalar -> v -> v
+ Data.Vector: (*|) :: (Vector v) => v -> Scalar -> v
+ Data.Vector: (|*) :: (Vector v) => Scalar -> v -> v
+ Data.Vector: vnormalise :: (Vector v) => v -> v
Files
- AC-Vector.cabal +9/−2
- Data/Vector.hs +24/−2
- Licence.txt +0/−10
- License.txt +10/−0
AC-Vector.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: >= 1.6 Name: AC-Vector -Version: 1.1.1 +Version: 1.2.1 Stability: Experimental Synopsis: Efficient geometric vectors. @@ -10,9 +10,16 @@ with @Double@ fields, with seperate types for each size of vector, and a type class for handling vectors generally. + Changes: + + * Operator '*<>' has been renamed '|*' (and there's a + matching '*|' operator now too). + + * There is now a 'vnormalise' function. + Category: Data, Math, Numerical License: BSD3 -License-file: Licence.txt +License-file: License.txt Author: Andrew Coppin Maintainer: MathematicalOrchid@hotmail.com Build-Type: Simple
Data/Vector.hs view
@@ -46,11 +46,33 @@ (length) of the vector, but leaves its length unchanged. (Except in the case of a negative scalar, in which case the vector's direction is reversed.) + + The operators '|*' and '*|' are identical, just with their + arguments flipped. -} -(*<>) :: Vector v => Scalar -> v -> v -s *<> v = vmap (s*) v +(|*) :: Vector v => Scalar -> v -> v +s |* v = vmap (*s) v +{- | + Multiply a vector by a scalar. This scales the magnitude + (length) of the vector, but leaves its length unchanged. + (Except in the case of a negative scalar, in which case + the vector's direction is reversed.) + The operators '*|' and '|*' are identical, just with their + arguments flipped. +-} +(*|) :: Vector v => v -> Scalar -> v +v *| s = vmap (*s) v + +{- | + Adjust a vector so that its length is exactly one. (Or, + if the vector's length was zero, it stays zero.) +-} +vnormalise :: Vector v => v -> v +vnormalise v = + let m = vmag v + in if m < 1e-10 then v else v *| (1/m) {- | The type of 2-dimensional vectors. It provides various
− Licence.txt
@@ -1,10 +0,0 @@-Copyright (c) 2009, Andrew Coppin -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Andrew Coppin nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ License.txt view
@@ -0,0 +1,10 @@+Copyright (c) 2009, Andrew Coppin +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of Andrew Coppin nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.