Skip to content

Latest commit

 

History

History
410 lines (320 loc) · 18.7 KB

SPECIFICATION.md

File metadata and controls

410 lines (320 loc) · 18.7 KB

Specification

This document describes the application in enough detail to rebuild it in another language and arrive at a homologous outcome. It is updated whenever functionality is added, removed or changed.

  • Product: Geometria Descritiva 10 — a static bilingual course covering the Portuguese Geometria Descritiva A, 10.º ano programme.
  • Version: 1.1.0
  • Status: complete for the 10th-year programme.

1. Purpose and audience

1.1 The problem

Descriptive geometry is taught through a construction — the double orthogonal projection system, or Monge system — whose central move is counter-intuitive on paper: two projection planes at right angles are folded into one flat sheet. A student who does not see that fold happen is left memorising rules that appear arbitrary ("the horizontal projection goes below the line"), and the subject then compounds, because every later topic is expressed in those terms.

1.2 The audience

A 10th-year student, roughly 15 years old, who finds mathematics difficult and is anxious about it. This is a design constraint, not a footnote:

  • Ideas arrive one at a time, on their own page, with a drawing.
  • Prose is short, concrete and uses an everyday analogy before the term.
  • Being wrong is free: unlimited attempts, no timer, no score, and a hint ladder that is always available before the answer is.
  • Feedback names what is wrong ("check the cota"), never merely that something is.
  • The Portuguese term is always given, because that is the word on the exam.

1.3 Non-goals

  • Métodos geométricos auxiliares (rebatimento of an oblique plane, mudança de diedros, rotações) belong to the 11th-year programme and are out of scope. Lesson 16 names the limit explicitly rather than pretending it does not exist.
  • No accounts, no server, no telemetry, no analytics.

2. User stories

# As a … I want to … So that …
U1 student see the two projection planes fold flat, at my own speed I understand where an épura comes from instead of memorising it
U2 student read a lesson in Portuguese or English I can use the language I think in, and still learn the exam term
U3 student drag a point in an épura and watch its coordinates follow I can test a claim rather than take it on faith
U4 student answer an exercise and be told what is wrong I can correct the specific mistake
U5 student ask for a hint before the answer I can be helped without being given the answer
U6 student come back tomorrow and carry on where I stopped I do not have to find my place again
U7 student work entirely from the keyboard I can use the course without a mouse
U8 student make the text bigger, or stop things moving the interface does not get in my way
U9 teacher switch the abcissa convention the drawings match what I put on the board
U10 student look up a term I have forgotten I am not blocked by vocabulary
U11 student back up and restore my progress changing device or browser does not lose my work
U12 maintainer run one command to check the whole course is coherent content mistakes are caught before a student meets them
U13 student read a printed sheet away from the screen I can revise, or work at a table with a pencil
U14 student be told what I must already understand before a lesson I am not defeated by something it assumed I knew
U15 student see the calculations actually worked through "find the trace" means something I can copy
U16 student take the sheets to a computer with no internet school and exam conditions do not lock me out

3. Domain model

Coordinates follow the Portuguese convention and are named for it:

Symbol Portuguese Meaning
x abcissa distance along the linha de terra
y afastamento distance in front of the frontal plane φ; negative is behind
z cota height above the horizontal plane ν; negative is below

Internally x always increases to the right; whether positive abcissas are drawn left or right is a rendering setting (§7.3), because textbooks differ.

3.1 Reference geometry

  • ν, the plano horizontal de projeção, is the plane z = 0.
  • φ, the plano frontal de projeção, is the plane y = 0.
  • The linha de terra is their intersection, the x axis.
  • β1/3, the bissector of the odd dihedrals, is y = z.
  • β2/4, the bissector of the even dihedrals, is y = −z.

3.2 Points

dihedral(P) is 1 when y > 0, z > 0; 2 when y < 0, z > 0; 3 when y < 0, z < 0; 4 when y > 0, z < 0. A point with y = 0 or z = 0 lies on a projection plane and belongs to no dihedral; this distinction is modelled explicitly because it is the one students most often get wrong.

Projections: P₁ = (x, y, 0) on ν, P₂ = (x, 0, z) on φ.

3.3 Lines

A line is stored as two distinct points. Its traces are the point of zero cota (H, the traço horizontal) and the point of zero afastamento (F, the traço frontal); either may not exist when the line is parallel to that plane.

Families are decided by the zero pattern of the direction d:

Family Condition
fronto-horizontal dy = 0, dz = 0
de topo dx = 0, dz = 0
vertical dx = 0, dy = 0
horizontal (de nível) dz = 0
frontal (de frente) dy = 0
de perfil dx = 0
oblíqua otherwise

The tests must be applied in that order: the special families are progressively less constrained.

Relative position of two lines is coincident, parallel, concurrent or skew; skew is detected as non-parallel and non-coplanar.

3.4 Planes

A plane is dot(n, p) = c with n normalised. Because two planes are perpendicular exactly when their normals are, and n_ν = (0,0,1), n_φ = (0,1,0), every named family falls out of the zero pattern of n:

Family Normal Note
horizontal (de nível) (0,0,±1), c ≠ 0 no hα
frontal (de frente) (0,±1,0), c ≠ 0 no fα
de perfil (±1,0,0) both traces ⊥ LT
de topo nx ≠ 0, ny = 0, nz ≠ 0 ⊥ φ; projecting onto φ
vertical nx ≠ 0, ny ≠ 0, nz = 0 ⊥ ν; projecting onto ν
de rampa nx = 0, ny ≠ 0, nz ≠ 0, c ≠ 0 both traces ∥ LT
passante nx = 0, c = 0 contains the LT
oblíquo all non-zero
ν, φ as above with c = 0 the projection planes themselves

Derived constructions: intersection with a plane or line; the level and frontal lines of a plane at a given cota or afastamento; the reta de maior declive (steepest descent within the plane, whose horizontal projection is ⊥ hα) and the reta de maior inclinação (its analogue against φ).

3.5 Figures and solids

Regular polygons are generated in a given plane; prisms and pyramids are built from a base polygon; cylinders and cones are many-sided prisms and pyramids. Hidden-line determination for a convex solid: an edge is visible from a direction when at least one face meeting it faces the observer. Face normals are oriented outwards by comparison with the solid's centroid rather than trusting the winding of hand-authored meshes.


4. Architecture

