简体   繁体   中英

Can I add “labels” to a set of Cartesian coordinates for easier readout?

I have a circular series of 250 Cartesian coordinates that are all equidistant from one another (essentially 250 equally spaced points making up a 360 degree circle), and I'd like to create a program (python, preferably) that assigns a label to each point for easier readout. For instance, (0, 500) could be point number 1, while (0, -500) would be point number 125. I'm having trouble coming up with a coherent means of doing this, though. I briefly considered translating to polar coordinates, but that didn't seem right. I then considered plotting each of the points and manually inputting the translated point for each, but that seems unnecessarily clunky. Any tips on how I can achieve this? Am I going to have to break out my old trigonometry book? Haha

This will print i and the (x, y) coordinate of the points in Python.

import math

n = 250
r = 500
angle = math.pi * 2 / n

for i in range(n):
    x = r * math.cos(angle * i)
    y = r * math.sin(angle * i)
    print(i, x, y)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM