diff options
| author | Zachary Zhang <zacharyzhang7@gmail.com> | 2024-07-24 13:16:52 -0400 |
|---|---|---|
| committer | Zachary Zhang <zacharyzhang7@gmail.com> | 2024-07-24 13:16:52 -0400 |
| commit | b8d9c7ad67191316b764cf18eb2fc666592fb6b3 (patch) | |
| tree | 98700deffa8af061a1f77a9772f46115a65d29f5 /src/client/views/GestureOverlay.tsx | |
| parent | a1960941edc43d71508ec5cb244f453eb06cf2e1 (diff) | |
ndollar stroke data useless
Diffstat (limited to 'src/client/views/GestureOverlay.tsx')
| -rw-r--r-- | src/client/views/GestureOverlay.tsx | 24 |
1 files changed, 23 insertions, 1 deletions
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); |
