A simple python script to calculate the coordinates to place nodes around a origin point.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
This is a module used for setting coordinates for | |
networks. | |
""" | |
import math | |
def rotate(origin, point, angle): | |
# This function rotates the point around the | |
# origin at a particular angle | |
ox, oy, oz = origin | |
px, py, pz = point | |
qx = ox + math.cos(angle) * (px - ox) - math.sin(angle) * (py - oy) | |
qy = oy + math.sin(angle) * (px - ox) + math.cos(angle) * (py - oy) | |
return qx, qy, 0 | |
def find_points(origin, n): | |
# Retrieves coordinates of the stations (points) | |
# around a singular Access Point (origin). | |
points = [(origin[0] + 100, origin[1] + 100, origin[2] + 0)] | |
for _ in range(n - 1): | |
points.append(rotate(origin, points[-1], 360 / n)) | |
return points |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment