Index: libcfa/src/vector.hfa
===================================================================
--- libcfa/src/vector.hfa	(revision 44f41997f4700a1ebb0f2d4e4d0805fe222483da)
+++ libcfa/src/vector.hfa	(revision b545cad6384cb3c61358c407bf1e371892a64b18)
@@ -1,9 +1,8 @@
 #pragma once
-#include "math.hfa"
+#include <math.hfa>
 #include <iostream.hfa>
 
 //---------------------- Vector Types ----------------------
 // TODO: make generic, as per glm
-
 
 struct vec2 {
@@ -21,7 +20,14 @@
         return os;
     }
-    void ?|?( ostype & os, const vec2 v ) {
+    void ?|?( ostype & os, const vec2& v ) {
         (ostype &)(os | v); ends( os );
     }
+}
+
+void ?{}(vec2& vec, zero_t) with (vec) {
+    x = y = 0;
+}
+void ?{}(vec2& vec, vec2& other) with (vec) {
+    [x,y] = other.[x,y];
 }
 
@@ -31,4 +37,7 @@
 vec2 ?*?(const vec2& v, float scalar) with (v) {
     return [x * scalar, y * scalar];
+}
+vec2 ?*?(float scalar, const vec2& v) {
+    return v * scalar;
 }
 vec2 ?/?(const vec2& v, float scalar) with (v) {
@@ -58,2 +67,27 @@
     return v / sqrt(dot(v, v));
 }
+
+// project vector u onto vector v
+static inline vec2 project(const vec2& u, const vec2& v) {
+    vec2 v_norm = normalize(v);
+    return v_norm * dot(u, v_norm);
+}
+
+/* returns the reflection direction : v - 2.0 * project(v, n)
+ * for incident vector v and surface normal n
+ */
+static inline vec2 reflect(const vec2& v, const vec2& n) {
+    return v - 2 * project(v, n);
+}
+
+// incident vector v, surface normal n
+// eta = ratio of indices of refraction between starting material and
+// entering material (i.e., from air to water, eta = 1/1.33)
+static inline vec2 refract(const vec2& v, const vec2& n, float eta) {
+    float dotValue = dot(n, v);
+    float k = 1 - eta * eta * (1 - dotValue * dotValue);
+    if (k < 0) {
+        return 0;
+    }
+    return eta * v - (eta * dotValue + sqrt(k)) * n;
+}
