Created
July 22, 2020 20:51
-
-
Save sibelius/59ca7d9af7388a2e92870c3bb1035992 to your computer and use it in GitHub Desktop.
Thales theorem function and inverted
This file contains 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
/* | |
a = minProgress | |
b = minResult | |
c = maxProgress | |
d = maxResult | |
x = result | |
y = progress | |
y = (-ad + ax + bc - cx) / (b - d) | |
x = (ad - bc + by - dy) / (a - c) | |
https://www.wolframalpha.com/input/?i=(x-a)%2F(y-b)+%3D+(c-x)%2F(d-y),+solve+to+y | |
*/ | |
export const thalesTheorem = ( | |
minProgress: number, | |
maxProgress: number, | |
minResult: number, | |
maxResult: number, | |
result: number, | |
) => ( | |
(-minProgress * maxResult + minProgress * result + minResult * maxProgress - maxProgress * result) | |
/ (minResult - maxResult) | |
); | |
export const thalesTheoremInverted = ( | |
minProgress: number, | |
maxProgress: number, | |
minResult: number, | |
maxResult: number, | |
progress: number, | |
) => ( | |
(minProgress * maxResult - minResult * maxProgress + minResult * progress - maxResult * progress) | |
/ (minProgress - maxProgress) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment