Created
May 2, 2015 16:14
-
-
Save shoooe/1298be89c64a371e61de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type alias Unit = Float | |
type Vec2 = Vec2 Unit Unit | |
(|+|) : Vec2 -> Vec2 -> Vec2 | |
(Vec2 ax ay) |+| (Vec2 bx by) = Vec2 (ax + bx) (ay + by) | |
negate : Vec2 -> Vec2 | |
negate (Vec2 x y) = Vec2 (-x) (-y) | |
(|-|) : Vec2 -> Vec2 -> Vec2 | |
v1 |-| v2 = v1 |+| (negate v2) | |
(|*) : Vec2 -> Unit -> Vec2 | |
(Vec2 x y) |* k = Vec2 (x * k) (y * k) | |
(*|) : Unit -> Vec2 -> Vec2 | |
k *| v1 = v1 |* k | |
(|/) : Vec2 -> Unit -> Vec2 | |
(Vec2 x y) |/ k = Vec2 (x * k) (y * k) | |
(/|) : Unit -> Vec2 -> Vec2 | |
k /| v1 = v1 |/ k |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment