You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Enhance line intersection visualization with improved UI, accessibility features, and detailed README. Updated index.html for better structure and added metadata. Refactored main.js for clarity and maintainability, including enhanced calculation methods and UI interactions.
-**2D space**: Two draggable points (P1, P2) define the line.
14
+
-**Target X**: A vertical line you move with a slider; the intersection is where the line meets this x.
15
+
-**Y constraints**: Y min / Y max limit where the intersection point is drawn; the yellow point is clamped to this band. When clamped, the dashed path is shown in a different color.
16
+
-**Export & share**: Download the diagram as PNG; the URL updates so you can share or bookmark a configuration.
17
+
18
+
## How to use
19
+
20
+
1.**Drag** either endpoint (P1 or P2) to change the line.
21
+
2. Use **Constraints** to set the y-range (band) for the intersection.
22
+
3. Use **Target X** to move the vertical line and see the intersection move.
23
+
4. Use **Export as PNG** to download the current diagram.
24
+
5. Copy the URL to share or bookmark a configuration.
25
+
26
+
## Math
27
+
28
+
The line through two points $(x_1, y_1)$ and $(x_2, y_2)$ has slope and intercept:
29
+
30
+
$$
31
+
m = \frac{y_1 - y_2}{x_1 - x_2}, \qquad b = y_2 - m\,x_2.
32
+
$$
33
+
34
+
So the line is $y = mx + b$. At a given **x**, the intersection **y** is:
35
+
36
+
$$
37
+
y = m \cdot x + b.
38
+
$$
39
+
40
+
| Case | Behaviour |
41
+
|------|-----------|
42
+
|**Vertical line** ($x_1 = x_2$) | No single **y** at that **x**; no intersection point is drawn. |
43
+
|**Outside band**|**y** is clamped to the constraint band; dashed path is shown in a different color. |
44
+
45
+
## Development
46
+
47
+
### Run locally
48
+
49
+
**Option A: Direct:** Open `index.html` in a browser (some features may be limited with `file://`).
50
+
51
+
**Option B: Local server:**
52
+
53
+
```bash
54
+
npx serve .
55
+
```
56
+
57
+
Then open the URL shown (e.g. `http://localhost:3000`).
aria-label="Interactive diagram: line intersection with constraints. Drag the two endpoints or use the sliders to change the target x and constraints.">
0 commit comments