How can I create a 3d object/class in Python? -
How can I create a 3d object/class in Python? -
my end goal right take points read text file, , turn them 3d objects. not need visualized, need stored in objects instead of string containing x, y, , z values. file gives me 6 numbers, 2 of each x, y, , z, , wondering how go creating point class/object take 3 variables , line object/class take 2 of points.
just define point
, line
class:
class point(object): def __init__(self, x=0, y=0 ,z=0): self.x = x self.y = y self.z = z class line(object): def __init__(self, point1=none, point2=none): self.point1 = point1 or point() # (0,0,0) default self.point2 = point2 or point() # (0,0,0) default
to create points , lines objects:
>>> p1 = point(1, 2, 3) >>> p2 = point(4, 5, 6) >>> line = line(p1, p2)
python 3d
Comments
Post a Comment