Skip to content

Commit 690e7a4

Browse files
committed
Minor PEP8 formatting
1 parent 81aecdb commit 690e7a4

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

graphics/graphics_grid.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, scene):
2121

2222
self.__relative_cam = True
2323
self.__num_squares = 10
24-
self.__scale = 0.5
24+
self.__scale = 1
2525

2626
# Save the current camera settings
2727
self.camera_pos = self.__scene.camera.pos
@@ -75,8 +75,8 @@ 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, 2),\
79-
round(self.__scene.center.y, 2),\
78+
x_origin, y_origin, z_origin = round(self.__scene.center.x, 2), \
79+
round(self.__scene.center.y, 2), \
8080
round(self.__scene.center.z, 2)
8181
self.__focal_point = [x_origin, y_origin, z_origin]
8282
else:
@@ -98,20 +98,20 @@ def __create_grid_objects(self):
9898
# min = -num_squares or 0, around the default position
9999
# max = +num_squares or 0, around the default position
100100
# e.g. at the origin, for negative axes: -10 -> 0, positive axes: 0 -> 10
101-
min_x_coord = x_origin + int(-(self.__num_squares / 2) +
102-
(sign(camera_axes.x) * -1) * (self.__num_squares / 2)) * self.__scale
103-
max_x_coord = x_origin + int((self.__num_squares / 2) +
104-
(sign(camera_axes.x) * -1) * (self.__num_squares / 2)) * self.__scale
101+
min_x_coord = round(x_origin + (-(self.__num_squares / 2) +
102+
(sign(camera_axes.x) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
103+
max_x_coord = round(x_origin + ((self.__num_squares / 2) +
104+
(sign(camera_axes.x) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
105105

106-
min_y_coord = y_origin + int(-(self.__num_squares / 2) +
107-
(sign(camera_axes.y) * -1) * (self.__num_squares / 2)) * self.__scale
108-
max_y_coord = y_origin + int((self.__num_squares / 2) +
109-
(sign(camera_axes.y) * -1) * (self.__num_squares / 2)) * self.__scale
106+
min_y_coord = round(y_origin + (-(self.__num_squares / 2) +
107+
(sign(camera_axes.y) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
108+
max_y_coord = round(y_origin + ((self.__num_squares / 2) +
109+
(sign(camera_axes.y) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
110110

111-
min_z_coord = z_origin + int(-(self.__num_squares / 2) +
112-
(sign(camera_axes.z) * -1) * (self.__num_squares / 2)) * self.__scale
113-
max_z_coord = z_origin + int((self.__num_squares / 2) +
114-
(sign(camera_axes.z) * -1) * (self.__num_squares / 2)) * self.__scale
111+
min_z_coord = round(z_origin + (-(self.__num_squares / 2) +
112+
(sign(camera_axes.z) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
113+
max_z_coord = round(z_origin + ((self.__num_squares / 2) +
114+
(sign(camera_axes.z) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
115115

116116
x_coords = arange(min_x_coord, max_x_coord + self.__scale, self.__scale)
117117
y_coords = arange(min_y_coord, max_y_coord + self.__scale, self.__scale)
@@ -215,20 +215,20 @@ def __move_grid_objects(self):
215215
# min = -num_squares or 0, around the default position
216216
# max = +num_squares or 0, around the default position
217217
# e.g. at the origin, for negative axes: -10 -> 0, positive axes: 0 -> 10
218-
min_x_coord = x_origin + int(-(self.__num_squares / 2) +
219-
(sign(camera_axes.x) * -1) * (self.__num_squares / 2)) * self.__scale
220-
max_x_coord = x_origin + int((self.__num_squares / 2) +
221-
(sign(camera_axes.x) * -1) * (self.__num_squares / 2)) * self.__scale
218+
min_x_coord = round(x_origin + (-(self.__num_squares / 2) +
219+
(sign(camera_axes.x) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
220+
max_x_coord = round(x_origin + ((self.__num_squares / 2) +
221+
(sign(camera_axes.x) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
222222

223-
min_y_coord = y_origin + int(-(self.__num_squares / 2) +
224-
(sign(camera_axes.y) * -1) * (self.__num_squares / 2)) * self.__scale
225-
max_y_coord = y_origin + int((self.__num_squares / 2) +
226-
(sign(camera_axes.y) * -1) * (self.__num_squares / 2)) * self.__scale
223+
min_y_coord = round(y_origin + (-(self.__num_squares / 2) +
224+
(sign(camera_axes.y) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
225+
max_y_coord = round(y_origin + ((self.__num_squares / 2) +
226+
(sign(camera_axes.y) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
227227

228-
min_z_coord = z_origin + int(-(self.__num_squares / 2) +
229-
(sign(camera_axes.z) * -1) * (self.__num_squares / 2)) * self.__scale
230-
max_z_coord = z_origin + int((self.__num_squares / 2) +
231-
(sign(camera_axes.z) * -1) * (self.__num_squares / 2)) * self.__scale
228+
min_z_coord = round(z_origin + (-(self.__num_squares / 2) +
229+
(sign(camera_axes.z) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
230+
max_z_coord = round(z_origin + ((self.__num_squares / 2) +
231+
(sign(camera_axes.z) * -1) * (self.__num_squares / 2)) * self.__scale, 2)
232232

233233
# Compound origins are in the middle of the bounding boxes. Thus new pos will be between max and min.
234234
x_middle = (max_x_coord + min_x_coord) / 2
@@ -358,14 +358,14 @@ def create_line(pos1, pos2, scene, colour=None, thickness=0.01):
358358
colour = [0, 0, 0]
359359

360360
if colour[0] > 1.0 or colour[1] > 1.0 or colour[2] > 1.0 or \
361-
colour[0] < 0.0 or colour[1] < 0.0 or colour[2] < 0.0:
361+
colour[0] < 0.0 or colour[1] < 0.0 or colour[2] < 0.0:
362362
raise ValueError("RGB values must be normalised between 0 and 1")
363363

364364
if thickness < 0.0:
365365
raise ValueError("Thickness must be greater than 0")
366366

367367
# Length of the line using the magnitude
368-
line_len = mag(pos2-pos1)
368+
line_len = mag(pos2 - pos1)
369369

370370
# Position of the line is the midpoint (centre) between the ends
371371
position = (pos1 + pos2) / 2
@@ -411,14 +411,14 @@ def create_segmented_line(pos1, pos2, scene, segment_len, colour=None, thickness
411411
colour = [0, 0, 0]
412412

413413
if colour[0] > 1.0 or colour[1] > 1.0 or colour[2] > 1.0 or \
414-
colour[0] < 0.0 or colour[1] < 0.0 or colour[2] < 0.0:
414+
colour[0] < 0.0 or colour[1] < 0.0 or colour[2] < 0.0:
415415
raise ValueError("RGB values must be normalised between 0 and 1")
416416

417417
if thickness < 0.0:
418418
raise ValueError("Thickness must be greater than 0")
419419

420420
# Length of the line using the magnitude
421-
line_len = mag(pos2-pos1)
421+
line_len = mag(pos2 - pos1)
422422

423423
# Axis direction of the line (to align the box (line) to intersect the two points)
424424
axis_dir = pos2 - pos1
@@ -427,24 +427,24 @@ def create_segmented_line(pos1, pos2, scene, segment_len, colour=None, thickness
427427
# Return a compound of boxes of thin width and height to resemble a dashed line
428428
dash_positions = []
429429
boxes = []
430-
pos1 = pos1 + (axis_dir * segment_len/2) # Translate centre pos to centre of where dashes will originate from
430+
pos1 = pos1 + (axis_dir * segment_len / 2) # Translate centre pos to centre of where dashes will originate from
431431

432432
# Range = number of dashes (vis and invis)
433-
for idx in range(0, int(ceil(line_len / (segment_len / axis_dir.mag)))):
433+
for idx in range(0, int(ceil(line_len / (segment_len / axis_dir.mag)))):
434434
# Add every even point (zeroth, second...) to skip gaps between boxes
435435
if idx % 2 == 0:
436436
dash_positions.append(pos1)
437437
pos1 = (pos1 + axis_dir * segment_len)
438438
# If the axis between points changes, then the line has surpassed the end point. The line is done
439-
check_dir = pos2-pos1
439+
check_dir = pos2 - pos1
440440
check_dir.mag = 1.0
441441
if not vectors_approx_equal(axis_dir, check_dir):
442442
break
443443

444444
for xyz in dash_positions:
445445
length = segment_len
446446
# If the box will surpass the end point
447-
len_to_end = (pos2-xyz).mag
447+
len_to_end = (pos2 - xyz).mag
448448
if len_to_end < segment_len / 2:
449449
# Length is equal to dist to the end * 2 (as pos is middle of box)
450450
length = len_to_end * 2

0 commit comments

Comments
 (0)