Skip to content

Instantly share code, notes, and snippets.

@Juan-Embid
Created February 23, 2022 10:59
Show Gist options
  • Select an option

  • Save Juan-Embid/43a36665830dcde50901342d8d535e65 to your computer and use it in GitHub Desktop.

Select an option

Save Juan-Embid/43a36665830dcde50901342d8d535e65 to your computer and use it in GitHub Desktop.
Given two points it calculates the value of the new symmetric points at a certain angle
def get_distance(x1, y1, x2, y2):
dist = math.sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2))
def circunference_points(P1, P2, Cx, Cy): #Polar points
P1x = P1 - Cx
dist = get_distance(P1, P2, Cx, Cy)
deg = math.acos(P1x / dist)
C1x = Cx + dist * math.cos((0.785398163397 / 2) + deg) #where 0.785398163397 is 45 degrees in radians
C1y = Cy - dist * math.sin((0.785398163397 / 2) + deg) #you can put what ever angle you want in radians
C2x = Cx + dist * math.cos(deg -(0.785398163397 / 2))
C2y = Cy - dist * math.sin(deg -(0.785398163397 / 2))
return C1x, C1y, C2x, C2y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment