8000 Documentation for clearing and updating the scene. · navrobot/robotics-toolbox-python@06c363f · GitHub
[go: up one dir, main page]

Skip to content

Commit 06c363f

Browse files
committed
Documentation for clearing and updating the scene.
1 parent 1a8e0c9 commit 06c363f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

graphics/graphics_grid.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __init_grid(self):
1717
"""
1818
Initialise the grid along the x, y, z axes.
1919
"""
20+
# TODO base off user input?
2021
num_squares = 10 # Length of the grid in each direction (in units)
2122
relative_cam = True # Whether the grid follows the camera rotation and movement
2223

@@ -125,6 +126,14 @@ def __create_grid_objects(self, bool_camera_relative, num_squares):
125126
return grid
126127

127128
def __move_grid_objects(self, bool_camera_relative, num_squares):
129+
"""
130+
Reusing the current assets, move the planes to the new origins.
131+
132+
:param bool_camera_relative: Whether to draw the axes at the camera focus point or at (0, 0, 0).
133+
:type bool_camera_relative: bool
134+
:param num_squares: How many unit squares to draw along the axis.
135+
:type num_squares: int
136+
"""
128137
camera_axes = self.camera_axes
129138
# Locate centre of axes
130139
if bool_camera_relative:
@@ -155,6 +164,7 @@ def __move_grid_objects(self, bool_camera_relative, num_squares):
155164
min_z_coord = z_origin + int(-(num_squares / 2) + (sign(camera_axes.z) * -1) * (num_squares / 2))
156165
max_z_coord = z_origin + int((num_squares / 2) + (sign(camera_axes.z) * -1) * (num_squares / 2))
157166

167+
# Compound origins are in the middle of the bounding boxes. Thus new pos will be between max and min.
158168
x_middle = (max_x_coord + min_x_coord) / 2
159169
y_middle = (max_y_coord + min_y_coord) / 2
160170
z_middle = (max_z_coord + min_z_coord) / 2
@@ -180,9 +190,7 @@ def __move_grid_objects(self, bool_camera_relative, num_squares):
180190
def update_grid(self):
181191
"""
182192
Update the grid axes and numbers if the camera position/rotation has changed.
183-
184193
"""
185-
186194
# Obtain the new camera settings
187195
new_camera_pos = scene.camera.pos
188196
new_camera_axes = scene.camera.axis
@@ -197,6 +205,7 @@ def update_grid(self):
197205
self.camera_axes = new_camera_axes
198206

199207
# Update grid
208+
# TODO base off user input?
200209
num_squares = 10 # Length of the grid in each direction (in units)
201210
relative_cam = True # Whether the grid follows the camera rotation and movement
202211
self.__move_grid_objects(relative_cam, num_squares)

0 commit comments

Comments
 (0)
0