From b8d9c7ad67191316b764cf18eb2fc666592fb6b3 Mon Sep 17 00:00:00 2001
From: Zachary Zhang <zacharyzhang7@gmail.com>
Date: Wed, 24 Jul 2024 13:16:52 -0400
Subject: ndollar stroke data useless

---
 src/client/views/GestureOverlay.tsx | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

(limited to 'src/client/views/GestureOverlay.tsx')

diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index e961bc031..dd80418c8 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -150,6 +150,7 @@ export class GestureOverlay extends ObservableReactComponent<React.PropsWithChil
                 // need to decide when to turn gestures back on
                 const result = points.length > 2 && GestureUtils.GestureRecognizer.Recognize([points]);
                 console.log(points);
+                console.log(this.getNumberOfCusps(points));
                 let actionPerformed = false;
                 console.log(result);
                 if (Doc.UserDoc().recognizeGestures && result && result.Score > 0.7) {
@@ -201,7 +202,28 @@ export class GestureOverlay extends ObservableReactComponent<React.PropsWithChil
         }
         this._points.length = 0;
     };
-
+    getNumberOfCusps(points: any) {
+        let numberOfSharpCusps = 0;
+        for (let i = 0; i < points.length - 2; i++) {
+            const point1 = points[i];
+            const point2 = points[i + 1];
+            const point3 = points[i + 2];
+            // console.log(point1);
+            // console.log(point2);
+            // console.log(point3);
+            // console.log(this.find_angle(point1, point2, point3));
+            if (this.find_angle(point1, point2, point3) < 90) {
+                numberOfSharpCusps += 1;
+            }
+        }
+        return numberOfSharpCusps;
+    }
+    find_angle(A: any, B: any, C: any) {
+        let AB = Math.sqrt(Math.pow(B.X - A.X, 2) + Math.pow(B.Y - A.Y, 2));
+        let BC = Math.sqrt(Math.pow(B.X - C.X, 2) + Math.pow(B.Y - C.Y, 2));
+        let AC = Math.sqrt(Math.pow(C.X - A.X, 2) + Math.pow(C.Y - A.Y, 2));
+        return Math.acos((BC * BC + AB * AB - AC * AC) / (2 * BC * AB)) * (180 / Math.PI);
+    }
     makeBezierPolygon = (shape: string, gesture: boolean) => {
         const xs = this._points.map(p => p.X);
         const ys = this._points.map(p => p.Y);
-- 
cgit v1.2.3-70-g09d2

