Index: libcfa/src/vec/vec2.hfa
===================================================================
--- libcfa/src/vec/vec2.hfa	(revision d1314805609c325d4e1c48b7a5254a2f1393bcf5)
+++ libcfa/src/vec/vec2.hfa	(revision 3376ec9679544e4a3573e3f6ba122456afec811f)
@@ -1,53 +1,7 @@
 #pragma once
-#include <math.hfa>
-#include <iostream.hfa>
 
-trait zeroassn(otype T) {
-    T ?=?(T&, zero_t);
-};
-trait fromint(otype T) {
-    void ?{}(T&, int);
-};
-trait zero_assign(otype T) {
-    T ?=?(T&, zero_t);
-};
-trait subtract(otype T) {
-    T ?-?(T, T);
-    T -?(T);
-};
-trait add(otype T) {
-    T ?+?(T, T);
-};
-trait multiply(otype T) {
-    T ?*?(T, T);
-};
-trait divide(otype T) {
-    T ?/?(T, T);
-};
-trait lessthan(otype T) {
-    int ?<?(T, T);
-};
-trait equality(otype T) {
-    int ?==?(T, T);
-};
-trait sqrt(otype T) {
-    T sqrt(T);
-};
+#include "vec.hfa"
 
-static inline {
-// int
-int ?=?(int& n, zero_t) { return n = 0.f; }
-/* float */
-void ?{}(float& a, int b) { a = b; }
-float ?=?(float& n, zero_t) { return n = 0.f; }
-/* double */
-void ?{}(double& a, int b) { a = b; }
-double ?=?(double& n, zero_t) { return n = 0L; }
-// long double
-void ?{}(long double& a, int b) { a = b; }
-long double ?=?(long double& n, zero_t) { return n = 0L; }
-}
-
-forall(otype T) {
+forall (otype T) {
     struct vec2 {
         T x, y;
@@ -55,8 +9,7 @@
 }
 
-forall(otype T) {
+
+forall (otype T) {
     static inline {
-
-    // Constructors
 
     void ?{}(vec2(T)& v, T x, T y) {
@@ -98,4 +51,7 @@
         return u;
     }
+    }
+
+    forall(| negate(T)) {
     vec2(T) -?(vec2(T)& v) with (v) {
         return [-x, -y];
@@ -149,4 +105,5 @@
     }
 
+    // Geometric functions
     forall(| add(T) | multiply(T))
     T dot(vec2(T) u, vec2(T) v) {
@@ -154,71 +111,4 @@
     }
 
-    forall(| sqrt(T) | add(T) | multiply(T))
-    T length(vec2(T) v) {
-       return sqrt(dot(v, v));
-    }
-
-    forall(| add(T) | multiply(T))
-    T length_squared(vec2(T) v) {
-       return dot(v, v);
-    }
-
-    forall(| subtract(T) | sqrt(T) | add(T) | multiply(T))
-    T distance(vec2(T) v1, vec2(T) v2) {
-        return length(v1 - v2);
-    }
-
-    forall(| sqrt(T) | divide(T) | add(T) | multiply(T))
-    vec2(T) normalize(vec2(T) v) {
-        return v / sqrt(dot(v, v));
-    }
-
-    // Project vector u onto vector v
-    forall(| sqrt(T) | divide(T) | add(T) | multiply(T))
-    vec2(T) project(vec2(T) u, vec2(T) v) {
-        vec2(T) v_norm = normalize(v);
-        return v_norm * dot(u, v_norm);
-    }
-
-    // Reflect incident vector v with respect to surface with normal n
-    forall(| sqrt(T) | divide(T) | add(T) | multiply(T) | subtract(T) | fromint(T))
-    vec2(T) reflect(vec2(T) v, vec2(T) n) {
-        return v - (T){2} * project(v, n);
-    }
-
-    // Refract incident vector v with respect to surface with normal n
-    // eta is the ratio of indices of refraction between starting material and
-    // entering material (i.e., from air to water, eta = 1/1.33)
-    // v and n must already be normalized
-    forall(| sqrt(T) | add(T) | multiply(T) | subtract(T) | fromint(T) | lessthan(T) | zeroassn(T))
-    vec2(T) refract(vec2(T) v, vec2(T) n, T eta) {
-        T dotValue = dot(n, v);
-        T k = (T){1} - eta * eta * ((T){1} - dotValue * dotValue);
-        if (k < (T){0}) {
-            return 0;
-        }
-        return eta * v - (eta * dotValue + sqrt(k)) * n;
-    }
-
-    // Given a perturbed normal and a geometric normal,
-    // flip the perturbed normal if the geometric normal is pointing away
-    // from the observer.
-    // n is the perturbed vector that we want to align
-    // i is the incident vector
-    // ng is the geometric normal of the surface
-    forall(| add(T) | multiply(T) | lessthan(T) | fromint(T) | subtract(T))
-    vec2(T) faceforward(vec2(T) n, vec2(T) i, vec2(T) ng) {
-        return dot(ng, i) < (T){0} ? n : -n;
-    }
-
-    }
+    } // static inline
 }
-
-forall(dtype ostype, otype T | writeable(T, ostype)) {
-    ostype & ?|?( ostype & os, vec2(T) v) with (v) {
-        return os | '<' | x | ',' | y | '>';
-    }
-    void ?|?( ostype & os, vec2(T) v ) with (v) {
-        (ostype &)(os | v); ends(os);
-    }
-}
