diff --git a/src/grid.py b/src/grid.py --- a/src/grid.py +++ b/src/grid.py @@ -4,7 +4,7 @@ from epoint import EPoint ## Projective transformation of a point with a matrix A. # -# Takes a point as a horizontal vector and multiplies it transposed with A from left. +# Takes a point as a horizontal vector, transposes it and multiplies with A from left. # # @return transformed point as a numpy.array def transformPoint(point,A): @@ -21,11 +21,12 @@ class Grid: # # The result is stored in grid.intersections, a boardSize*boardSize list with [row][column] coordinates. # - # @param corners a properly initialized Corners object. !! Needs a check for the proper initialization. + # @param corners list of EPoints in ABCD order per corners.Corners.canonizeOrder(). + # !! Needs a check for proper initialization. def __init__(self,corners): # ad # bc - a,b,c,d=[c.toProjective() for c in corners.corners] + a,b,c,d=[c.toProjective() for c in corners] p1=numpy.cross(a,b) p2=numpy.cross(c,d) @@ -60,12 +61,12 @@ class Grid: affineIntersection=(rowStart*(boardSize-1-c)+rowEnd*c) / (boardSize-1) self.intersections[r][c]=EPoint.fromProjective(transformPoint(affineIntersection.toProjective(),rectiMatrixInv)) - def stoneSizeAt(self,r,c,sizeCoef): + def stoneSizeAt(self,r,c): intersection=self.intersections[r][c] - if c>0: width=sizeCoef*(intersection.x-self.intersections[r][c-1].x) - else: width=sizeCoef*(self.intersections[r][c+1].x-intersection.x) - if r>0: height=sizeCoef*(intersection.y-self.intersections[r-1][c].y) - else: height=sizeCoef*(self.intersections[r+1][c].y-intersection.y) + if c>0: width=intersection.x - self.intersections[r][c-1].x + else: width=self.intersections[r][c+1].x - intersection.x + if r>0: height=intersection.y - self.intersections[r-1][c].y + else: height=self.intersections[r+1][c].y - intersection.y return (width,height)