diff --git a/inc/hgl/math/Vector.h b/inc/hgl/math/Vector.h index 9d44301..04a1ce9 100644 --- a/inc/hgl/math/Vector.h +++ b/inc/hgl/math/Vector.h @@ -106,6 +106,14 @@ namespace hgl return Vector3f(src.x,src.y,z); } + template + inline T clamp(const T &v,const T &min_v,const T &max_v) + { + if(vmax_v)return max_v; + return v; + } + template inline T normalized(const T &v) { @@ -130,6 +138,12 @@ namespace hgl return v1.Dot(v2); } + template + inline float dot2(const T &v) + { + return v.Dot(v); + } + inline float ray_angle_cos(const Ray &ray,const vec &pos) { return ray.dir.Dot((pos-ray.pos).Normalized());