changes to see how its faulty

This commit is contained in:
2024-06-07 12:36:21 +02:00
parent 8aa8c674d9
commit 2ffc391032

View File

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