Skip to content

Commit 2b7385d

Browse files
committed
Grid uses two decimal precision on positioning and display
1 parent 95ce5a2 commit 2b7385d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

graphics/graphics_grid.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def __create_grid_objects(self):
7575
camera_axes = self.camera_axes
7676
# Locate centre of axes
7777
if self.__relative_cam:
78-
x_origin, y_origin, z_origin = round(self.__scene.center.x),\
79-
round(self.__scene.center.y),\
80-
round(self.__scene.center.z)
78+
x_origin, y_origin, z_origin = round(self.__scene.center.x, 2),\
79+
round(self.__scene.center.y, 2),\
80+
round(self.__scene.center.z, 2)
8181
self.__focal_point = [x_origin, y_origin, z_origin]
8282
else:
8383
x_origin, y_origin, z_origin = self.__focal_point[0], \
@@ -185,9 +185,9 @@ def __move_grid_objects(self):
185185
camera_axes = self.camera_axes
186186
# Locate centre of axes
187187
if self.__relative_cam:
188-
x_origin, y_origin, z_origin = round(self.__scene.center.x), \
189-
round(self.__scene.center.y), \
190-
round(self.__scene.center.z)
188+
x_origin, y_origin, z_origin = round(self.__scene.center.x, 2), \
189+
round(self.__scene.center.y, 2), \
190+
round(self.__scene.center.z, 2)
191191
self.__focal_point = [x_origin, y_origin, z_origin]
192192
# Convert focal point for 2D rendering. Puts focus point in centre of the view
193193
if not self.__is_3d:

graphics/graphics_text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def update_grid_numbers(focal_point, numbers_list, num_squares, scale, scene):
147147
# X plane
148148
for x_pos in x_coords:
149149
# Draw the corresponding unit number at each x coordinate
150-
txt = str(x_pos)
150+
txt = "{:.2f}".format(x_pos)
151151
pos = vector(x_pos + padding, y_origin + padding, z_origin)
152152
if append:
153153
numbers_list.append(draw_text(txt, pos, scene))
@@ -172,7 +172,7 @@ def update_grid_numbers(focal_point, numbers_list, num_squares, scale, scene):
172172
# Y plane
173173
for y_pos in y_coords:
174174
# Draw the corresponding unit number at each x coordinate
175-
txt = str(y_pos)
175+
txt = "{:.2f}".format(y_pos)
176176
pos = vector(x_origin, y_pos + padding, z_origin + padding)
177177
if append:
178178
numbers_list.append(draw_text(txt, pos, scene))
@@ -197,7 +197,7 @@ def update_grid_numbers(focal_point, numbers_list, num_squares, scale, scene):
197197
# Z plane
198198
for z_pos in z_coords:
199199
# Draw the corresponding unit number at each x coordinate
200-
txt = str(z_pos)
200+
txt = "{:.2f}".format(z_pos)
201201
pos = vector(x_origin, y_origin - padding, z_pos + padding)
202202
if append:
203203
numbers_list.append(draw_text(txt, pos, scene))

0 commit comments

Comments
 (0)