Marker mit einer Kamera - Gaurds
This commit is contained in:
@@ -193,3 +193,42 @@ describe('computeYAxis – Edge Cases', () => {
|
||||
expect(Math.abs(r.axisDir[2])).toBeGreaterThan(0.99);
|
||||
});
|
||||
});
|
||||
|
||||
// ── Fehlende position_mm (z.B. 1-Kamera-Marker, von 3b nicht trianguliert) ───
|
||||
|
||||
describe('computeYAxis – Marker ohne position_mm werden ignoriert statt zu crashen', () => {
|
||||
|
||||
test('position_mm fehlt bei Pos A → Marker landet in skipped, kein Crash', () => {
|
||||
const a = [{ marker_id: 5 }]; // keine position_mm
|
||||
const b = [{ marker_id: 5, position_mm: [0, 0, 0] }];
|
||||
const c = [{ marker_id: 5, position_mm: [0, 1, 0] }];
|
||||
expect(() => computeYAxis(a, b, c)).not.toThrow();
|
||||
const r = computeYAxis(a, b, c);
|
||||
expect(r.ok).toBe(false);
|
||||
expect(r.skipped.some(s => s.id === 5)).toBe(true);
|
||||
});
|
||||
|
||||
test('position_mm fehlt bei Pos B/C → ebenfalls kein Crash', () => {
|
||||
const a = [{ marker_id: 6, position_mm: [0, 0, 0] }];
|
||||
const b = [{ marker_id: 6, position_mm: null }];
|
||||
const c = [{ marker_id: 6 }];
|
||||
expect(() => computeYAxis(a, b, c)).not.toThrow();
|
||||
});
|
||||
|
||||
test('Mix aus gültigen und ungültigen Markern: gültige werden trotzdem genutzt', () => {
|
||||
const R = 100;
|
||||
const angle = (deg) => deg * Math.PI / 180;
|
||||
const mk = (id, deg) => ({
|
||||
marker_id: id,
|
||||
position_mm: [R * Math.cos(angle(deg)), R * Math.sin(angle(deg)), 50],
|
||||
});
|
||||
const a = [mk(1, 0), { marker_id: 2 /* fehlt */ }];
|
||||
const b = [mk(1, 90), { marker_id: 2, position_mm: [1, 2, 3] }];
|
||||
const c = [mk(1, 180), { marker_id: 2 }]; // bei C wieder fehlend
|
||||
const r = computeYAxis(a, b, c);
|
||||
expect(r.ok).toBe(true);
|
||||
expect(r.numMarkers).toBe(1);
|
||||
expect(r.markerData.map(m => m.markerId)).toEqual([1]);
|
||||
expect(r.skipped.some(s => s.id === 2)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user