@@ -21,7 +21,7 @@ def __init__(self, scene):
21
21
22
22
self .__relative_cam = True
23
23
self .__num_squares = 10
24
- self .__scale = 0.5
24
+ self .__scale = 1
25
25
26
26
# Save the current camera settings
27
27
self .camera_pos = self .__scene .camera .pos
@@ -75,8 +75,8 @@ def __create_grid_objects(self):
75
75
camera_axes = self .camera_axes
76
76
# Locate centre of axes
77
77
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 ), \
80
80
round (self .__scene .center .z , 2 )
81
81
self .__focal_point = [x_origin , y_origin , z_origin ]
82
82
else :
@@ -98,20 +98,20 @@ def __create_grid_objects(self):
98
98
# min = -num_squares or 0, around the default position
99
99
# max = +num_squares or 0, around the default position
100
100
# 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 )
105
105
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 )
110
110
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 )
115
115
116
116
x_coords = arange (min_x_coord , max_x_coord + self .__scale , self .__scale )
117
117
y_coords = arange (min_y_coord , max_y_coord + self .__scale , self .__scale )
@@ -215,20 +215,20 @@ def __move_grid_objects(self):
215
215
# min = -num_squares or 0, around the default position
216
216
# max = +num_squares or 0, around the default position
217
217
# 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 )
222
222
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 )
227
227
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 )
232
232
233
233
# Compound origins are in the middle of the bounding boxes. Thus new pos will be between max and min.
234
234
x_middle = (max_x_coord + min_x_coord ) / 2
@@ -358,14 +358,14 @@ def create_line(pos1, pos2, scene, colour=None, thickness=0.01):
358
358
colour = [0 , 0 , 0 ]
359
359
360
360
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 :
362
362
raise ValueError ("RGB values must be normalised between 0 and 1" )
363
363
364
364
if thickness < 0.0 :
365
365
raise ValueError ("Thickness must be greater than 0" )
366
366
367
367
# Length of the line using the magnitude
368
- line_len = mag (pos2 - pos1 )
368
+ line_len = mag (pos2 - pos1 )
369
369
370
370
# Position of the line is the midpoint (centre) between the ends
371
371
position = (pos1 + pos2 ) / 2
@@ -411,14 +411,14 @@ def create_segmented_line(pos1, pos2, scene, segment_len, colour=None, thickness
411
411
colour = [0 , 0 , 0 ]
412
412
413
413
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 :
415
415
raise ValueError ("RGB values must be normalised between 0 and 1" )
416
416
417
417
if thickness < 0.0 :
418
418
raise ValueError ("Thickness must be greater than 0" )
419
419
420
420
# Length of the line using the magnitude
421
- line_len = mag (pos2 - pos1 )
421
+ line_len = mag (pos2 - pos1 )
422
422
423
423
# Axis direction of the line (to align the box (line) to intersect the two points)
424
424
axis_dir = pos2 - pos1
@@ -427,24 +427,24 @@ def create_segmented_line(pos1, pos2, scene, segment_len, colour=None, thickness
427
427
# Return a compound of boxes of thin width and height to resemble a dashed line
428
428
dash_positions = []
429
429
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
431
431
432
432
# 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 )))):
434
434
# Add every even point (zeroth, second...) to skip gaps between boxes
435
435
if idx % 2 == 0 :
436
436
dash_positions .append (pos1 )
437
437
pos1 = (pos1 + axis_dir * segment_len )
438
438
# 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
440
440
check_dir .mag = 1.0
441
441
if not vectors_approx_equal (axis_dir , check_dir ):
442
442
break
443
443
444
444
for xyz in dash_positions :
445
445
length = segment_len
446
446
# If the box will surpass the end point
447
- len_to_end = (pos2 - xyz ).mag
447
+ len_to_end = (pos2 - xyz ).mag
448
448
if len_to_end < segment_len / 2 :
449
449
# Length is equal to dist to the end * 2 (as pos is middle of box)
450
450
length = len_to_end * 2
0 commit comments