#pragma once #include "math.hfa" #include //---------------------- Vector Types ---------------------- // TODO: make generic, as per glm struct vec2 { float x, y; }; void ?{}( vec2 & v, float x, float y) { v.[x, y] = [x, y]; } forall( dtype ostype | ostream( ostype ) ) { ostype & ?|?( ostype & os, const vec2& v) with (v) { if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); fmt( os, "<%g,%g>", x, y); return os; } void ?|?( ostype & os, const vec2 v ) { (ostype &)(os | v); ends( os ); } } vec2 ?-?(const vec2& u, const vec2& v) { return [u.x - v.x, u.y - v.y]; } /* //---------------------- Geometric Functions ---------------------- */ /* // These functions implement the Geometric Functions section of GLSL */ static inline float dot(const vec2& u, const vec2& v) { return u.x * v.x + u.y * v.y; } static inline float length(const vec2& v) { return sqrt(dot(v, v)); }