center function for cartesian grid

This commit is contained in:
Asad M. Zaman 2006-03-14 22:58:30 +00:00
parent 7b1d16480f
commit 36aba2fd7e

View File

@ -40,6 +40,8 @@ class CartesianGridBase:
return 2 * (sphereRadius // cellWidth)
def getZoneCellOrigin(self, zoneId):
# It returns the origin of the zoneCell
# Origin is the top-left corner of zoneCell
dx = self.cellWidth * self.gridSize * .5
zone = zoneId - self.startingZone
row = zone // self.gridSize
@ -49,3 +51,16 @@ class CartesianGridBase:
return (x,y,0)
def getZoneCellOriginCenter(self, zoneId):
# Variant of the getZoneCellOrigin. It
# returns the center of the zoneCell
dx = self.cellWidth * self.gridSize * .5
center = self.cellWidth * 0.5
zone = zoneId - self.startingZone
row = zone // self.gridSize
col = zone % self.gridSize
x = col * self.cellWidth - dx + center
y = row * self.cellWidth - dx + center
return (x,y,0)