Mercurial > Kubik
changeset 121:dd9e28e1a97a
merge
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Tue, 08 Jul 2014 20:02:35 +0000 |
| parents | a2551a0ba52a (current diff) e741dc92df48 (diff) |
| children | 7261169ff322 |
| files | |
| diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/kubik.py Mon Jul 07 21:30:33 2014 +0000 +++ b/kubik.py Tue Jul 08 20:02:35 2014 +0000 @@ -59,7 +59,8 @@ # Lengths of leg segments, in mm coxa = 12.5 # between the hip and the knee femur = 30.0 # between the knee and the ankle - tibia = 35.0 # between the ankle and the foot + tibia = 36.0 # between the ankle and the foot + base = 45.0, 45.0 # from the center of body def __init__(self, hip, knee, ankle, hip_offset=0): self.hip = hip @@ -96,6 +97,15 @@ position[i] = self.position[i] self.position = position + def rotate(self, degrees): + """Rotate the leg around the center of the body horizontally.""" + x, y, z = self.position + bx, by = self.base[0] + x, self.base[1] + y + r = _length(bx, by) + x = r * math.cos(math.radians(degrees)) - self.base[0] + y = r * math.sin(math.radians(degrees)) - self.base[1] + self.move_to((x, y, None)) + def update(self): hip, knee, ankle = self._inverse_kinematics(self.position) self.hip.move_degrees(hip)
