--- /dev/null
+// vector provides a Vec type and methods for performing vector arithmetic
+package vector
+
+// 3 dimensional vector
+type Vec struct {
+ X, Y, Z float64
+}
+
+// Cross returns the cross product between vectors v and o
+func (v Vec) Cross(o Vec) Vec {
+ return Vec{v.Y*o.Z - v.Z*o.Y, v.Z*o.X - v.X*o.Z, v.X*o.Y - v.Y*o.X}
+}
+
+// Doc returns the dot product between vectors v and o
+func (v Vec) Dot(o Vec) float64 {
+ return v.X*o.X + v.Y*o.Y + v.Z*o.Z
+}
+
+// sub subtracts o from v
+func (v Vec) Sub(o Vec) Vec {
+ return Vec{v.X - o.X, v.Y - o.Y, v.Z - o.Z}
+}