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 --- algorithm/include/graph.h | 65 ++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 0 deletions(-) diff --git a/algorithm/include/graph.h b/algorithm/include/graph.h new file mode 100644 index 0000000..4d35724 --- /dev/null +++ b/algorithm/include/graph.h @@ -0,0 +1,65 @@ +#ifndef __USG_GRAPH_H__ +#define __USG_GRAPH_H__ + +#include "usg_common.h" + +struct Point { +//public: + double x; + double y; + + //Point(const double _x =0, const double _y =0) : x(_x), y(_y) {} +}; + +//骞抽潰鍚戦噺 +struct Vector2 +{ + double x; + double y; + +}; + + +class Edge { +public: + const Point a, b; + /** + * 鏄惁鐩镐氦 + */ + bool isCorss(const Point& p) const; +}; + + + + +class Figure { + //const string name; + std::vector<Edge> edges; + +public: + Figure(); + //Figure(const std::initializer_list<Edge> & _edges); + Figure(const std::vector<Edge> & _edges); + Figure & operator=(Figure && f); // move assignment + bool contains(const Point& p) const; + +}; + + + + + // 杩斿洖涓や釜鍚戦噺澶硅鐨刢os鍊�, cos灏忎簬0鍗充袱涓悜閲忕殑澶硅澶т簬90搴� +static inline double getVector2Angle(const Vector2 & a, const Vector2 & b) { + double doc_product = a.x * b.x + a.y * b.y; + double ma = sqrt(a.x * a.x + a.y * a.y); + double mb = sqrt(b.x * b.x + b.y * b.y); + double cos = doc_product / (ma * mb); + return cos; +} + +// 璁$畻a鎸囧悜b鐨勫悜閲� +static inline Vector2 getVecor2(const Point &a, const Point &b) { + return {b.x - a.x, b.y - a.y}; +} + +#endif -- Gitblit v1.8.0