Commit c0948289 authored by Hoek, Steven's avatar Hoek, Steven
Browse files

Handling of input in different forms enabled further

parent 5d485fd0
...@@ -47,8 +47,12 @@ class Triangle(object): ...@@ -47,8 +47,12 @@ class Triangle(object):
assert len(self.__points) == 3, "Triangle must have 3 corners!" assert len(self.__points) == 3, "Triangle must have 3 corners!"
# Calculate the centroid by averaging coordinates # Calculate the centroid by averaging coordinates
xc = [pt[0] for pt in self.__points] / 3 if hasattr(self.__points[0], "__len__"):
yc = [pt[1] for pt in self.__points] / 3 xc = sum([pt[0] for pt in self.__points]) / 3
yc = sum([pt[1] for pt in self.__points]) / 3
elif hasattr(self.__points[0], "x") and hasattr(self.__points[0], "y"):
xc = sum([pt.x for pt in self.__points]) / 3
yc = sum([pt.y for pt in self.__points]) / 3
return xc, yc return xc, yc
# TODO: develop this class # TODO: develop this class
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment