Repository navigation
OrientToleranceCompress
Up | Previous | Next | Русский
Below is the full source of the class in documentation form. The comments inside the block explain the purpose of the parts of the class, but they are not stored in the working file OrientToleranceCompress.java: the production code stays clean and the explanations live in the wiki.
package com.velitask.plugin.official.processing.compress;
import com.velitask.sdk.data.OrientationSensorAtom;
/* Tolerance compression for camera orientation: quaternion w, x, y, z. */
public final class OrientToleranceCompress extends ToleranceCompress<OrientationSensorAtom> {
/* Stable step name; the "Tolerance (0.01 ≈ 1°)" strings are looked up by it. */
public static final String NAME = "orientToleranceCompress";
/* Step logic version is 1; atoms are OrientationSensorAtom. */
public OrientToleranceCompress() {
super(NAME, 1, OrientationSensorAtom.class);
}
/* Four quaternion components: w, x, y, z. */
@Override
protected int components() {
return 4;
}
/* Indexes 0, 1, 2 are w, x, y; any other one is z (no range check). */
@Override
protected double component(OrientationSensorAtom atom, int index) {
return switch (index) {
case 0 -> atom.w;
case 1 -> atom.x;
case 2 -> atom.y;
default -> atom.z;
};
}
/* Tolerance spinner step is 0.001. */
@Override
protected double toleranceStep() {
return 0.001;
}
}The "Tolerance compression: camera orientation" step replaces a series of points with straight segments that deviate from the original values by no more than the tolerance. An implementation of ToleranceCompress for OrientationSensorAtom.
The algorithm and the tolerance parameter are in ToleranceCompress. The class defines the four quaternion components (w, x, y, z), a tolerance spinner step of 0.001 and does not override period(). The tolerance is in units of the quaternion components, the same for all four (the label "Tolerance (0.01 ≈ 1°)": 0.01 roughly corresponds to one degree).
It is used by the GoPro import plan: a tolerance of 0.01 after OrientAverageFilter; the sensor is disabled in the plan by default. The step is also registered in BuiltinScenarios.steps().
- The tolerance is checked for each component separately, not by the angle between rotations: the relation "0.01 ≈ 1°" is approximate.
- The default tolerance is 0 — lossless; the GoPro plan overrides it.
- Any component index except 0, 1 and 2 returns
z.