Skip to content

Instantly share code, notes, and snippets.

@unixpickle
Created January 7, 2020 22:50
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 unixpickle/568de0e41d915b2cd373562073e47d5e to your computer and use it in GitHub Desktop.
Save unixpickle/568de0e41d915b2cd373562073e47d5e to your computer and use it in GitHub Desktop.
Circle involutes
import math
def involute_point(a, t):
c = math.cos(t)
s = math.sin(t)
d = t - a
return c + d * s, s - d * c
def involute_slope(a, t):
return math.tan(t)
def t_for_y0(a):
assert a < 0
t0 = 0
t1 = math.pi / 2
for _ in range(30):
t = (t0 + t1) / 2
_, y = involute_point(a, t)
if y < 0:
t0 = t
else:
t1 = t
return (t0 + t1) / 2
def a_for_slope_at_y0(m):
a0 = 0
a1 = -10
for _ in range(30):
a = (a0 + a1) / 2
t = t_for_y0(a)
slope = involute_slope(a, t)
if slope < m:
a0 = a
else:
a1 = a
return (a0 + a1) / 2
def a_for_slope_at_y0_2(m):
return math.atan(m) - m
print(t_for_y0(-0.5))
print(involute_slope(-0.5, t_for_y0(-0.5)))
print(a_for_slope_at_y0(1.0))
print(a_for_slope_at_y0_2(math.tan(20*math.pi/180)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment