jpcad/YDistance.py
2011-03-29 14:28:05 -04:00

21 lines
625 B
Python

from Constraint import Constraint
class Horizontal(Constraint):
def __init__(self, shape1, pt1, shape2, pt2, dist):
self.shape1 = shape1
self.pt1 = pt1
self.shape2 = shape2
self.pt2 = pt2
self.dist = dist
def toEqu(self):
varrefs1 = self.shape1.toEqu(pt1)[1]
varrefs2 = self.shape2.toEqu(pt2)[1]
coeffs = []
for i in range(len(varrefs1)):
coeffs.append((-1 * varrefs1[i], (self.shape1, i)))
for i in range(len(varrefs2)):
coeffs.append((1 * varrefs2[i], (self.shape2, i)))
return [(coeffs, self.dist)]