Skip to content

Instantly share code, notes, and snippets.

@triffid
Created July 17, 2012 12:18
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 triffid/3129117 to your computer and use it in GitHub Desktop.
Save triffid/3129117 to your computer and use it in GitHub Desktop.
scissor jack math
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