Skip to content

Instantly share code, notes, and snippets.

@woniesong92
Created November 13, 2014 05:38
Show Gist options
  • Save woniesong92/c7f79c812f1ae8be21f5 to your computer and use it in GitHub Desktop.
Save woniesong92/c7f79c812f1ae8be21f5 to your computer and use it in GitHub Desktop.
from math import sqrt
#x1 = X1 = midpt1.x
#x2 = X2 = midpt2.x
def getT(x, x1, x2):
x0 = 0.0 # origin
out1 = ((2.0 * x0 - x1) + sqrt(((-2.0 * x0 + x1) ** 2.0) - ((4 * (x0 - 2.0 * x1 + x2)) * (x0 - x)))) / (2.0 * (x0 - 2.0 * x1 + x2))
out2 = ((2.0 * x0 - x1) - sqrt(((-2.0 * x0 + x1) ** 2.0) - ((4 * (x0 - 2.0 * x1 + x2)) * (x0 - x)))) / (2.0 * (x0 - 2.0 * x1 + x2))
return (out1, out2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment