From: Krzysztof Kosiński <tweenk.pl@gm...>  20091231 02:03:52

2009/12/30 bulia byak <buliabyak@...>: > But a still better and more useful approach is to dedect a clockwise > order, as I wrote before. This may not be always easy, but it's an > interesting mathematical challenge. For example: calculate a center > point of objects and rotate clockwise a ray from this center, and > process objects in the order in which this ray crosses their bbox > centers. This is actually rather simple. Compute the center (this may require learning some notperfectlyclear API); for each object calculate the vector from the center to that object's center (let's call it relpos) and sort on Geom::atan2(relpos), for example by inserting the SPItem*s into a std::map<double, SPItem*> and then iterating over it. I'm not sure whether it will produce a clockwise or a counterclockwise ordering, because I never remember which one (desktop / document) is the mathematical one :) Regards, Krzysztof 