10
10
edge_fmt = "{j}a * {b}a_{c}a + {j}{b} * {c}a_aa - {j}{c} * {b}a_aa"
11
11
12
12
# These checks must be negative and not positive, as in the cheat sheet.
13
- # They are the same as in the cheat sheet, except that we consider (...).dot(A) instead of (...).dot(-A)
13
+ # They are the same as in the cheat sheet, except that we consider (...).dot(A)
14
+ # instead of (...).dot(-A)
14
15
plane_tests = ["C.dot (a_cross_b)" , "D.dot(a_cross_c)" , "-D.dot(a_cross_b)" ]
15
16
checks = (
16
17
plane_tests
247
248
def set_test_values (current_tests , test_values , itest , value ):
248
249
def satisfies (values , indices ):
249
250
for k in indices :
250
- if k > 0 and values [k - 1 ] != True :
251
+ if k > 0 and values [k - 1 ] is not True :
251
252
return False
252
- if k < 0 and values [- k - 1 ] != False :
253
+ if k < 0 and values [- k - 1 ] is not False :
253
254
return False
254
255
return True
255
256
@@ -286,17 +287,17 @@ def set_tests_values(current_tests, test_values, itests, values):
286
287
def apply_test_values (cases , test_values ):
287
288
def canSatisfy (values , indices ):
288
289
for k in indices :
289
- if k > 0 and values [k - 1 ] == False :
290
+ if k > 0 and values [k - 1 ] is False :
290
291
return False
291
- if k < 0 and values [- k - 1 ] == True :
292
+ if k < 0 and values [- k - 1 ] is True :
292
293
return False
293
294
return True
294
295
295
296
def satisfies (values , indices ):
296
297
for k in indices :
297
- if k > 0 and values [k - 1 ] != True :
298
+ if k > 0 and values [k - 1 ] is not True :
298
299
return False
299
- if k < 0 and values [- k - 1 ] != False :
300
+ if k < 0 and values [- k - 1 ] is not False :
300
301
return False
301
302
return True
302
303
@@ -337,7 +338,7 @@ def max_number_of_tests(
337
338
prevScore = 0 ,
338
339
):
339
340
for test in current_tests :
340
- assert test_values [test ] == None , "Test " + str (test ) + " already performed"
341
+ assert test_values [test ] is None , "Test " + str (test ) + " already performed"
341
342
342
343
left_cases = apply_test_values (cases , test_values )
343
344
@@ -375,7 +376,8 @@ def max_number_of_tests(
375
376
remaining_tests = None
376
377
377
378
if remaining_tests is not None :
378
- # Do not put this in try catch as I do not want other ValueError to be understood as an infeasible branch.
379
+ # Do not put this in try catch as I do not want other ValueError to be
380
+ # understood as an infeasible branch.
379
381
score_if_t , order_if_t = max_number_of_tests (
380
382
remaining_tests ,
381
383
left_cases ,
@@ -396,7 +398,8 @@ def max_number_of_tests(
396
398
remaining_tests = None
397
399
398
400
if remaining_tests is not None :
399
- # Do not put this in try catch as I do not want other ValueError to be understood as an infeasible branch.
401
+ # Do not put this in try catch as I do not want other ValueError to be
402
+ # understood as an infeasible branch.
400
403
score_if_f , order_if_f = max_number_of_tests (
401
404
remaining_tests ,
402
405
left_cases ,
@@ -438,37 +441,37 @@ def printOrder(order, indent="", start=True, file=sys.stdout, curTests=[]):
438
441
file = file ,
439
442
)
440
443
print (indent + "const vertex_id_t a = 3, b = 2, c = 1, d = 0;" , file = file )
441
- for l in "abcd" :
444
+ for v in "abcd" :
442
445
print (
443
446
indent
444
- + "const Vec3f& {} (current.vertex[{}]->w);" .format (l .upper (), l ),
447
+ + "const Vec3f& {} (current.vertex[{}]->w);" .format (v .upper (), v ),
445
448
file = file ,
446
449
)
447
- print (indent + "const FCL_REAL aa = A.squaredNorm();" .format (l ), file = file )
448
- for l in "dcb" :
450
+ print (indent + "const FCL_REAL aa = A.squaredNorm();" .format (), file = file )
451
+ for v in "dcb" :
449
452
for m in "abcd" :
450
- if m <= l :
453
+ if m <= v :
451
454
print (
452
455
indent
453
456
+ "const FCL_REAL {0}{1} = {2}.dot({3});" .format (
454
- l , m , l .upper (), m .upper ()
457
+ v , m , v .upper (), m .upper ()
455
458
),
456
459
file = file ,
457
460
)
458
461
else :
459
462
print (
460
- indent + "const FCL_REAL& {0}{1} = {1}{0};" .format (l , m ),
463
+ indent + "const FCL_REAL& {0}{1} = {1}{0};" .format (v , m ),
461
464
file = file ,
462
465
)
463
- print (indent + "const FCL_REAL {0}a_aa = {0}a - aa;" .format (l ), file = file )
466
+ print (indent + "const FCL_REAL {0}a_aa = {0}a - aa;" .format (v ), file = file )
464
467
for l0 , l1 in zip ("bcd" , "cdb" ):
465
468
print (
466
469
indent + "const FCL_REAL {0}a_{1}a = {0}a - {1}a;" .format (l0 , l1 ),
467
470
file = file ,
468
471
)
469
- for l in "bc" :
472
+ for v in "bc" :
470
473
print (
471
- indent + "const Vec3f a_cross_{0} = A.cross({1});" .format (l , l .upper ()),
474
+ indent + "const Vec3f a_cross_{0} = A.cross({1});" .format (v , v .upper ()),
472
475
file = file ,
473
476
)
474
477
print ("" , file = file )
@@ -502,15 +505,12 @@ def printOrder(order, indent="", start=True, file=sys.stdout, curTests=[]):
502
505
elif region == "A" :
503
506
print (indent + "originToPoint (current, a, A, next, ray);" , file = file )
504
507
elif len (region ) == 2 :
505
- a = region [0 ]
508
+ region [0 ]
506
509
B = region [1 ]
507
510
print (
508
- indent
509
- + "originToSegment (current, a, {b}, A, {B}, {B}-A, -{b}a_aa, next, ray);" .format (
510
- ** {
511
- "b" : B .lower (),
512
- "B" : B ,
513
- }
511
+ indent + "originToSegment "
512
+ "(current, a, {b}, A, {B}, {B}-A, -{b}a_aa, next, ray);" .format (
513
+ ** {"b" : B .lower (), "B" : B }
514
514
),
515
515
file = file ,
516
516
)
@@ -524,8 +524,8 @@ def printOrder(order, indent="", start=True, file=sys.stdout, curTests=[]):
524
524
else :
525
525
test = "-" + test
526
526
print (
527
- indent
528
- + "originToTriangle (current, a, {b}, {c}, ({B}-A).cross({C}-A), {t}, next, ray);" .format (
527
+ indent + "originToTriangle "
528
+ " (current, a, {b}, {c}, ({B}-A).cross({C}-A), {t}, next, ray);" .format (
529
529
** {"b" : B .lower (), "c" : C .lower (), "B" : B , "C" : C , "t" : test }
530
530
),
531
531
file = file ,
0 commit comments