Add geometric transform workflows: reflect, scale, shear, arbitrary-center rotation#43
Merged
Add geometric transform workflows: reflect, scale, shear, arbitrary-center rotation#43
Conversation
Add four new transform methods to each geometry drawable: - Point: direct coordinate transforms with label sync - Segment: delegates to point methods, recalculates line formula - Vector: delegates to underlying segment - Polygon: iterates vertices for all transforms - Circle: reflect/scale/rotate center; shear raises ValueError - Ellipse: reflect adjusts rotation_angle; scale supports uniform and axis-aligned non-uniform; shear raises ValueError
…th arbitrary center New methods: reflect_object, scale_object, shear_object follow the same orchestration pattern as translate_object (find → archive → transform → refresh dependencies → redraw). Extend rotate_object with optional center_x/center_y parameters for rotation around an arbitrary point. When provided, Points and Circles become eligible targets (they have rotate_around methods). Extract shared helpers: _find_drawable_by_name, _gather_moved_points, _refresh_dependencies_after_transform, _get_class_name, _redraw. Add _resolve_segment_to_line to convert a named segment into line coefficients for segment-axis reflections.
…nctionRegistry Add Canvas delegation methods for the three new transforms and update rotate_object signature with optional center_x/center_y. Register all three in get_available_functions() and get_undoable_functions() alongside the existing transform entries.
…d update rotate_object Add JSON schemas for three new transform tools with strict parameter validation. Update rotate_object with optional center_x/center_y parameters for arbitrary-center rotation.
Test drawable-level transforms (reflect, scale, shear, rotate_around) on Point, Segment, Vector, Triangle, Circle, and Ellipse. Test manager orchestration for reflect_object, scale_object, shear_object, and rotate_object with arbitrary center. Verify undo archiving, error cases (non-uniform circle scale, shear on circle/ellipse, missing drawable, zero-length segment axis, single center coord).
Add Geometric Transformations section to Example Prompts with reflect, scale, shear, and arbitrary-center rotation examples. Update Reference Manual: TransformationsManager description and methods, Canvas methods, drawable method lists for Point, Segment, Vector, Polygon, Circle, and Ellipse, and function category summaries.
…d transforms Fix dependency refresh to use moved_points presence instead of a hard-coded class name set, so all Polygon subclasses (Quadrilateral, Pentagon, Hexagon, etc.) get proper segment formula and cache refresh after transforms. Also refactor translate_object to use the shared _refresh_dependencies_after_transform helper. Add _validate_shear_support and _validate_scale_support checks that run before undo archiving, so unsupported operations (shear on circle/ellipse, non-uniform scale on circle/rotated ellipse) raise ValueError without polluting the undo history. Add tests verifying archive is not called on rejected transforms.
ba061be to
a1b2f40
Compare
Expand test_transforms.py from 42 to 126 test methods covering: - Point: general line reflection, identity transforms, negative scale, non-origin shear centers, unknown axis no-op behavior - Segment: y-axis/arbitrary line reflection, shear with visible effect, formula recalculation after scale (fix weak assertion) - Vector: shear and rotate_around - Rectangle: drawable-level reflect, scale, rotate_around - Circle: y-axis/line reflection, scale from non-origin, negative scale center movement - Ellipse: line reflection with offset, zero scale, negative scale, 180-aligned non-uniform scale, modulo wrap, degenerate line no-op - Manager: line axis, invalid axis, zero coefficients, segment not found, empty segment name, zero/threshold scale factors, invalid shear axis, excluded types (Function/Graph/Angle), no-archive on missing drawable, rotate point/circle exclusion without center, return values, redraw control, segment formula refresh - Invariants: double reflect identity, scale inverse identity, 360 rotation, four 90s rotation, shear inverse identity - Composition: reflect+scale, shear+rotate, scale+reflect circle, rotate+reflect ellipse Fix two weak existing tests found by Codex review: - test_segment_scale_verifies_line_formula: was a no-op assertion - test_composition_shear_then_rotate: shear had no visible effect (dy=0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
reflect(),scale(),shear(),rotate_around()methods following the existingtranslate()/rotate()patternreflect_object,scale_object,shear_object) and enhancedrotate_objectwith optional center coordinatesValueErrorwith clear messages (e.g., shearing circles, non-uniform scaling of circles/rotated ellipses)get_vertices()presence instead of hard-coded class names, covering all Polygon subclassesTest plan
test_transforms.py) with 42 tests covering:🤖 Generated with Claude Code