aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/views/GestureOverlay.tsx24
-rw-r--r--src/client/views/InkTranscription.tsx21
2 files changed, 41 insertions, 4 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);
diff --git a/src/client/views/InkTranscription.tsx b/src/client/views/InkTranscription.tsx
index 3f90df7d1..a7af11463 100644
--- a/src/client/views/InkTranscription.tsx
+++ b/src/client/views/InkTranscription.tsx
@@ -114,6 +114,7 @@ export class InkTranscription extends React.Component {
const validInks = inkDocs.filter(s => s.type === DocumentType.INK);
const strokes: InkData[] = [];
+
const times: number[] = [];
validInks
.filter(i => Cast(i[Doc.LayoutFieldKey(i)], InkField))
@@ -124,8 +125,22 @@ export class InkTranscription extends React.Component {
times.push(DateCast(i.author_date).getDate().getTime());
});
console.log(strokes);
- console.log(this.convertPointsToString(strokes));
- console.log(this.convertPointsToString2(strokes));
+ console.log(
+ `this.Multistrokes.push(
+ new Multistroke(
+ Gestures.Scribble,
+ useBoundedRotationInvariance,
+ new Array([
+ ` +
+ this.convertPointsToString(strokes) +
+ `
+ ])
+ )
+ )
+ `
+ );
+ //console.log(this.convertPointsToString(strokes));
+ //console.log(this.convertPointsToString2(strokes));
this.currGroup = groupDoc;
const pointerData = strokes.map((stroke, i) => this.inkJSON(stroke, times[i]));
const processGestures = false;
@@ -137,7 +152,7 @@ export class InkTranscription extends React.Component {
}
};
convertPointsToString(points: InkData[]): string {
- return points[0].map(point => `new Point(${point.X}, ${point.Y})`).join(',\n ');
+ return points[0].map(point => `new Point(${point.X}, ${point.Y})`).join(',');
}
convertPointsToString2(points: InkData[]): string {
return points[0].map(point => `(${point.X},${point.Y})`).join(',');