Skip to content

Instantly share code, notes, and snippets.

@GGLinnk
Last active April 28, 2022 01:47
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 GGLinnk/7f67f3c08a01543cc9e45bf63eb3e1b3 to your computer and use it in GitHub Desktop.
Save GGLinnk/7f67f3c08a01543cc9e45bf63eb3e1b3 to your computer and use it in GitHub Desktop.
Python Maths : Calculate the distance of two points from polar coordinates (angle and distance from point 0).
import math
def polar_distance(self, distance: float, distance_cmp: float, angle: float, angle_cmp: float):
p1 = distance
p2 = distance_cmp
a = math.cos(angle_cmp - angle)
return math.sqrt(p1 ** 2 + p2 ** 2 - 2 * p1 * p2 * a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment