v0.0.4.0 feat(module-2): tam giác đồng dạng (lớp 8, scale slider)#4
Merged
v0.0.4.0 feat(module-2): tam giác đồng dạng (lớp 8, scale slider)#4
Conversation
Single-slider similarity demo for Module 2. Fixed △ABC, scaled △A'B'C' computed each frame as `centroid_target + k · (vertex − centroid_ABC)` for k ∈ [0.5, 2]. The slider's input event is the only event listener — no Pointer Events here (we're not dragging vertices in this MVP). AbortController teardown on astro:before-swap as before. The renderTicks helper is duplicated from congruence-sss.ts for now — when Module 4 lands we'll factor it out into a shared module. Premature abstraction would force a circular import structure for one helper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Page at /lop-8/tam-giac-dong-dang/. △ABC fixed on the left at scalene scale-72.8 / 83.2 / 93.4 sides. △A'B'C' is the runtime scaled image, controlled by a single range input k ∈ [0.5, 2] step 0.05. Live readout table shows all six side lengths and all three ratios. The killer moment: drag the slider, watch all 3 ratios stay numerically equal to each other (= 1/k). That equality IS the definition of similarity, made visible. Tick marks per Decision D3: 1/2/3 ticks color-paired (#D7263D / #1B998B / #F46036). Triangle 1 ticks rendered once on mount; triangle 2 ticks redrawn on every slider input. Hub: lớp 8 card flips to live status. All 3 grade cards now active — the autoplan 3-module hero set is complete. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
v0.0.4.0 = scaffold + Module 3 (góc nội tiếp) + Module 1 (tam giác bằng nhau) + Module 2 (tam giác đồng dạng). All three MVP modules from autoplan now live. Move 2 P1 items to Completed (scale slider, ratio readout) and reduce Module 2 remaining items to P2 (free-drag mode) + P3 (numeric angle readouts). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Third interactive theorem demo: Module 2 — Tam giác đồng dạng, live at
/lop-8/tam-giac-dong-dang/. With this PR, all three MVP modules from the autoplan plan are live — Hình Học Sống has its hero curriculum.What changed
Module 2 (the killer moment): a single range slider drives
k ∈ [0.5, 2]step 0.05. Fixed △ABC on the left; △A′B′C′ on the right is recomputed each frame ascentroid_target + k · (vertex − centroid_ABC). Three ratio readouts (AB/A′B′, BC/B′C′, CA/C′A′) show the same number, regardless ofk. That numerical-equality-under-scaling IS similarity, made visible in one gesture.Files:
src/components/similarity-scale.ts— slider controller. Singleinputevent listener; no Pointer Events here. AbortController teardown onastro:before-swap.src/pages/lop-8/tam-giac-dong-dang.astro— page at viewBox 400×300, hub-style layout. Left triangle's tick marks rendered once on mount (static); right triangle's redrawn on everyinput.i18n/vi.tsextended withmodule2.*strings +lop-8.href/statusflipped to live.Encoding (Decision D3, same as Module 1):
Build observation
With three canvas pages now in the build, Astro extracts shared geom-engine chunks (
vec.js~441B,triangle.js~288B) instead of inlining per-page scripts. Per-page scripts are now 2–3.6KB, cached after first visit. Net result: total JS for any page < 4KB, and visiting a second module is faster (shared chunks already cached). Documented in CHANGELOG.Test Coverage
No new geom-engine logic in this PR — Module 2 reuses
triangle.sides()andvec.scale/sub/add. Existing 39 tests still pass; coverage unchanged.The math being demonstrated (similar triangles have proportional sides + equal angles) is implicit in
vec.scale's definition; the unit tests for scale already cover it.Pre-Landing Review
No critical findings. INFORMATIONAL:
data-vertex-label="..."(they're not referenced by the script). Non-issue.Adversarial Review (Claude inline, Codex unavailable)
Checked: slider clamped to
[0.5, 2.0]sokcannot reach 0 (autoplan eng failure mode #3).Number.isFinite(k)guards the parsed value before update.1/kratio computation cannot divide by zero given the clamp. Static triangle 1 vertices are inline literals matching the component'sA/B/Cconstants — if those drift, the static SVG will visibly misalign with the controller's expectations; the static positions and the constants should ideally be a single source of truth, but for one-pair-of-numbers it's overkill to wire that up now (called out in CHANGELOG implicitly).Plan Completion (vs autoplan plan)
Documentation
CHANGELOG entry for 0.0.4.0 written. TODOS.md: 2 P1 items moved to Completed (scale slider, similarity-ratio readout). Module 2 section reduced to remaining P2/P3 items. VERSION + package.json bumped together.
Test plan
bun run test && bun run typecheck && bun run buildclean locally🤖 Generated with Claude Code