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 --- basic_pack/test_right_walk2.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-) diff --git a/basic_pack/test_right_walk2.c b/basic_pack/test_right_walk2.c new file mode 100644 index 0000000..a6504fc --- /dev/null +++ b/basic_pack/test_right_walk2.c @@ -0,0 +1,60 @@ +#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}); + /** + * 绗竴涓弬鏁癅points 缁勬垚瑙傛祴鍖哄煙鐨勫郊姝ょ浉閭荤殑鐐� + * 绗簩涓弬鏁癅_keepTime 淇濇寔鏃堕棿 + * 绗笁涓弬鏁癅_direction 姝g‘琛岃繘鐨勬柟鍚戞柟鍚� + */ + 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; + record.id = 1; //鐩爣ID + 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(); + +} -- Gitblit v1.8.0