Created
July 17, 2012 12:18
-
-
Save triffid/3129117 to your computer and use it in GitHub Desktop.
scissor jack math
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
import math | |
### Input variables | |
# distance from end pin to center pin on scissor arm | |
c = 12 | |
# minimum height, when arms are touching | |
a = 3 | |
### calculated variables | |
# c^2 | |
c2 = c ** 2 | |
# maximum height | |
m = math.sqrt(c2 - (a ** 2)) | |
### Utility functions | |
# transform Z position | |
# parameters: | |
# z; requested Z position | |
# returns: | |
# number of units motor must turn from lowest position | |
def z_scissor_transform(z): | |
if ((z + a) > m): | |
raise ValueError("Can't move here!") | |
return (m - math.sqrt(c2 - ((z + a) ** 2))) | |
# get Z delta | |
# paramters: | |
# cz; current Z position | |
# dz; destination Z position | |
# returns: | |
# number of units motor must turn to get from cz to dz. may be negative | |
def z_scissor_delta(cz, dz): | |
return z2steps(dz) - z2steps(cz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment