12345678910111213141516171819202122232425(* Claude Code
*
* Copyright (C) 2026 Yoann Padioleau
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* (LGPL) as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*)(* See Vec2.mli *)typet=float*floatletadd((ax,ay):t)((bx,by):t):t=(ax+.bx,ay+.by)letsub((ax,ay):t)((bx,by):t):t=(ax-.bx,ay-.by)letscale(s:float)((x,y):t):t=(s*.x,s*.y)letdot((ax,ay):t)((bx,by):t):float=(ax*.bx)+.(ay*.by)letcross((ax,ay):t)((bx,by):t):float=(ax*.by)-.(ay*.bx)letperp((x,y):t):t=(-.y,x)letlength((x,y):t):float=Float.hypotxyletnormalize(v:t):t=letn=lengthvinifn=0.thenvelsescale(1./.n)v