A geometry-based algorithm for the stability of planar switching systems