changes to see how its faulty
This commit is contained in:
@@ -17,6 +17,7 @@ import com.google.gson.JsonParser;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Vector3f;
|
||||
import org.json.JSONArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -418,30 +419,31 @@ public class InputProcessor {
|
||||
* Function for checking whether the last movement was faulty
|
||||
*/
|
||||
public boolean isFaultyMovement() {
|
||||
boolean upMovementDetected = false;
|
||||
boolean downMovementDetected = false;
|
||||
|
||||
// Calculate the index of the reference rotation vector
|
||||
// This is done by calculating the closest index of the last received vector
|
||||
// to the current time.
|
||||
// i = | (t % T) / T * N |
|
||||
for (List<Vector3f> path : selfRotationVectorPaths) {
|
||||
if (path.size() < 2) {
|
||||
continue; // Skip if there are not enough points to compare
|
||||
}
|
||||
|
||||
int i, referenceIndex;
|
||||
float distance;
|
||||
Vector3f firstPoint = path.get(0);
|
||||
Vector3f lastPoint = path.get(path.size() - 1);
|
||||
|
||||
for (i = 0; i < selfRotationVectorPaths.length; i++) {
|
||||
referenceIndex = (int) (Math.round(
|
||||
((this.secondsPassed % this.exerciseRepetitionDurationInSeconds) /
|
||||
(this.exerciseRepetitionDurationInSeconds)) * this.targetRotationVectorPaths[i].length))
|
||||
% this.targetRotationVectorPaths[i].length;
|
||||
referenceIndex = Math.min(1, Math.max(0, referenceIndex));
|
||||
// If distance is greater than the threshold, return true
|
||||
distance = this.selfRotationVectorPaths[i].get(this.selfRotationVectorPaths[i].size() - 1).distance(
|
||||
this.targetRotationVectorPaths[i][referenceIndex]);
|
||||
float y1 = firstPoint.y;
|
||||
float y2 = lastPoint.y;
|
||||
|
||||
if (distance > ExerciseManager.EXERCISE_ERROR_MARGIN) {
|
||||
Log.i("MotionProcessor", "Faulty movement detected: " + distance + " > " + ExerciseManager.EXERCISE_ERROR_MARGIN);
|
||||
return true;
|
||||
if (y2 > y1) {
|
||||
upMovementDetected = true;
|
||||
} else if (y2 < y1) {
|
||||
downMovementDetected = true;
|
||||
}
|
||||
|
||||
if (upMovementDetected && downMovementDetected) {
|
||||
return false; // Return false for faulty movement if both up and down movements are detected
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return true; // Return true for faulty movement if only up or down movement is detected
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user