Browse Source

add util to xyz tools

Bastien Sevajol 6 years ago
parent
commit
27a2cfe2b6
1 changed files with 25 additions and 0 deletions
  1. 25 0
      synergine2_xyz/utils.py

+ 25 - 0
synergine2_xyz/utils.py View File

@@ -180,6 +180,31 @@ def get_around_positions_of_positions(position, exclude_start_position=True) ->
180 180
     return points
181 181
 
182 182
 
183
+def get_direct_around_positions_of_position(position, exclude_start_position=True) -> list:
184
+    """
185
+    TODO: compute with z (allow or disable with parameter)
186
+    Return positions around a point with distance of 1 on left/right top/bottom only.
187
+
188
+    :param position: (x, y, z) tuple
189
+    :param exclude_start_position: if True, given position will not be
190
+    added to result list
191
+    :return: list of (x, y, z) positions
192
+    :rtype: list
193
+    """
194
+    pz = position[2]
195
+    px = position[0]
196
+    py = position[1]
197
+    points = [
198
+        (px,   py-1, pz),
199
+        (px-1, py  , pz),
200
+        (px+1, py  , pz),
201
+        (px,   py+1, pz),
202
+    ]
203
+    if not exclude_start_position:
204
+        points.append(position)
205
+    return points
206
+
207
+
183 208
 def get_around_positions_of(
184 209
         position,
185 210
         distance=1,