/* * graphical interfaces */ #include "config.h" #include "interface.h" // the simplest way I could imagine fast enough to find out wether a polygon // is clockwise or ccw could probably be *much* faster // double winding (const points &v) t_no { double wind = 0; points::const_iterator a = v.begin (); points::const_iterator b = a; b++; points::const_iterator c = b; c++; for (;;) { if (c == v.end ()) c = v.begin (); if (b == v.end ()) b = v.begin (); if (a == v.end ()) return wind; vec d = cross (b->v - a->v, c->v - b->v); if (abs (d) > 1e-6) // ignore almost coincident edges wind += normalize (d) * normalize (b->n); ++c; ++b; ++a; } }