Last active
December 10, 2021 19:44
-
-
Save timrprobocom/5ac261f5004fb122965e08420a596c97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import math | |
def polar_add( v1, v2 ): | |
dtheta = v2[1]-v1[1] | |
r = math.sqrt( v1[0]**2 + v2[0]**2 + 2*v1[0]*v2[0]* math.cos(dtheta) ) | |
theta = v1[1] + math.atan2( | |
v2[1] * math.sin(dtheta), | |
v1[1] + v2[1]*math.cos(dtheta) | |
) | |
return (r, theta ) | |
inpoints = [ | |
( 12, math.pi/6 ), | |
( 23, math.pi/4 ) | |
] | |
def convert_points( inpts ): | |
outpts = [inpts[0]] | |
for pt in inpts[1:]: | |
outpts.append( polar_add( outpts[-1], pt ) ) | |
return outpts | |
print(convert_points(inpoints)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment