Chris Collins

Tools · math

Conics, pixels and metrics

Coordinate geometry you can drag: conics from a focus, a directrix and an eccentricity slider (and from slicing a cone), a parabolic reflector, Bresenham, DDA and anti-aliased lines stepped pixel by pixel with the decision value D, Lᵖ unit circles and A* heuristics, the inscribed angle and Thales, a line meeting a circle via the discriminant, and world-to-screen mapping.

Added

How to use it

Seven tabs, each a picture you can drag with the numbers beside it. Every tab has a Book examples menu with the worked examples from Mathematics, Reconnected.

How to use it

  • Conics — Focus & directrix: drag the eccentricity slider e. The orange curve is every point P whose distance to the focus F is e times its distance to the directrix (dashed). Below 1 it is an ellipse, at exactly 1 a parabola, above 1 a hyperbola (both branches, with its asymptotes). Drag the focus, the directrix, or the red point P along the curve: the panel shows |PF|, the distance to the directrix, their ratio e, the standard-form equation, the centre, a, b and c = e·a, the second focus and directrix, and |PF| + |PF₂| = 2a (ellipse) or the difference (hyperbola). Slice a cone: tilt a plane through a double cone of half-angle α. The slice is shown in 3-D (drag to turn it) and face on; its eccentricity is sin θ ÷ cos α, so it becomes a parabola exactly when the tilt θ reaches 90° − α.

  • Reflector — a dish of given width and depth has focal length f = (width/2)² ÷ (4 · depth). Parallel rays reflect through the focus; tilt them off the axis to see them miss (the spread on the focal line is shown). Tick Headlight to run it backwards: light from the focus leaves as a parallel beam. One point of the dish shows its equal distances to the focus and the directrix.

  • Pixels — drag the start (green) and end (purple) pixels, or tap a cell to move the nearer one. Step through with ◀ ▶ (or Play) and watch the table:

    • Midpoint (D) — the book’s decision-variable procedure, extended to every direction by stepping along the longer axis. D starts at 2Δy − Δx; D > 0 means the true line passes above the midpoint (orange dot), so step diagonally. Rows where D = 0 are ties.

    • Bresenham all-octant — the book’s production version with one error term err and e2 = 2·err. It breaks ties the other way, and the tool says which pixels differ.

    • DDA — equal steps in floating point, rounded (halves round up; Python’s round() would round them to even).

    • Anti-aliased — Xiaolin Wu style: two pixels per column, shaded by closeness, adding to 1.

  • Metrics & A* — the slider sets p (far right is ∞). The thick orange curve is the Lᵖ unit circle around A; dashed: L¹ (diamond), L² (circle), L∞ (square). Drag A and B to compare the three distances (always Chebyshev ≤ Euclidean ≤ Manhattan). Below 1 the “circle” caves in and is no longer a metric. The A* panel searches a 24 × 14 grid with 4 moves (rook) or 8 (king, every move costing 1, no cutting wall corners) and compares the number of nodes expanded and the path found with each heuristic.

  • Inscribed angle — drag A, B and V around the rim. ∠AVB is half the arc it stands on (the arc AB not containing V), so it stays fixed while V stays on one arc and jumps to 180° minus it on the other. Put A and B at opposite ends of a diameter for Thales' right angle. Tick the fourth point W for a cyclic quadrilateral.

  • Line & circle — type the line as y = m·x + c (or x = constant) and the circle’s centre and radius; fractions such as -3/4 are fine. The panel substitutes the line into the circle, shows the quadratic A x² + B x + C = 0 and its discriminant Δ, and classifies the line as a secant (Δ > 0), tangent (Δ = 0) or miss (Δ < 0), with the points. Drag the orange handle to slide the line and the black dot to move the circle.

  • World → screen — a W × H canvas at s pixels per unit, centred on (cx, cy): col = W/2 + s(x − cx), row = H/2 − s(y − cy). Drag the red point or type it; type a pixel “col, row” to convert back.

⛶ Full screen (or F) gives the current tab’s drawing the whole screen — the browser’s full screen where it is allowed, otherwise a full-window layer (iPhone); the plot widens or deepens its view to fill the space and is redrawn as the window changes, and ◫ Panels hides the controls beside it. Escape leaves.

Limits

Everything is drawn in floating point; a tangent is recognised when Δ is zero to about nine significant figures. The conic directrix is horizontal or vertical (no rotated conics). The pixel grid is for short lines (it fits itself to the endpoints). A* uses unit move costs only (no √2 diagonals) and fixed layouts; diagonal moves never cut a wall corner, and ties in f are broken by the smaller h, then by the order nodes were found, so other implementations may expand a few nodes more or fewer.

Companion to chapter 10, Coordinate geometry (conic sections, world to screen, Bresenham’s algorithm, distance metrics), chapter 9, Circles (the inscribed angle) and chapter 8, Quadratics (the reflective property) of Mathematics, Reconnected.

Linking to an example

