From e7e07f42b336bb7b5c488eb3bcc6397c0a2a03f4 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期一, 24 八月 2020 16:36:09 +0800 Subject: [PATCH] fix conflict --- test/test_right_walk.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 115 insertions(+), 0 deletions(-) diff --git a/test/test_right_walk.c b/test/test_right_walk.c new file mode 100644 index 0000000..4331f6f --- /dev/null +++ b/test/test_right_walk.c @@ -0,0 +1,115 @@ +#include "usg_common.h" /* cos */ +#include "graph.h" +#include "IndirectAlg.h" +using namespace std; + +int test2() { + // IndirectAlg indirectAlg({ {{0.0, 0.0}, {1000.0, 0.0}}, {{1000.0, 0.0}, {1000.0, 1000.0}}, {{1000.0, 1000.0}, {0.0, 1000.0}}, {{0.0, 1000.0}, {0.0, 0.0}} }, 5, {1, 1}); + + IndirectAlg indirectAlg((std::initializer_list<Point>){{0.0, 0.0}, {1000.0, 0.0}, {1000.0, 1000.0}, {0.0, 1000.0} }, 5, {1, 1}); + + int i = 0; + time_t start_time; + srand((unsigned) time(0)); + + double rx, ry; + bool isRetrograde; + Point start = {0, 0}; + Record record; + record.id = 1; + record.timestamp = time(0); + record.coordinate = start; + time(&start_time); + while(!(isRetrograde = indirectAlg.isRetrograde(record)) ) { + rx = ((double)(rand()%10))/100000; + ry = ((double)(rand()%10))/100000; + + //std::cout << timestamp << ":" << << "isRetrograde" << isRetrograde; + // err_msg(0, "%ld : {%f, %f} %d\n", record.timestamp, record.coordinate.x, record.coordinate.y, isRetrograde); + record.timestamp = time(0); + + //if (difftime(time(0), start_time) > 1) + if (i > 10) + { + record.coordinate = {record.coordinate.x - rx , record.coordinate.y - ry}; + } else { + record.coordinate = {record.coordinate.x + rx , record.coordinate.y + ry}; + } + + if (i > 100) + break; + + sleep(1); + i++; + } + printf("return %ld : {%f, %f} %d\n", record.timestamp, record.coordinate.x, record.coordinate.y, isRetrograde); + return 0; +} + + +int main() { + test2(); + +} +int test() +{ + // cout << epsilon << endl; + // Vector3 a = new Vector3(1, 1, 1); + // double param, result; + // param = 0; + // result = cos ( param * PI / 180.0 ); + // printf ("The cosine of %f degrees is %f.\n", param, result ); + + // param = 60.0; + // result = cos ( param * PI / 180.0 ); + // printf ("The cosine of %f degrees is %f.\n", param, result ); + + // param = 90.0; + // result = cos ( param * PI / 180.0 ); + // printf ("The cosine of %f degrees is %f.\n", param, result ); + + // param = 100.0; + // result = cos ( param * PI / 180.0 ); + // printf ("The cosine of %f degrees is %f.\n", param, result ); + + // param = 180.0; + // result = cos ( param * PI / 180.0 ); + // printf ("The cosine of %f degrees is %f.\n", param, result ); + + + // param = 360.0; + // result = cos ( param * PI / 180.0 ); + // printf ("The cosine of %f degrees is %f.\n", param, result ); + + // result = getAngle({3, 4}, {4, 3}); + // printf ("getAngle result is %f.\n", result ); + + // const initializer_list<Point> points = { { 5.0, 5.0}, {5.0, 8.0}, {-10.0, 5.0}, {0.0, 5.0}, {10.0, 5.0}, {8.0, 5.0}, {10.0, 10.0} }; + + // const Figure square = { "Square", + // { {{0.0, 0.0}, {10.0, 0.0}}, {{10.0, 0.0}, {10.0, 10.0}}, {{10.0, 10.0}, {0.0, 10.0}}, {{0.0, 10.0}, {0.0, 0.0}} } + // }; + + // const Figure square_hole = { "Square hole", + // { {{0.0, 0.0}, {10.0, 0.0}}, {{10.0, 0.0}, {10.0, 10.0}}, {{10.0, 10.0}, {0.0, 10.0}}, {{0.0, 10.0}, {0.0, 0.0}}, + // {{2.5, 2.5}, {7.5, 2.5}}, {{7.5, 2.5}, {7.5, 7.5}}, {{7.5, 7.5}, {2.5, 7.5}}, {{2.5, 7.5}, {2.5, 2.5}} + // } + // }; + + // const Figure strange = { "Strange", + // { {{0.0, 0.0}, {2.5, 2.5}}, {{2.5, 2.5}, {0.0, 10.0}}, {{0.0, 10.0}, {2.5, 7.5}}, {{2.5, 7.5}, {7.5, 7.5}}, + // {{7.5, 7.5}, {10.0, 10.0}}, {{10.0, 10.0}, {10.0, 0.0}}, {{10.0, 0}, {2.5, 2.5}} + // } + // }; + + // const Figure exagon = { "Exagon", + // { {{3.0, 0.0}, {7.0, 0.0}}, {{7.0, 0.0}, {10.0, 5.0}}, {{10.0, 5.0}, {7.0, 10.0}}, {{7.0, 10.0}, {3.0, 10.0}}, + // {{3.0, 10.0}, {0.0, 5.0}}, {{0.0, 5.0}, {3.0, 0.0}} + // } + // }; + + // for(auto f : {square, square_hole, strange, exagon}) + // f.check(points, cout); + + return EXIT_SUCCESS; +} \ No newline at end of file -- Gitblit v1.8.0