Skip to content

Add geometric construction tools#41

Merged
vl3c merged 11 commits intomainfrom
feature/geometric-constructions
Feb 15, 2026
Merged

Add geometric construction tools#41
vl3c merged 11 commits intomainfrom
feature/geometric-constructions

Conversation

@vl3c
Copy link
Copy Markdown
Owner

@vl3c vl3c commented Feb 15, 2026

Summary

  • Add 5 geometric construction tools: midpoint, perpendicular bisector, perpendicular from point, angle bisector, and parallel line
  • New ConstructionManager follows the TangentManager pattern — computes geometry, then creates standard Point/Segment drawables via existing managers
  • Constructions produce static snapshots (no reactive re-computation if source objects move)
  • Composite constructions (perpendicular from point) use suspend_archiving pattern for single-undo-step behavior

New AI tools

  • construct_midpoint — midpoint of two points or a segment
  • construct_perpendicular_bisector — perpendicular bisector of a segment
  • construct_perpendicular_from_point — drop perpendicular from point to segment
  • construct_angle_bisector — bisect an angle (by vertex + arm points or angle name)
  • construct_parallel_line — line through a point parallel to a segment

Files changed

  • math_utils.py — added perpendicular_foot() and angle_bisector_direction()
  • construction_manager.py — new manager (5 public methods)
  • drawable_manager.py / canvas.py — wiring and delegation
  • function_registry.py — tool registration + undoable list
  • functions_definitions.py — 5 AI tool schemas
  • tool_discovery_cases.yaml — updated tool count/hash
  • test_construction_manager.py — 38 Brython tests (6 test classes)
  • Example Prompts.txt / Reference Manual.txt — documentation

Test plan

  • All 38 new construction tests pass
  • Full client test suite passes (2458 tests, 0 failures)
  • Server tests pass
  • Codex code review completed (1 P2 finding fixed: degenerate segment validation)

vl3c added 11 commits February 15, 2026 17:04
Add two vector-form geometric computation methods to MathUtils:
- perpendicular_foot: projects a point onto a line using dot-product
  projection, with degenerate segment and non-finite result validation
- angle_bisector_direction: computes unit bisector vector by normalizing
  and summing arm vectors, with zero-length arm and collinear validation
Introduce ConstructionManager following the TangentManager pattern with
five geometric constructions: midpoint, perpendicular bisector,
perpendicular from point, angle bisector, and parallel line.

Constructions produce static Point/Segment snapshots via existing
managers. Composite constructions (perpendicular from point) use the
suspend_archiving pattern for single-undo-step behavior. Degenerate
segments are rejected in the shared slope helper.
Register five construction tools in FunctionRegistry (_build_registry
and get_undoable_functions) and add strict JSON schemas in
functions_definitions.py: construct_midpoint, construct_perpendicular_
bisector, construct_perpendicular_from_point, construct_angle_bisector,
and construct_parallel_line.

Update tool discovery test data (count 85, new hash).
Add test_construction_manager.py with 38 tests across 6 classes covering
midpoint, perpendicular bisector, perpendicular from point, angle
bisector, parallel line, and low-level math utility functions. Tests
verify geometric correctness, undo behavior, edge cases, and error
handling for degenerate inputs.
Document midpoint, perpendicular bisector, perpendicular from point,
angle bisector, and parallel line constructions with example prompts
and Canvas/ConstructionManager API reference entries.
When construct_angle_bisector is called with angle_name referencing a
reflex angle, negate the bisector direction so it points into the reflex
arc instead of the minor arc.
Completed in PR #41. Circle-through-3-points deferred to future work.
Add MathUtils.circumcenter() (determinant-based formula) and
MathUtils.incenter_and_inradius() (weighted-average incenter with
inradius = 2*area/perimeter). Both reject degenerate inputs.

Add ConstructionManager methods: create_circumcircle() supports
triangle name or 3 point names, create_incircle() takes a triangle
name. Both use suspend_archiving for single-undo-step semantics.

Also fix angle bisector vertex attribute (vertex → vertex_point).
Add delegation methods in DrawableManager and Canvas. Register
construct_circumcircle and construct_incircle in FunctionRegistry
(registry, operation names, undoable list). Add AI tool schemas
with strict mode. Update tool discovery metadata (85 → 87 tools).
TestConstructCircumcircle: by triangle name, by 3 point names,
collinear raises, no args raises, undo.
TestConstructIncircle: right triangle inradius, nonexistent raises, undo.
Math utility tests: circumcenter right/equilateral/collinear,
incenter equilateral/degenerate.
Add Example Prompts for circumcircle, incircle, and circle-through-3-
points. Add Reference Manual entries. Update todo to reflect
circumcircle/incircle completion alongside PR #41.
@vl3c vl3c merged commit 644d602 into main Feb 15, 2026
1 check passed
@vl3c vl3c deleted the feature/geometric-constructions branch February 15, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant