Skip to content
Snippets Groups Projects
Commit dbf93557 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

[GJK] Improve GJK::projectTetrahedraOrigin

parent 8b0f94aa
No related branches found
No related tags found
No related merge requests found
......@@ -95,9 +95,14 @@ implications = [
[ [- 8, 9, 12,], [- 10] ],
[ [ 8,- 9,- 12,], [ 10] ],
[ [- 4, 9,- 10,], [- 11,- 12] ],
[ [- 6, 5,- 11,], [- 12,- 10] ],
[ [- 8, 7,- 12,], [- 10,- 11] ],
[ [ 10, 3, 9, -12, 4, -5], [1] ],
[ [ 10, -3, 1, -4], [9] ],
[ [ 10, -3, -1, 2, -6, 11], [5] ],
[ [ -10, 11, 2, -12, -5, -1], [6] ],
[ [ -10,11,-2,1,5], [-6] ],
[ [-10,-11,12,1,-7,-2,4],[-5]],
[ [-10,-11,12,-3,2,7],[-8]],
[ [-10,-11,12,-3,-2],[-1]],
]
def set_test_values (current_tests, test_values, itest, value):
......@@ -128,6 +133,11 @@ def set_test_values (current_tests, test_values, itest, value):
raise ValueError ("Absurd case")
return remaining_tests, next_test_values
def set_tests_values (current_tests, test_values, itests, values):
for itest,value in zip(itests,values):
current_tests, test_values = set_test_values (current_tests, test_values, itest, value)
return current_tests, test_values
def apply_test_values (cases, test_values):
def canSatisfy (values, indices):
for k in indices:
......@@ -229,7 +239,7 @@ def printComments (order, indent, file):
for comment in order['comments']:
print (indent + "// " + comment, file=file)
def printOrder (order, indent = "", start=True,file=sys.stdout):
def printOrder (order, indent = "", start=True,file=sys.stdout,curTests=[]):
if start:
print ("bool GJK::projectTetrahedraOrigin(const Simplex& current, Simplex& next)", file=file)
print ("{", file=file)
......@@ -301,20 +311,22 @@ def printOrder (order, indent = "", start=True,file=sys.stdout):
check = checks[order['test']]
check_hr = checks_hr[order['test']]
printComments (order, indent, file)
nextTests_t=curTests+["a"+str(order['test']+1),]
nextTests_f=curTests+["!a"+str(order['test']+1),]
if order['true'] is None:
if order['false'] is None:
print (indent + """assert(false && "Case {} should never happen.");""".format(check_hr))
else:
print (indent + "assert(!({} <= 0)); // Not {}".format(check, check_hr), file=file)
printOrder (order['false'], indent=indent, start=False, file=file)
print (indent + "assert(!({} <= 0)); // Not {} / {}".format(check, check_hr, ".".join(nextTests_f)), file=file)
printOrder (order['false'], indent=indent, start=False, file=file, curTests=nextTests_f)
elif order['false'] is None:
print (indent + "assert({} <= 0); // {}".format(check, check_hr), file=file)
printOrder (order['true'], indent=indent, start=False, file=file)
print (indent + "assert({} <= 0); // {} / {}".format(check, check_hr, ".".join(nextTests_t)), file=file)
printOrder (order['true'], indent=indent, start=False, file=file, curTests=nextTests_t)
else:
print (indent + "if ({} <= 0) {{ // if {}".format(check, check_hr), file=file)
printOrder (order['true'], indent=indent+" ", start=False, file=file)
print (indent + "}} else {{ // not {}".format(check_hr), file=file)
printOrder (order['false'], indent=indent+" ", start=False, file=file)
print (indent + "if ({} <= 0) {{ // if {} / {}".format(check, check_hr, ".".join(nextTests_t)), file=file)
printOrder (order['true'], indent=indent+" ", start=False, file=file, curTests=nextTests_t)
print (indent + "}} else {{ // not {} / {}".format(check_hr, ".".join(nextTests_f)), file=file)
printOrder (order['false'], indent=indent+" ", start=False, file=file, curTests=nextTests_f)
print (indent + "}} // end of {}".format(check_hr), file=file)
if start:
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment