From 114c53f58d535d9fab158ed669646a0aae5f078a Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期五, 12 六月 2020 14:56:34 +0800 Subject: [PATCH] commit --- README.md | 96 ------------------------------------------------ 1 files changed, 0 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index 53f9376..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,96 +0,0 @@ -## 閫嗚绠楁硶璋冪敤璇存槑 - - -### 1. 浠g爜璋冪敤 -``` - /** - * 绗竴涓弬鏁癅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}); - -//鍥犱负鏁版嵁鏃舵祦鏁版嵁锛屼笅闈㈢殑璋冪敤搴旇鏃跺湪涓�涓惊鐜噷闈紝澶勭悊瀹屼竴鏉℃帴鐫�澶勭悊涓嬩竴鏉� -//鏋勫缓浼犲叆鐨勬暟鎹� -Record record; -record.id = 1; //鐩爣ID -record.timestamp = time(0); //鏃堕棿鎴� -record.coordinate = {2.0, 3.0}; // 鍧愭爣 -//鍒ゆ柇鏄惁閫嗚 -indirectAlg.isRetrograde(record) - -``` - -### 2 娴嬭瘯鐢ㄤ緥 -test_right_walk2.c - -```test_right_walk2.c -#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(); - -} -``` - -### 3 缂栬瘧 - -瀹夎濂絪o鍖呭悗锛岀敤濡備笅鐨勬柟寮忕紪璇戯紝alg鏄�嗚绠楁硶鍖咃紝usgcommon鏄畻娉曠敤鐨勭殑鍏叡鍖咃紝pthread鏄郴缁熺殑绾跨▼鍖� -``` -g++ -std=c++11 test_right_walk2.c -o test_right_walk2 -lalg -lusgcommon -lpthread -``` - -- Gitblit v1.8.0