安排坐标转换为顺时针顺序 [英] Arranging coordinates into clockwise order

查看:187
本文介绍了安排坐标转换为顺时针顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有9的屏幕坐标,每个重presenting 9个位置。在页面的右上角,我想那个位置开始的第一个位置,下面顺时针坐标重新present第二,第三,第四等,直到9日,这将是左上角的坐标。

I have 9 screen coordinates, each representing one of 9 positions. From the top right, I want that position to start as the 1st position, and the following clockwise coordinates to represent the 2nd, 3rd, 4th and so on, up until the 9th, which would be the top left coordinate.

会有人在这里能想出某种确定其中9坐标是哪个位置的数学方法?他们都彼此相对,并且相互之间总是会。

Would anybody here be able to come up with some sort of mathematical means of determining which of the 9 coordinates is in which position? They're all relative to each other, and will always be THAT relative to each other.

例坐标可能是:

(x,y)
X   Y
663 382
543 454
303 454
183 382
418 459
543 209
303 209
653 259
183 259

绘制成图像是这样的:

Plotting into an image something like:

会有人有什么想法?我只是想某种形式的上市按顺时针顺序这些坐标的编程方式...

Would anybody have any ideas? I simply want some form of programmatic way of listing these coordinates in clockwise order...

推荐答案

找到圈子,即平均X和平均Y的中心

Find the center of the "circle," i.e., the average X and average Y

移位的X和Y值,以便所有都相对于新的中心

Shift the X and Y values so all are relative to the new center.

转换到极坐标和排序的角度。

Convert to polar coordinates and sort by angle.

这篇关于安排坐标转换为顺时针顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