|
|
|
@ -41,12 +41,13 @@ static inline bool approx (float a, float b) |
|
|
|
|
int |
|
|
|
|
main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
TripleDistances default_axis_distances{1.f, 1.f}; |
|
|
|
|
/* Case 1 */ |
|
|
|
|
{ |
|
|
|
|
/* pin axis*/ |
|
|
|
|
Triple tent (0.f, 1.f, 1.f); |
|
|
|
|
Triple axis_range (0.f, 0.f, 0.f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -54,7 +55,7 @@ main (int argc, char **argv) |
|
|
|
|
/* pin axis*/ |
|
|
|
|
Triple tent (0.f, 1.f, 1.f); |
|
|
|
|
Triple axis_range (0.5f, 0.5f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 0.5f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -64,7 +65,7 @@ main (int argc, char **argv) |
|
|
|
|
/* tent falls outside the new axis range */ |
|
|
|
|
Triple tent (0.3f, 0.5f, 0.8f); |
|
|
|
|
Triple axis_range (0.1f, 0.2f, 0.3f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -72,7 +73,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 1.f, 1.f); |
|
|
|
|
Triple axis_range (-1.f, 0.f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 0.5f); |
|
|
|
|
assert (out[0].second == Triple (0.f, 1.f, 1.f)); |
|
|
|
@ -82,7 +83,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 1.f, 1.f); |
|
|
|
|
Triple axis_range (-1.f, 0.f, 0.75f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 0.75f); |
|
|
|
|
assert (out[0].second == Triple (0.f, 1.f, 1.f)); |
|
|
|
@ -93,7 +94,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.2f, 1.f); |
|
|
|
|
Triple axis_range (-1.f, 0.f, 0.8f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (0.f, 0.25f, 1.25f)); |
|
|
|
@ -103,7 +104,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.4f, 1.f); |
|
|
|
|
Triple axis_range (-1.f, 0.f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (0.f, 0.8f, 32767/(float) (1 << 14))); |
|
|
|
@ -113,7 +114,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.25f, 1.f); |
|
|
|
|
Triple axis_range (-1.f, 0.f, 0.4f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 2); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (0.f, 0.625f, 1.f)); |
|
|
|
@ -125,7 +126,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.25f, 0.3f, 1.05f); |
|
|
|
|
Triple axis_range (0.f, 0.2f, 0.4f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 2); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (approx (out[0].second, Triple (0.25f, 0.5f, 1.f))); |
|
|
|
@ -137,7 +138,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.25f, 0.5f, 1.f); |
|
|
|
|
Triple axis_range (0.f, 0.25f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (0.f, 1.f, 1.f)); |
|
|
|
@ -148,7 +149,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.5f, 1.f); |
|
|
|
|
Triple axis_range (0.f, 0.5f, 1.f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 3); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -161,7 +162,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.5f, 1.f); |
|
|
|
|
Triple axis_range (0.f, 0.5f, 0.75f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 3); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -174,7 +175,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.5f, 1.f); |
|
|
|
|
Triple axis_range (0.f, 0.25f, 0.8f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 4); |
|
|
|
|
assert (out[0].first == 0.5f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -190,7 +191,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.5f, 2.f); |
|
|
|
|
Triple axis_range (0.2f, 0.5f, 0.8f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 3); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -204,7 +205,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.5f, 2.f); |
|
|
|
|
Triple axis_range (0.2f, 0.5f, 1.f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 3); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -218,7 +219,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.5f, 1.f); |
|
|
|
|
Triple axis_range (0.25f, 0.25f, 0.75f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 2); |
|
|
|
|
assert (out[0].first == 0.5f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -230,7 +231,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.5f, 1.f); |
|
|
|
|
Triple axis_range (0.f, 0.25f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 3); |
|
|
|
|
assert (out[0].first == 0.5f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -244,7 +245,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.05f, 0.55f, 1.f); |
|
|
|
|
Triple axis_range (0.f, 0.25f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 4); |
|
|
|
|
assert (approx (out[0].first, 0.4f)); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -260,7 +261,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (-1.f, -0.55f, -0.05f); |
|
|
|
|
Triple axis_range (-0.5f, -0.25f, 0.f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 4); |
|
|
|
|
assert (approx (out[0].first, 0.4f)); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -276,7 +277,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.5f, 0.5f, 0.5f); |
|
|
|
|
Triple axis_range (0.5f, 0.5f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -285,7 +286,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.3f, 0.5f, 0.7f); |
|
|
|
|
Triple axis_range (0.1f, 0.5f, 0.9f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 5); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -302,7 +303,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.5f, 0.5f, 0.5f); |
|
|
|
|
Triple axis_range (0.25f, 0.25f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (1.f, 1.f, 1.f)); |
|
|
|
@ -311,7 +312,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.5f, 0.5f, 0.5f); |
|
|
|
|
Triple axis_range (0.25f, 0.35f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (1.f, 1.f, 1.f)); |
|
|
|
@ -320,7 +321,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.5f, 0.5f, 0.55f); |
|
|
|
|
Triple axis_range (0.25f, 0.35f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (1.f, 1.f, 1.f)); |
|
|
|
@ -329,7 +330,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.5f, 0.5f, 1.f); |
|
|
|
|
Triple axis_range (0.5f, 0.5f, 1.f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 2); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -340,7 +341,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.25f, 0.5f, 1.f); |
|
|
|
|
Triple axis_range (0.5f, 0.5f, 1.f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 2); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -351,7 +352,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.2f, 1.f); |
|
|
|
|
Triple axis_range (0.f, 0.f, 0.5f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (0.f, 0.4f, 32767/(float) (1 << 14))); |
|
|
|
@ -361,7 +362,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 0.5f, 1.f); |
|
|
|
|
Triple axis_range (-1.f, 0.25f, 1.f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 5); |
|
|
|
|
assert (out[0].first == 0.5f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -378,7 +379,7 @@ main (int argc, char **argv) |
|
|
|
|
{ |
|
|
|
|
Triple tent (0.5f, 0.5f, 0.5f); |
|
|
|
|
Triple axis_range (0.f, 0.5f, 1.f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 5); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple ()); |
|
|
|
@ -391,5 +392,24 @@ main (int argc, char **argv) |
|
|
|
|
assert (out[4].first == -1.f); |
|
|
|
|
assert (out[4].second == Triple (-1.f, -1.f, -2/(float) (1 << 14))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 1.f, 1.f); |
|
|
|
|
Triple axis_range (-1.f, -0.5f, 1.f); |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, default_axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (1.f/3, 1.f, 1.f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
Triple tent (0.f, 1.f, 1.f); |
|
|
|
|
Triple axis_range (-1.f, -0.5f, 1.f); |
|
|
|
|
TripleDistances axis_distances{2.f, 1.f}; |
|
|
|
|
result_t out = rebase_tent (tent, axis_range, axis_distances); |
|
|
|
|
assert (out.length == 1); |
|
|
|
|
assert (out[0].first == 1.f); |
|
|
|
|
assert (out[0].second == Triple (0.5f, 1.f, 1.f)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|