Spaces:
Sleeping
Sleeping
File size: 1,379 Bytes
395651c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from solver.engine import GeometryEngine
from solver.models import Point, Constraint
def test_triangle_abc():
engine = GeometryEngine()
# Triangle ABC: AB=5, AC=7, angle A=60
points = [
Point(id="A"),
Point(id="B"),
Point(id="C")
]
constraints = [
Constraint(type="length", targets=["A", "B"], value=5.0),
Constraint(type="length", targets=["A", "C"], value=7.0),
Constraint(type="angle", targets=["A"], value=60.0) # Angle at A
]
print("Solving for Triangle ABC (AB=5, AC=7, angle A=60)...")
results = engine.solve(points, constraints)
if results:
coords = results["coordinates"]
print("Success! Coordinates:")
for pid, c in coords.items():
print(f"Point {pid}: {c}")
# Verify distance AB
dist_ab = ((coords["B"][0] - coords["A"][0])**2 + (coords["B"][1] - coords["A"][1])**2)**0.5
print(f"Verified AB distance: {dist_ab:.2f}")
# Verify distance AC
dist_ac = ((coords["C"][0] - coords["A"][0])**2 + (coords["C"][1] - coords["A"][1])**2)**0.5
print(f"Verified AC distance: {dist_ac:.2f}")
else:
print("Solver failed.")
if __name__ == "__main__":
test_triangle_abc()
|