private static bool ContainsOrigin(Simplex s, ref Fix64Vector2 dir) { var a = s.GetLast(); var AO = -a; var b = s.GetB(); var AB = b - a; if (s.Count() == 3) { var c = s.GetC(); var AC = c - a; var abPerp = CalcNomal(AC, AB, AB); var acPerp = CalcNomal(AB, AC, AC); if (Fix64Vector2.Dot(abPerp, AO) > Fix64.Zero) { s.Remove(c); dir = abPerp; } else { if (Fix64Vector2.Dot(acPerp, AO) > Fix64.Zero) { s.Remove(b); dir = acPerp; } else { return(true); } } } else { var abPerp = CalcNomal(AB, AO, AB); dir = abPerp; } return(false); }