add clamp and dot2 functions.
This commit is contained in:
parent
a24e522ffe
commit
1ad31f6f6b
@ -106,6 +106,14 @@ namespace hgl
|
|||||||
return Vector3f(src.x,src.y,z);
|
return Vector3f(src.x,src.y,z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T clamp(const T &v,const T &min_v,const T &max_v)
|
||||||
|
{
|
||||||
|
if(v<min_v)return min_v;
|
||||||
|
if(v>max_v)return max_v;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T normalized(const T &v)
|
inline T normalized(const T &v)
|
||||||
{
|
{
|
||||||
@ -130,6 +138,12 @@ namespace hgl
|
|||||||
return v1.Dot(v2);
|
return v1.Dot(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline float dot2(const T &v)
|
||||||
|
{
|
||||||
|
return v.Dot(v);
|
||||||
|
}
|
||||||
|
|
||||||
inline float ray_angle_cos(const Ray &ray,const vec &pos)
|
inline float ray_angle_cos(const Ray &ray,const vec &pos)
|
||||||
{
|
{
|
||||||
return ray.dir.Dot((pos-ray.pos).Normalized());
|
return ray.dir.Dot((pos-ray.pos).Normalized());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user