From 59abff0d03403344619420aa0bcd9c2b28ff3522 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期三, 08 四月 2020 11:06:58 +0800
Subject: [PATCH] 坐标

---
 lib/src/main/cpp/test_common/Geometry.cpp |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/lib/src/main/cpp/Geometry.cpp b/lib/src/main/cpp/test_common/Geometry.cpp
similarity index 95%
rename from lib/src/main/cpp/Geometry.cpp
rename to lib/src/main/cpp/test_common/Geometry.cpp
index 0a43ae1..db6deb5 100644
--- a/lib/src/main/cpp/Geometry.cpp
+++ b/lib/src/main/cpp/test_common/Geometry.cpp
@@ -2,7 +2,7 @@
 // Created by YY on 2019/4/30.
 //
 
-#include "defs.h"
+#include "../defs.h"
 #include "Geometry.h"
 #include <stdbool.h>
 #include <stdint.h>
@@ -12,7 +12,7 @@
 #include <initializer_list>
 #include <cctype>
 
-#include "jni_log.h"
+#include "../jni_log.h"
 
 using namespace std;
 
@@ -245,7 +245,6 @@
 
 Relation IntersectionOf(Line line1, Line line2)
 {
-    //  Fail if either line segment is zero-length.
     if ((isEqual(line1.X1, line1.X2) && isEqual(line1.Y1, line1.Y2)) || (isEqual(line2.X1, line2.X2) && isEqual(line2.Y1, line2.Y2)))
         return GM_None;
 
@@ -255,15 +254,14 @@
     if ((isEqual(line1.X1, line2.X2) && isEqual(line1.Y1, line2.Y2)) || (isEqual(line1.X2, line2.X2) && isEqual(line1.Y2, line2.Y2)))
         return GM_Intersection;
 
-    //  (1) Translate the system so that point A is on the origin.
+    //  鐩寸嚎鍧愭爣鍙樻崲閲嶅悎
     line1.X2 -= line1.X1; line1.Y2 -= line1.Y1;
     line2.X1 -= line1.X1; line2.Y1 -= line1.Y1;
     line2.X2 -= line1.X1; line2.Y2 -= line1.Y1;
 
-    //  Discover the length of segment A-B.
     double distAB = sqrt(line1.X2 * line1.X2 + line1.Y2 * line1.Y2);
 
-    //  (2) Rotate the system so that point B is on the positive X axis.
+    //  鏃嬭浆鍒癤杞�
     double theCos = line1.X2 / distAB;
     double theSin = line1.Y2 / distAB;
     double newX = line2.X1 * theCos + line2.Y1 * theSin;
@@ -274,19 +272,16 @@
     line2.Y2 = line2.Y2 * theCos - line2.X2 * theSin;
     line2.X2 = newX;
 
-    //  Fail if segment C-D doesn't cross line A-B.
     if ((line2.Y1 < 0 && line2.Y2 < 0) || (line2.Y1 >= 0 && line2.Y2 >= 0)) {
         return GM_None;
     }
 
-    //  (3) Discover the position of the intersection point along line A-B.
     double posAB = line2.X2 + (line2.X1 - line2.X2) * line2.Y2 / (line2.Y2 - line2.Y1);
 
-    //  Fail if segment C-D crosses line A-B outside of segment A-B.
     if (posAB < 0 || posAB > distAB) {
         return GM_None;
     }
-    //  (4) Apply the discovered position to line A-B in the original coordinate system.
+
     return GM_Intersection;
 }
 

--
Gitblit v1.8.0