add vars array to Line and Circle for solver

This commit is contained in:
Josh Holtrop 2011-03-28 16:22:25 -04:00
parent 4932447df9
commit cc3831e235
2 changed files with 33 additions and 5 deletions

View File

@ -1,3 +1,22 @@
class Circle(Shape): class Circle(Shape):
pass def __init__(self, x, y, r):
self.vars = [x, y, r]
def nVars(self):
return len(self.vars)
def nPts(self):
return 5
def toEqu(self, ptNum):
if ptNum == 0:
return ([1, 0, 0], [0, 1, 0])
elif ptNum == 1:
return ([1, 0, 1], [0, 1, 0])
elif ptNum == 2:
return ([1, 0, 0], [0, 1, 1])
elif ptNum == 3:
return ([1, 0, -1], [0, 1, 0])
elif ptNum == 4:
return ([1, 0, 0], [0, 1, -1])

17
Line.py
View File

@ -1,7 +1,16 @@
class Line(Shape): class Line(Shape):
def __init__(self, x0, y0, x1, y1): def __init__(self, x0, y0, x1, y1):
self.x0 = x0 self.vars = [x0, y0, x1, y1]
self.y0 = y0
self.x1 = x1 def nVars(self):
self.y1 = y1 return len(self.vars)
def nPts(self):
return 3
def toEqu(self, ptNum):
if ptNum == 0:
return ([1, 0, 0, 0], [0, 1, 0, 0])
elif ptNum == 1:
return ([0, 0, 1, 0], [0, 0, 0, 1])