Share link (under the title) copies a URL that reopens the tool exactly as you have it. You can also write links by hand: open a book example with ?example= and the tab with #tab, and add any of the parameters below to change one setting, for example ?e=0.5&fx=0&fy=0&d=-2&dir=x#conics or ?example=ch10-bresenham&algo=dda#pixels. Values are plain numbers; where a fraction is useful (m=-3/4, e=5/3) type it as is. Write a plus sign as %2B or leave it out (x0=3): a bare + in a URL means a space, which the tool ignores. Settings not in the link take their defaults. The tabs are #conics, #reflector, #pixels, #metrics, #angles, #line-circle and #viewport; an ?example= link without one opens the example’s own tab.

Parameter Meaning Example

e

eccentricity

0.8, 5/3

fx, fy

the focus

4, 0

d, dir

the directrix: x = d (dir=x) or y = d (dir=y)

6.25, x

mode

conics view: focus or cone

cone

tilt, cone

slicing plane tilt θ and cone half-angle α, in degrees

60, 30

width, depth

dish width (across) and depth

60, 9

rays, off, beam

number of rays, their angle off the axis (degrees), headlight mode (1)

9, 5, 1

x0, y0, x1, y1

the line’s start and end pixels

1, 1, 8, 4

algo

mid (midpoint, D), bres (all-octant), dda, wu (anti-aliased)

mid

step

which step to show (0 is the first; large shows all)

0

p

the Lᵖ exponent, or inf

1, inf

ax, ay, bx, by

the centre A and the point B

1, 1, 5, 4

moves, heur, map

A*: 4 or 8 moves; heuristic zero, manhattan, euclid, cheb; layout open, wall, trap, rooms

8, manhattan, rooms

A, B, V

rim positions in degrees

220, 320, 100

quad

the fourth point W in degrees, or off

270

m, c

the line y = m·x + c

-3/4, 25/4

vert

a vertical line x = vert instead (empty for y = m·x + c)

3

h, k, r

the circle’s centre and radius

0, 0, 5

W, H, scale

canvas width and height (px) and pixels per unit

800, 600, 50

cx, cy

the world point at the centre of the canvas

0, 0

x, y

the world point to map

3, 2

The example= presets:

Preset What it shows

ch10-focus-directrix

The lab: focus at the origin, directrix x = −2, e = 0.8 — drag e through 1

ch10-ellipse

x²/25 + y²/9 = 1 from its focus (4, 0) and directrix x = 25/4, e = 0.8

ch10-hyperbola

x²/9 − y²/16 = 1 from focus (5, 0), directrix x = 9/5, e = 5/3

ch10-parabola

x² = −12y: focus (0, −3), directrix y = 3

ch10-parabola-quarter

y = x²/4: focus (0, 1), directrix y = −1

ch10-cone-ellipse

A 30° cone sliced at 40°: an ellipse

ch10-cone-parabola

Sliced at 60° = 90° − 30°, parallel to the side: a parabola

ch10-cone-hyperbola

Sliced at 80°, through both nappes: a hyperbola

ch08-dish

A dish 60 cm across and 9 cm deep: the receiver at f = 25 cm

ch08-headlight

A bulb at the focus makes a parallel beam

ch08-dish-offaxis

Rays 5° off the axis no longer meet at one point

ch10-bresenham

The worked example (1, 1) → (8, 4), from step 0, with D

ch10-bresenham-exercise

The exercise (0, 0) → (5, 2), from step 0

ch10-bresenham-tie

The tie case (0, 0) → (4, 2): D = 0 twice; the two versions differ

ch10-bresenham-all

The all-octant version on (0, 0) → (10, 4)

ch10-bresenham-steep

A steep line (0, 0) → (2, 5)

ch10-bresenham-left

Leftward and down: (3, 3) → (−2, 1)

ch10-dda

DDA on a near-horizontal line

ch10-antialiased

Anti-aliased on the same line

ch10-metrics

A(1, 1) to B(5, 4): Euclidean 5, Manhattan 7, Chebyshev 4

ch10-taxicab

p = 1: the unit circle is a diamond

ch10-chebyshev

p = ∞: the unit circle is a square

ch10-astar-4

A* with 4 moves: Manhattan is exact and expands the fewest nodes

ch10-astar-8

A* with 8 moves: Manhattan overestimates and returns 26 moves where 24 will do

ch09-inscribed

The lab: A = 220°, B = 320°; drag V

ch09-thales

AB a diameter: Thales' right angle

ch09-cyclic

A cyclic quadrilateral: opposite angles add to 180°

ch10-secant

y = x + 1 meets x² + y² = 25 at (3, 4) and (−4, −3)

ch10-tangent

The tangent 3x + 4y = 25 at (3, 4): Δ = 0

ch10-line-exercise

y = 7 − x meets the circle at (3, 4) and (4, 3)

ch10-miss

y = x + 8 misses: Δ < 0

ch10-viewport

800 × 600 at 50 px per unit: (3, 2) → (550, 200)

ch10-viewport-corner

(−8, −6) → the corner pixel (0, 600)

ch10-viewport-exercise

640 × 480 at 20 px per unit: (−4, 3) → (240, 180)

Opening a link replaces the settings this browser had saved for the tool; a Restore my settings button appears so you can undo that.

Runs entirely in your browser; nothing you type leaves this page.