Fastest way to sort vectors by angle without actually computing that angle

后端 未结 7 1356
长情又很酷
长情又很酷 2020-12-09 04:19

Many algorithms (e.g. Graham scan) require points or vectors to be sorted by their angle (perhaps as seen from some other point, i.e. using difference vectors). This order i

7条回答
  •  渐次进展
    2020-12-09 04:49

    Just use a cross-product function. The direction you rotate one segment relative to the other will give either a positive or negative number. No trig functions and no division. Fast and simple. Just Google it.

提交回复
热议问题