moved shapes and constraints into module directories

This commit is contained in:
Josh Holtrop committed 2011-06-17 12:21:12 -04:00
1 parent 4e70df40e3
commit e398a6e6c8
14 files changed

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
from Constraint import Constraint
class Connect(Constraint):
def __init__(self, shape1, pt1, shape2, pt2):
self.shape1 = shape1
self.pt1 = pt1
self.shape2 = shape2
self.pt2 = pt2
def toEqu(self):
varrefs1 = self.shape1.toEqu(self.pt1)[0]
varrefs2 = self.shape2.toEqu(self.pt2)[0]
coeffs1 = []
for i in range(len(varrefs1)):
coeffs1.append((1 * varrefs1[i], (self.shape1, i)))
for i in range(len(varrefs2)):
coeffs1.append((-1 * varrefs2[i], (self.shape2, i)))
varrefs1 = self.shape1.toEqu(self.pt1)[1]
varrefs2 = self.shape2.toEqu(self.pt2)[1]
coeffs2 = []
for i in range(len(varrefs1)):
coeffs2.append((1 * varrefs1[i], (self.shape1, i)))
for i in range(len(varrefs2)):
coeffs2.append((-1 * varrefs2[i], (self.shape2, i)))
return [(coeffs1, 0), (coeffs2, 0)]
+3
View File
@@ -0,0 +1,3 @@
class Constraint(object):
pass
+9
View File
@@ -0,0 +1,9 @@
from Constraint import Constraint
class Equal(Constraint):
def __init__(self, shape1, pt1, shape2, pt2):
self.shape1 = shape1
self.shape2 = shape2
self.pt1 = pt1
self.pt2 = pt2
+19
View File
@@ -0,0 +1,19 @@
from Constraint import Constraint
class Horizontal(Constraint):
def __init__(self, shape1, pt1, shape2, pt2):
self.shape1 = shape1
self.pt1 = pt1
self.shape2 = shape2
self.pt2 = pt2
def toEqu(self):
varrefs1 = self.shape1.toEqu(self.pt1)[1]
varrefs2 = self.shape2.toEqu(self.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, 0)]
+19
View File
@@ -0,0 +1,19 @@
from Constraint import Constraint
class Vertical(Constraint):
def __init__(self, shape1, pt1, shape2, pt2):
self.shape1 = shape1
self.pt1 = pt1
self.shape2 = shape2
self.pt2 = pt2
def toEqu(self):
varrefs1 = self.shape1.toEqu(self.pt1)[0]
varrefs2 = self.shape2.toEqu(self.pt2)[0]
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, 0)]
+20
View File
@@ -0,0 +1,20 @@
from Constraint import Constraint
class XDistance(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(self.pt1)[0]
varrefs2 = self.shape2.toEqu(self.pt2)[0]
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)]
+15
View File
@@ -0,0 +1,15 @@
from Constraint import Constraint
class XFix(Constraint):
def __init__(self, shape, pt, val):
self.shape = shape
self.pt = pt
self.val = val
def toEqu(self):
varrefs1 = self.shape.toEqu(self.pt)[0]
coeffs = []
for i in range(len(varrefs1)):
coeffs.append((varrefs1[i], (self.shape, i)))
return [(coeffs, self.val)]
+20
View File
@@ -0,0 +1,20 @@
from Constraint import Constraint
class YDistance(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(self.pt1)[1]
varrefs2 = self.shape2.toEqu(self.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)]
+15
View File
@@ -0,0 +1,15 @@
from Constraint import Constraint
class YFix(Constraint):
def __init__(self, shape, pt, val):
self.shape = shape
self.pt = pt
self.val = val
def toEqu(self):
varrefs1 = self.shape.toEqu(self.pt)[1]
coeffs = []
for i in range(len(varrefs1)):
coeffs.append((varrefs1[i], (self.shape, i)))
return [(coeffs, self.val)]
+8
View File
@@ -0,0 +1,8 @@
from Connect import *
from XDistance import *
from YDistance import *
from Horizontal import *
from Vertical import *
from XFix import *
from YFix import *