Reputation: 139
I'm trying to make a program that can points and interpolate between them using the Finite difference method. It has to be able to be return xy coordinates so it can be drawn to screen
My Spline class:
class Spline():
def __init__(self):
self.x = 1
self.y = 1
self.p = []
self.l = []
self.s = []
self.Width = 2
self.Color = "#000"
def AddPoints(self,*a):
self.p.append(a)
def DefineCurve(self,*a):
for pp in a:
self.s.append(pp)
def DefineLine(self,*a):
for pp in a:
self.l.append(pp)
def GetSpline(self):
return self.s
def GetLine(self):
tL = []
for a in self.l:
tL.append(self.l[a])
return tL
I'm open to any suggestions
Upvotes: 2
Views: 112
Reputation: 110801
This is not a complete answer - but a primer on Python before you can get started. That said, you should elaborate more specifically your question - it is too broad, and not meaningful out of context as it is.
What do you plan to use to draw it to the screen?
class Spline():
x = 1
y = 1
p = []
l = []
s = []
Width = 2
Color = "#000"
def AddPoints(self,*a):
self.p.append(a)
You are aware that when you declare attributes like this, they are class
attributes that are shared across all instances of this class, aren't you?
To proper declare these as instance attributes, you have to declare then inside a method (and the __init__
method is a nice place)
class Spline():
def __init__(self):
self.x = 1
self.y = 1
self.p = []
self.l = []
self.s = []
self.Width = 2
self.Color = "#000"
def AddPoints(self,*a):
self.p.append(a)
Upvotes: 2