# donrudd/pointtoellipse architecture

> Architecture diagram of the GitHub repository donrudd/pointtoellipse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/donrudd/pointtoellipse
- Repository: https://github.com/donrudd/pointtoellipse
- Video tour (about a minute): https://gitdiagram.com/donrudd/pointtoellipse/video

## Overview

This repository is a small numerical demo for projecting a point onto a parametrically defined ellipse. It offers two independent approaches: an analytic tangent-half-angle polynomial solve and an iterative gradient-descent method. Each script also visualizes its result. The scripts use hard-coded example inputs rather than exposing a separate application interface; the graph shows the computational and plotting responsibilities in those files.

Main entry points: [`Analytical.py`](https://github.com/donrudd/pointtoellipse/blob/main/Analytical.py) (Analytic plot), [`GradientDescent.py`](https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py) (Gradient plot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analytic["Analytic method"]
  node_analytic_solver["Projection solver<br/>[Analytical.py]"]
  node_quartic_roots["Polynomial roots"]
  node_analytic_tangent["Tangent direction<br/>[Analytical.py]"]
end

subgraph group_iterative["Iterative method"]
  node_gradient_objective["Distance objective<br/>[GradientDescent.py]"]
  node_finite_difference["Finite difference<br/>[GradientDescent.py]"]
  node_gradient_search["Backtracking descent<br/>[GradientDescent.py]"]
end

subgraph group_visualization["Visualization"]
  node_analytic_view["Analytic plot<br/>[Analytical.py]"]
  node_gradient_geometry["Ellipse geometry<br/>[GradientDescent.py]"]
  node_gradient_tangent["Tangent direction<br/>[GradientDescent.py]"]
  node_gradient_view["Gradient plot<br/>[GradientDescent.py]"]
end

node_runner(("Script runner"))
node_plotting["Plotting library"]

node_runner -.->|"runs script"| node_analytic_solver
node_analytic_solver -->|"solves polynomial"| node_quartic_roots
node_analytic_view -->|"gets projection"| node_analytic_solver
node_analytic_view -->|"gets tangent"| node_analytic_tangent
node_analytic_view -->|"draws result"| node_plotting
node_runner -.->|"runs script"| node_gradient_search
node_gradient_search -->|"estimates slope"| node_finite_difference
node_finite_difference -->|"samples distance"| node_gradient_objective
node_gradient_search -->|"tests steps"| node_gradient_objective
node_gradient_view -->|"computes ellipse"| node_gradient_geometry
node_gradient_view -->|"gets tangent"| node_gradient_tangent
node_gradient_view -->|"draws result"| node_plotting

click node_analytic_solver "https://github.com/donrudd/pointtoellipse/blob/main/Analytical.py"
click node_analytic_tangent "https://github.com/donrudd/pointtoellipse/blob/main/Analytical.py"
click node_analytic_view "https://github.com/donrudd/pointtoellipse/blob/main/Analytical.py"
click node_gradient_objective "https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py"
click node_finite_difference "https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py"
click node_gradient_search "https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py"
click node_gradient_geometry "https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py"
click node_gradient_tangent "https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py"
click node_gradient_view "https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_analytic_solver,node_quartic_roots,node_analytic_tangent toneBlue
class node_gradient_objective,node_finite_difference,node_gradient_search toneAmber
class node_analytic_view,node_gradient_geometry,node_gradient_tangent,node_gradient_view toneMint
class node_runner,node_plotting toneIndigo
```

## Components

### Analytic method

- [Projection solver](https://github.com/donrudd/pointtoellipse/blob/main/Analytical.py): `Analytical.py`
- **Polynomial roots**
- [Tangent direction](https://github.com/donrudd/pointtoellipse/blob/main/Analytical.py): `Analytical.py`

### Iterative method

- [Distance objective](https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py): `GradientDescent.py`
- [Finite difference](https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py): `GradientDescent.py`
- [Backtracking descent](https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py): `GradientDescent.py`

### Visualization

- [Analytic plot](https://github.com/donrudd/pointtoellipse/blob/main/Analytical.py): `Analytical.py`
- [Ellipse geometry](https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py): `GradientDescent.py`
- [Tangent direction](https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py): `GradientDescent.py`
- [Gradient plot](https://github.com/donrudd/pointtoellipse/blob/main/GradientDescent.py): `GradientDescent.py`

### Other components

- **Script runner**
- **Plotting library**

## Connections

- Script runner → Projection solver: runs script
- Projection solver → Polynomial roots: solves polynomial (evidence: `Analytical.py`)
- Analytic plot → Projection solver: gets projection (evidence: `Analytical.py`)
- Analytic plot → Tangent direction: gets tangent (evidence: `Analytical.py`)
- Analytic plot → Plotting library: draws result (evidence: `Analytical.py`)
- Script runner → Backtracking descent: runs script
- Backtracking descent → Finite difference: estimates slope (evidence: `GradientDescent.py`)
- Finite difference → Distance objective: samples distance (evidence: `GradientDescent.py`)
- Backtracking descent → Distance objective: tests steps (evidence: `GradientDescent.py`)
- Gradient plot → Ellipse geometry: computes ellipse (evidence: `GradientDescent.py`)
- Gradient plot → Tangent direction: gets tangent (evidence: `GradientDescent.py`)
- Gradient plot → Plotting library: draws result (evidence: `GradientDescent.py`)
