3 Some simple geometry shape helpers. 10 It tries to acts as a collection and a number. 18 return "Point(%s)" % s
33 return self._coords.__iter__()
36 return Point(*[
abs(a)
for a
in self])
40 return Point(*[(a-b)
for a,b
in zip(self, other)])
42 return Point(*[(a-other)
for a
in self])
46 return Point(*[(a+b)
for a,b
in zip(self, other)])
48 return Point(*[(a+other)
for a
in self])
52 return Point(*[(a*b)
for a,b
in zip(self, other)])
54 return Point(*[(a*other)
for a
in self])
58 return Point(*[(a/b)
for a,b
in zip(self, other)])
60 return Point(*[(a/other)
for a
in self])
63 return sum([a*b
for a,b
in zip(self, other)])
67 return math.sqrt(self.
dot(self))
104 A pair of N-D vectors, each represented by an N-D Point 111 return "%s -> %s" % (self.
tail, self.
head)
122 return self.vector.unit
129 def __init__(self, width, height, center = Point2D(0.0, 0.0)):
137 self.center.y - 0.5*self.
height);
140 return point2d - self.
center 148 Return a vector that takes point along direction to the nearest edge. 155 xdir = d1.dot((1.0, 0.0))
156 xsign = xdir/
abs(xdir)
157 ydir = d1.dot((0.0, 1.0))
158 ysign = ydir/
abs(ydir)
162 dx = xsign*corn.x - p1.x
163 dy = ysign*corn.y - p1.y
def relative(self, point2d)
def __init__(self, coords)
def __init__(self, width, height, center=Point2D(0.0, 0.0))
def __setitem__(self, key, val)
def __getitem__(self, key)
def toedge(self, point, direction)
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
def inside(self, point2d)
def __init__(self, tail, head)