
W dniu 31 grudnia 2009 10:37 użytkownik Arcadie Cracan <acracan@...400...> napisał:
The use of cross products avoids the division operation, so it is faster.
This is an interactive action that most likely won't be used in batch mode thousands of times, so as long as it takes less than 50ms, it is practically instantaneous to the user. In such a situation, performance should take a back seat to clarity and maintainability.
For example, I used a trivial pairwise nearest neighbor algorithm in the node tool, which is O(n^3), to determine which pairs of nodes should be joined. It's just very unlikely someone is going to regularly join 10,000 nodes in one step. On the other hand, when using a more involved algorithm it is easier to create a non-obvious bug; and other developers will want to read, bugfix or modify my code, so all else equal it makes sense to make life easier for them.
I expect centroid computations to take much more time than the order computation. So all in all, I think the immediate clarity of the atan2 approach is preferable to using less obvious optimized approaches that will not result in any tangible performance gain.
Of course in the end, the implementor decides :)
Regards, Krzysztof