aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Spear/Math/Vector/Vector.hs3
-rw-r--r--Spear/Math/Vector/Vector2.hs8
-rw-r--r--Spear/Math/Vector/Vector3.hs3
-rw-r--r--Spear/Math/Vector/Vector4.hs3
4 files changed, 16 insertions, 1 deletions
diff --git a/Spear/Math/Vector/Vector.hs b/Spear/Math/Vector/Vector.hs
index e7f6d53..d9cd64f 100644
--- a/Spear/Math/Vector/Vector.hs
+++ b/Spear/Math/Vector/Vector.hs
@@ -48,3 +48,6 @@ class
48 48
49 -- | Normalise the given vector. 49 -- | Normalise the given vector.
50 normalise :: v -> v 50 normalise :: v -> v
51
52 -- | Scale the vector.
53 scale :: Float -> v -> v
diff --git a/Spear/Math/Vector/Vector2.hs b/Spear/Math/Vector/Vector2.hs
index 1ede3a9..b74cfef 100644
--- a/Spear/Math/Vector/Vector2.hs
+++ b/Spear/Math/Vector/Vector2.hs
@@ -33,7 +33,10 @@ type Position2 = Vector2
33 33
34 34
35-- | Represents a vector in 2D. 35-- | Represents a vector in 2D.
36data Vector2 = Vector2 {-# UNPACK #-} !Float {-# UNPACK #-} !Float deriving (Eq, Show) 36data Vector2 = Vector2
37 {-# UNPACK #-} !Float
38 {-# UNPACK #-} !Float
39 deriving (Eq, Show)
37 40
38 41
39instance Addition Vector2 Vector2 where 42instance Addition Vector2 Vector2 where
@@ -129,6 +132,9 @@ instance Vector Vector2 where
129 n = if n' == 0 then 1 else n' 132 n = if n' == 0 then 1 else n'
130 in ((1.0::Float) / n) * v 133 in ((1.0::Float) / n) * v
131 134
135 {-# INLINABLE scale #-}
136 scale s (Vector2 x y) = Vector2 (s*x) (s*y)
137
132 138
133sizeFloat = sizeOf (undefined :: CFloat) 139sizeFloat = sizeOf (undefined :: CFloat)
134 140
diff --git a/Spear/Math/Vector/Vector3.hs b/Spear/Math/Vector/Vector3.hs
index db5dc45..6ad4fe1 100644
--- a/Spear/Math/Vector/Vector3.hs
+++ b/Spear/Math/Vector/Vector3.hs
@@ -163,6 +163,9 @@ instance Vector Vector3 where
163 n = if n' == 0 then 1 else n' 163 n = if n' == 0 then 1 else n'
164 in ((1.0::Float) / n) * v 164 in ((1.0::Float) / n) * v
165 165
166 {-# INLINABLE scale #-}
167 scale s (Vector3 x y z) = Vector3 (s*x) (s*y) (s*z)
168
166 169
167sizeFloat = sizeOf (undefined :: CFloat) 170sizeFloat = sizeOf (undefined :: CFloat)
168 171
diff --git a/Spear/Math/Vector/Vector4.hs b/Spear/Math/Vector/Vector4.hs
index 907295e..3ca27c9 100644
--- a/Spear/Math/Vector/Vector4.hs
+++ b/Spear/Math/Vector/Vector4.hs
@@ -161,6 +161,9 @@ instance Vector Vector4 where
161 n = if n' == 0 then 1 else n' 161 n = if n' == 0 then 1 else n'
162 in ((1.0::Float) / n) * v 162 in ((1.0::Float) / n) * v
163 163
164 {-# INLINABLE scale #-}
165 scale s (Vector4 x y z w) = Vector4 (s*x) (s*y) (s*z) (s*w)
166
164 167
165sizeFloat = sizeOf (undefined :: CFloat) 168sizeFloat = sizeOf (undefined :: CFloat)
166 169