isSustainedMovement method
Checks if the movement is sustained by evaluating the percentile value in a window of Z-axis data.
Implementation
bool isSustainedMovement(List<SensorEvent> gyroData, int startIndex, int windowSize, double threshold, int percentile) {
// Extract z values
List<double> zValues = gyroData
.sublist(startIndex, startIndex + windowSize)
.map((e) => e.z.abs()) // If you care about magnitude regardless of sign
.toList();
// Sort descending
zValues.sort((a, b) => b.compareTo(a));
// Find index at 75% position
int checkIndex = ((percentile / 100) * zValues.length).floor();
// Check if that value is above threshold
return zValues[checkIndex] > threshold;
}