mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Ensure skew is always in [-90, 90] (#319)
This commit is contained in:
@@ -42,6 +42,10 @@ public class TargetCalculations {
|
||||
if (isLandscape && minAreaRect.size.width < minAreaRect.size.height) angle += 90;
|
||||
else if (!isLandscape && minAreaRect.size.height < minAreaRect.size.width) angle += 90;
|
||||
|
||||
// Ensure skew is bounded on [-90, 90]
|
||||
while (angle > 90) angle -= 180;
|
||||
while (angle < -90) angle += 180;
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class TargetCalculationsTest {
|
||||
public void testSkewCalculation() {
|
||||
// Setup
|
||||
var isLandscape = true;
|
||||
var rect = new RotatedRect(new Point(), new Size(10, 5), -10);
|
||||
var rect = new RotatedRect(new Point(), new Size(10, 5), 170);
|
||||
|
||||
// Compute min area rect
|
||||
var points = new Point[4];
|
||||
|
||||
Reference in New Issue
Block a user