Skip to content

v0.0.4.0 feat(module-2): tam giác đồng dạng (lớp 8, scale slider)#4

Merged
tiennm99 merged 3 commits intomainfrom
feat/module-2-tam-giac-dong-dang
Apr 29, 2026
Merged

v0.0.4.0 feat(module-2): tam giác đồng dạng (lớp 8, scale slider)#4
tiennm99 merged 3 commits intomainfrom
feat/module-2-tam-giac-dong-dang

Conversation

@tiennm99
Copy link
Copy Markdown
Owner

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 as centroid_target + k · (vertex − centroid_ABC). Three ratio readouts (AB/A′B′, BC/B′C′, CA/C′A′) show the same number, regardless of k. That numerical-equality-under-scaling IS similarity, made visible in one gesture.

Files:

  • src/components/similarity-scale.ts — slider controller. Single input event listener; no Pointer Events here. AbortController teardown on astro: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 every input.
  • i18n/vi.ts extended with module2.* strings + lop-8.href/status flipped to live.

Encoding (Decision D3, same as Module 1):

  • AB / A′B′ → pair1 #D7263D + 1 tick
  • BC / B′C′ → pair2 #1B998B + 2 ticks
  • CA / C′A′ → pair3 #F46036 + 3 ticks

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() and vec.scale/sub/add. Existing 39 tests still pass; coverage unchanged.

Tests: 39 pass (16 vec + 13 circle + 10 triangle). No new tests.

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:

  • Module 2 ships scale-slider mode only (autoplan plan's BONUS variant). Free-vertex-drag mode with AA/SAS/SSS đồng dạng detectors deferred to v0.0.5.0+ (P2 in TODOS.md). Rationale: scale-slider gives the strongest "wow" in one gesture and ships in a weekend; free-drag is a separate UI surface with its own detector module.
  • Numeric angle readouts (∠A, ∠B, ∠C and primes) deferred to P3. Currently the angle-invariance is pinned in prose ("các góc tại A, B, C không thay đổi"). Numeric readouts add reassurance but aren't load-bearing for the MVP demo.
  • The static A/B/C circles in the page markup are decorative (not draggable). Distinct from the dynamic A'/B'/C' which are repositioned by the controller. Astro hint count went 0 → 3 because the static labels don't have 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] so k cannot reach 0 (autoplan eng failure mode #3). Number.isFinite(k) guards the parsed value before update. 1/k ratio computation cannot divide by zero given the clamp. Static triangle 1 vertices are inline literals matching the component's A/B/C constants — 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)

  • Module 2 (Tam giác đồng dạng) — was deferred to weekend 4; now done
  • Scale slider clamped to [0.5, 2.0] (autoplan failure mode v0.0.3.0 feat(module-1): drag-to-explore tam giác bằng nhau (lớp 7, SSS) #3)
  • Live ratio readouts (the killer-demo property)
  • SGK tick-mark encoding paired with 3-color palette (D3 reuse)
  • All 3 MVP modules from autoplan now live (Module 1, 2, 3)
  • Free-drag mode with AA/SAS/SSS đồng dạng detectors — P2
  • Numeric angle readouts — P3
  • More worked examples — P3 across all modules
  • Visual regression baselines — P2 (covers all three modules)

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 build clean locally
  • All 39 Vitest tests pass
  • Astro check: 0 errors / 0 warnings / 3 hints (decorative-vs-controlled SVG element distinction; informational)
  • Build produces 4 pages (+ sitemap)
  • Per-page JS bundle 2–3.6KB; shared geom-engine chunks ~730B total
  • CI workflow on this PR
  • Deploy on merge
  • Manual: drag the slider in a real browser, confirm all 3 ratios stay numerically equal as k changes

🤖 Generated with Claude Code

tiennm99 and others added 3 commits April 30, 2026 00:23
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>
@tiennm99 tiennm99 merged commit f51306a into main Apr 29, 2026
1 check passed
@tiennm99 tiennm99 deleted the feat/module-2-tam-giac-dong-dang branch April 29, 2026 17:25
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