Skip to content

Instantly share code, notes, and snippets.

@dat-adi
Created December 16, 2022 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dat-adi/e9eec1467e87131e9a6ab33317dcc616 to your computer and use it in GitHub Desktop.
Save dat-adi/e9eec1467e87131e9a6ab33317dcc616 to your computer and use it in GitHub Desktop.
A simple python script to calculate the coordinates to place nodes around a origin point.
#!/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