Browse Source

center function for cartesian grid

Asad M. Zaman 20 years ago
parent
commit
36aba2fd7e
1 changed files with 15 additions and 0 deletions
  1. 15 0
      direct/src/distributed/CartesianGridBase.py

+ 15 - 0
direct/src/distributed/CartesianGridBase.py

@@ -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)
+