1 /*
2 * @(#)$Id: F9.java 689 2009-07-22 00:10:27Z bsigner $
3 *
4 * Author : Ueli Kurmann, igesture@uelikurmann.ch
5 *
6 * Purpose : Rubine feature F9. The total angle traversed.
7 *
8 * -----------------------------------------------------------------------
9 *
10 * Revision Information:
11 *
12 * Date Who Reason
13 *
14 * Dec 26, 2006 ukurmann Initial Release
15 * Mar 15, 2007 bsigner Cleanup
16 *
17 * -----------------------------------------------------------------------
18 *
19 * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20 *
21 * This software is the proprietary information of ETH Zurich.
22 * Use is subject to license terms.
23 *
24 */
25
26
27 package org.ximtec.igesture.algorithm.feature;
28
29 import org.sigtec.ink.Note;
30 import org.sigtec.ink.Point;
31 import org.sigtec.ink.Trace;
32
33
34 /**
35 * Rubine feature F9. The total angle traversed.
36 *
37 * @version 1.0 Dec 2006
38 * @author Ueli Kurmann, igesture@uelikurmann.ch
39 * @author Beat Signer, signer@inf.ethz.ch
40 */
41 public class F9 implements Feature {
42
43 private static final int MINIMAL_NUMBER_OF_POINTS = 5;
44
45
46 public double compute(Note note) throws FeatureException {
47 if (note.getPoints().size() < MINIMAL_NUMBER_OF_POINTS) {
48 throw new FeatureException(FeatureException.NOT_ENOUGH_POINTS);
49 }
50
51 final Trace trace = FeatureTool.createTrace(note);
52 final Point[] points = new Point[trace.getPoints().size()];
53 int j = 0;
54
55 for (final Point p : trace.getPoints()) {
56 points[j] = p;
57 j++;
58 }
59
60 double result = 0;
61
62 for (int i = 1; i < trace.getPoints().size() - 1; i++) {
63 result += FeatureTool.roh(i, points);
64 }
65
66 return result;
67 } // compute
68
69
70 public int getMinimalNumberOfPoints() {
71 return MINIMAL_NUMBER_OF_POINTS;
72 } // getMinimalNumberOfPoints
73
74 }