70 lines
2.6 KiB
Python
70 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for the new rotated AoI bounding box approach.
|
|
"""
|
|
|
|
from decimal import Decimal
|
|
from scanning.sc3_scan_model import SC3ScanModel
|
|
|
|
def test_rotated_aoi():
|
|
"""Test the rotated AoI bounding box implementation."""
|
|
|
|
# Create scan model
|
|
model = SC3ScanModel()
|
|
|
|
# Configure scan parameters
|
|
model.x_origin = Decimal('50.0')
|
|
model.y_origin = Decimal('35.0')
|
|
model.x_delta = Decimal('10.0')
|
|
model.y_delta = Decimal('5.0')
|
|
model.row_spacing = Decimal('1.0')
|
|
model.laser_frequency = Decimal('2000.0')
|
|
model.scan_velocity = Decimal('100.0')
|
|
model.scan_angles = 4 # 0, 45, 90, 135 degrees
|
|
|
|
print("Scan Model Configuration:")
|
|
print(f" AoI Origin: ({model.x_origin}, {model.y_origin})")
|
|
print(f" AoI Size: {model.x_delta} x {model.y_delta}")
|
|
print(f" Row Spacing: {model.row_spacing}")
|
|
print(f" Optical Origin: ({model.optical_x_origin}, {model.optical_y_origin})")
|
|
print(f" Scan Angles: {model.get_angle_list()}")
|
|
print(f" Rows Required: {model.rows_required}")
|
|
print()
|
|
|
|
# Verify zero-angle scan (should be horizontal lines)
|
|
print("Zero-Angle Scan (first 3 lines):")
|
|
for i, coords in enumerate(model.scan_coordinates[:3]):
|
|
print(f" Line {i}: ({coords[0]}, {coords[1]}) -> ({coords[2]}, {coords[3]})")
|
|
print()
|
|
|
|
# Verify rotated scans
|
|
print("Rotated Scans (first line of each angle):")
|
|
for angle_idx, angle_deg in enumerate(model.get_angle_list()):
|
|
if angle_idx < len(model.rotated_coordinates):
|
|
rotated_scan = model.rotated_coordinates[angle_idx]
|
|
if rotated_scan:
|
|
coords = rotated_scan[0]
|
|
print(f" Angle {angle_deg}°: ({coords[0]:.3f}, {coords[1]:.3f}) -> ({coords[2]:.3f}, {coords[3]:.3f})")
|
|
print(f" Number of lines: {len(rotated_scan)}")
|
|
print()
|
|
|
|
# Verify that scans are horizontal (+x direction)
|
|
print("Verifying horizontal scan direction:")
|
|
for angle_idx, angle_deg in enumerate(model.get_angle_list()):
|
|
if angle_idx < len(model.rotated_coordinates):
|
|
rotated_scan = model.rotated_coordinates[angle_idx]
|
|
all_horizontal = True
|
|
for coords in rotated_scan:
|
|
# Check if y_start == y_end (horizontal line)
|
|
if abs(coords[1] - coords[3]) > 1e-10:
|
|
all_horizontal = False
|
|
break
|
|
status = "✓" if all_horizontal else "✗"
|
|
print(f" Angle {angle_deg}°: {status} All lines horizontal")
|
|
print()
|
|
|
|
print("Test completed successfully!")
|
|
|
|
if __name__ == "__main__":
|
|
test_rotated_aoi()
|