Skip to content

Instantly share code, notes, and snippets.

@shoooe
Created May 2, 2015 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoooe/1298be89c64a371e61de to your computer and use it in GitHub Desktop.
Save shoooe/1298be89c64a371e61de to your computer and use it in GitHub Desktop.
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