public static Vec2f Clamp(Vec2f x, float min, float max) { return(new Vec2f() { x = MathF.Clamp(x.x, min, max), y = MathF.Clamp(x.y, min, max) }); }
public static Vec2f Clamp(Vec2f x, Vec2f min, Vec2f max) { return(new Vec2f() { x = MathF.Clamp(x.x, min.x, max.x), y = MathF.Clamp(x.y, min.y, max.y) }); }
public static Vec2f Slerp(Vec2f x, Vec2f y, float a) { // Dot product - the cosine of the angle between 2 vectors. var dot = Vec2f.Dot(x, y); // Clamp it to be in the range of Acos() dot = MathF.Clamp(dot, -1.0f, 1.0f); float theta = MathF.Acos(dot) * a; var relativeVec = Vec2f.Normalize(y - x * dot); // Orthonormal basis return((x * MathF.Cos(theta)) + (relativeVec * MathF.Sin(theta))); }
public static float SmoothStep(float edge0, float edge1, float x) { float tmp = MathF.Clamp((x - edge0) / (edge1 - edge0), 0.0f, 1.0f); return(tmp * tmp * (3.0f - 2.0f * tmp)); }