public circle(vec2 a, vec2 b, vec2 c) { float det = (a.x - b.x) * (b.y - c.y) - (b.x - c.x) * (a.y - b.y); if (MathExOps.Abs(det) < float.Epsilon) { o = vec2.empty; r = 0f; } else { float offset = b ^ b; float bc = ((a ^ a) - offset) / 2f; float cd = (offset - (c ^ c)) / 2f; float idet = 1f / det; o = new vec2((bc * (b.y - c.y) - cd * (a.y - b.y)) * idet , (cd * (a.x - b.x) - bc * (b.x - c.x)) * idet); r = (a - o).length; } }
public static vec2 Adc(this vec2 v, float th) { return(new vec2(MathExOps.Abs(v.x) < th ? 0 : MathExOps.Sign(v.x), MathExOps.Abs(v.y) < th ? 0 : MathExOps.Sign(v.y))); }
public static bool eq(float a, float b, float eps) => MathExOps.Abs(a - b) <= eps;