index.html ──> css/*.css          static, five stylesheets
           ──> vendor/d3.min.js   classic script, exposes the d3 global
           ──> runtime/amd.js     a twenty-line synchronous module resolver
           ──> js/app.js          one classic bundle, compiled from src/

src/
  core/      vec, geometry, project   pure maths, no DOM
             scene                    declarative drawing description
             view                     the one D3 renderer
             i18n, store, dom         localisation, persistence, helpers
  exercises/ engine                   exercise types and marking, pure
             render                   the "now you try" card
  curriculum/types, helpers           the shape of a lesson
             part1…part6, glossary    the content, as data
             index                    assembly
  app/       router, shell            hash routing and the page frame
             figure, lesson, pages    composition
             credit                   the Kartoza credit
  i18n/ui                             interface strings

4.1 Layering rules

  1. core/vec, core/geometry, core/project and exercises/engine touch neither the DOM nor D3. Every rule the course teaches is therefore directly unit-testable, and it is.
  2. core/view is the only module that produces SVG.
  3. Lessons are data. A lesson contains no presentation logic, so the course can be reordered, re-skinned or translated without touching a renderer.
  4. Lesson figures derive their geometry from the objects they illustrate (horizontalLineOfPlane(α, 3), not a hard-coded pair of points), so a drawing cannot silently drift out of agreement with the prose beside it.

4.2 The single-renderer decision

The épura is the fully folded, straight-on case of the spatial view. One renderer takes a Scene plus a ViewConfig { yaw, pitch, fold, unit, origin, xConvention }:

  • a point of ν is rotated about the x axis by −fold · π/2 before projection, so at fold = 1 a point of afastamento y has been carried to cota −y;
  • the camera swings from a three-quarter view to straight-on as the fold completes;
  • at fold = 1 and yaw/pitch zero the mapping is affine and exactly invertible, which is what makes dragging possible.

Consequences that would otherwise need code: the épura and the spatial view can never disagree; the fold is a continuous control rather than two illustrations; and dragging a horizontal projection changes (x, y) while dragging a frontal one changes (x, z), with the shared abcissa keeping them on one recall line — which is the lesson, enacted.

4.3 State

A single Store owns settings and progress, persisted to localStorage under gd10.state with a version field and a migration hook. Listeners are told what changed:

  • settings — language, theme, abcissa convention, text size, motion. Rebuilds the whole interface, since every string and drawing depends on them.
  • progress — a step seen, an attempt recorded, a place remembered. Repaints only the step rail. It must not rebuild the page, because rendering a lesson records progress and a rebuild would re-enter that render.

5. Content model

Lesson  { id, number, title, summary, unit, steps[] }
Step    = ConceptStep | PracticeStep
Concept { id, title, body, plain?, remember?, mistake?, figure? }
Practice{ id, title, prompt, exercise, hints[], explanation, revealNodes?, figure? }
Figure  { build(), alt, caption?, config?, fold?, foldControl?, orbit?, stages[]? }

Every user-visible string is a Localized { en, pt }; the type system makes it impossible to write one language without the other, and the test suite rejects an empty one.

A Figure.stages[] is a numbered walkthrough the student advances themselves, each stage naming the scene nodes visible and optionally a fold position. This is how a construction is built one line at a time without an animation the student cannot pause.

5.1 Fact sheets

Every lesson carries a FactSheet, and the type makes it compulsory: the lesson constructor will not compile without one.

FactSheet { before, theory, skills[], keyFacts[], nextUp? }
Skill     { name, how, example }

The structure encodes what the lessons could not. before names both the earlier lesson an idea came from and the ordinary arithmetic assumed — the second of those is the gap that prompted the feature, because a student who cannot confidently handle a negative number cannot start lesson 4 however well lesson 3 was taught. example is required rather than optional, and the test suite rejects one containing no digits: "find the horizontal trace" means nothing until it has been watched being done with numbers.

Vocabulary is not authored on the sheet. It is derived from the glossary by lesson id, so a term can never be defined twice and drift.

A sheet is rendered three ways from one source: read on screen, printed through @media print, and downloaded. The download is a single HTML file with the stylesheet inlined and the drawings embedded as SVG, so it opens with no network at all. Its stylesheet is deliberately not derived from css/: paper is a different medium, with no dark mode and no hover, and the tinted washes that make the screen drawings readable print as grey mud. The one thing held identical is the colour code for notation, because that is what the student is relying on.

5.2 Exercise types

Type Answer Marked
mcq one or several options set equality; a subset of the correct options is reported as near
truefalse a boolean equality
number a number within tolerance; a sign slip is reported as near
coords some of x, y, z per axis within tolerance; the wrong axes are named
place drag a named point per axis within tolerance; the wrong axes are named
pick click elements of the drawing set equality

Marking is a pure function (exercise, response) → { correct, near, wrongParts }. A response of the wrong shape, or containing a non-finite number, is incorrect — never an exception, because a page a student is working in must not break.

Canonical option lists for "which family of line/plane is this?" and "which dihedral?" are generated from one place, so the wording cannot drift between questions.


6. Accessibility

Target: WCAG 2.2 AA.

  • Keyboard. Every control is reachable and operable. Left and right arrows move between steps. A draggable point is focusable and moves with the arrow keys — one unit, or a tenth with Shift.
  • Screen readers. Every figure carries a bilingual alt describing what it shows, which is required by the type, not optional. Exercise feedback is announced through a polite live region. The main region receives focus on navigation.
  • Colour. Never the only carrier of meaning: horizontal projections are hollow-centred and frontal ones solid, hidden edges are dashed, and every projection is labelled with its subscript.
  • Motion. prefers-reduced-motion is honoured, and there is an in-app setting for students whose device is not configured but who still find movement distracting. With it on, the fold jumps rather than animating.
  • Targets and text. Interactive targets are at least 44 px; drag handles are 30 px across. A text-size setting enlarges the whole scale.
  • Language. document.documentElement.lang follows the language setting, so a screen reader pronounces Portuguese as Portuguese.

7. Functional requirements

7.1 Navigation

Hash routing: #/, #/lessons, #/lesson/<id>/<step>, #/glossary, #/progress, #/settings. Hash routing is required, not incidental: it lets the built site be opened from a file, served from a subdirectory, and published to GitHub Pages without server rewrites.

7.2 Lesson page

Header with unit, number and title; a step rail where a circle is a concept and a diamond is an exercise, coloured by state; the step itself, with the drawing first on narrow screens; previous/next that carry across lesson boundaries.

7.3 Settings

Language (pt/en), abcissa direction (left/right of O), theme (auto/light/dark), text size (normal/large), motion (full/reduced). All persisted; all applied immediately to every page and drawing.

7.4 Progress

Per step: seen, solved, attempt count, whether the answer was revealed. Revealing an answer is recorded but never penalised. The progress page shows totals, per-lesson state, and offers export to and import from a JSON file. A reset is confirmed before it destroys anything.


8. Non-functional requirements

  • Static. No server, no network access at run time, no third-party requests. The site works from file://: the source is written as ES modules but shipped as a single AMD bundle loaded by a classic script, because a browser refuses to load an ES module from a file origin. That matters for a student copying the folder onto a memory stick and for a school network that blocks outside requests.
  • Dependencies. D3 v7 only, vendored, integrity-verified, loaded as a classic script. No node_modules. The TypeScript compiler is pinned and integrity-verified in tools/TOOLCHAIN.lock.
  • Privacy. No telemetry, no cookies, no network calls. All state is local.
  • Robustness. localStorage being unavailable (private browsing, file://) degrades to an in-memory session rather than failing.
  • Size. The built site is well under 500 kB, most of it D3.

9. Test strategy

bin/test.sh compiles the whole project and runs the Node built-in test runner. Four groups:

  1. Geometry — the rules the course teaches, stated as tests: dihedral classification, the boundary cases on the projection planes, bissector membership, line families, traces, relative position, plane families and their traces, intersections, lines of a plane, parallelism and perpendicularity, polygons, solids and hidden-line visibility.
  2. Projection — that a folded straight-on view reproduces an épura exactly: shared recall line, cota above and afastamento below, exact invertibility, and clipping.
  3. Marking — every exercise type, including the near-miss cases and the rule that a blank or malformed answer is never marked correct.
  4. The course itself — that lessons are numbered in order and uniquely identified; that every string exists in both languages and is non-empty; that every exercise's own stated answer marks as correct; that a place or pick exercise names a point the drawing actually contains and that can actually be dragged or clicked; that revealed nodes exist and start hidden; that walkthrough stages name real nodes; that the prose uses only markup the renderer understands; and that specific geometric claims made in captions ("these two lines are concurrent") hold when checked against the engine.

Group 4 is the one that pays for itself: it turns "the content is correct" from a hope into a build step.


10. Known limits

  • Métodos geométricos auxiliares are out of scope (§1.3); lesson 16 says so.
  • Retas and planos de perfil are taught, including the warning that the usual parallelism test fails for them, but the third (lateral) projection used to resolve them is not drawn. It belongs with the 11th-year material.
  • Hidden-line removal is exact for convex solids. The course only uses convex solids; a concave one would need a depth-sorted renderer.