For physics authors, the most reliable use of AI is not to generate final raster images, but to generate editable diagram code that can be corrected, refined, version-controlled, reused, and exported cleanly as PDF/SVG/PNG. This produces figures that remain mathematically faithful (angles, forces, labels, geometry) while keeping the author in full control of final presentation.

Principle
Use AI to draft editable figure source (code or SVG objects), not final images.
Then refine once and reuse across hundreds of problems with consistent style.

Four Stacks for AI-Assisted Editable Figures

TikZ / PGF
Precise 2D textbook diagrams with LaTeX labels and consistent academic styling.
Asymptote
Advanced 3D scientific diagrams with strong control of perspective, surfaces, and geometry.
SVG + Inkscape / Ipe
Best correction layer for near-correct AI output: visually editable vector objects with manual polish.
JSXGraph
Interactive, slider-driven teaching diagrams for web-based physics content and demonstrations.

TikZ / PGF Stack

Best for precise 2D academic physics diagrams
Use TikZ when the figure must be 2D, label-heavy, geometry-based, and fully consistent with LaTeX typography.

Ideal problem areas

  • classical mechanics, electromagnetism, optics, circuits, thermodynamics,
  • quantum mechanics schematics and conceptual diagrams,
  • coordinate-geometry-based physics problems.

Example problem patterns

  • ball sliding on a sphere: circle + bead + radius + angle $\theta$ + forces $mg$ and $N$ + tangent $v$,
  • inclined plane: block + slope angle + normal + friction + resolved components,
  • pendulum: support + string + bob + vertical reference + tension $T$ + weight $mg$,
  • ray diagrams: principal axis + lens + focal points + rays + image construction,
  • electric field sketches: charges + field lines + equipotentials.

Strengths

  • clean textbook style, strong label control, and consistent line aesthetics,
  • perfect integration with LaTeX math,
  • code-editable and version-controllable,
  • easy to maintain a unified style across an entire book.

Weaknesses

  • not ideal for complex 3D geometry and perspective,
  • coordinate tuning may be needed,
  • nontrivial learning curve,
  • highly artistic illustrations are difficult.

Best outputs PDF, SVG, PNG, LaTeX-integrated figures.

Asymptote Stack

Best for 3D and geometry-heavy technical figures
Use Asymptote when spatial geometry, surfaces, projections, rotations, and controlled perspective are essential.

Ideal problem areas

  • 3D mechanics, rigid body motion, vector fields in space,
  • spherical/cylindrical coordinates, scattering geometry,
  • nuclear and particle physics collision/track schematics,
  • advanced electromagnetism (3D field geometry), wave surfaces.

Example problem patterns

  • spherical coordinates: axes + $r$ + $\theta$ + $\phi$ + projections on the $xy$-plane,
  • rigid-body rotation: body + rotation axis + $\boldsymbol\omega$ + torque + $\mathbf{L}$,
  • scattering: incident line + scattered line + impact parameter + scattering angle,
  • 3D magnetic field around a loop: loop in perspective + field curves + symmetry axis,
  • particle collisions: incoming beams + outgoing tracks + angles + detector geometry.

Strengths

  • strong 3D capability with publication-grade vector output,
  • reliable perspective control and surface drawing,
  • excellent for advanced theoretical physics figures.

Weaknesses

  • more technical and code-heavy than TikZ,
  • smaller user ecosystem,
  • may be excessive for simple force diagrams.

Best outputs PDF, EPS, SVG, PNG.

SVG + Inkscape / Ipe Stack

Best correction and polishing layer for near-correct AI output
Use SVG when you need PowerPoint-like control with true vector precision for final alignment, spacing, and readability.

Ideal problem areas

  • diagrams requiring final visual polish,
  • label-heavy sketches where spacing and arrow placement matter,
  • cross-platform figures for Word, PowerPoint, LaTeX, and web,
  • semi-technical illustrations where aesthetics dominates exact geometry.

Example problem patterns

  • ball on sphere: adjust ball location, arcs, arrows, label offsets, line weights, contrast,
  • complex free-body diagram: pulley path, tensions, alignment, consistent arrow lengths,
  • EM illustration: Lorentz-force direction, circular path symmetry, field symbols density,
  • nuclear reaction sketches: incoming neutron, compound nucleus, fission fragments, emitted neutrons.

Strengths

  • maximum flexibility for manual correction,
  • ideal for fixing “almost correct” AI output quickly,
  • excellent for final polishing and consistent visual clarity,
  • exports cleanly to PDF/PNG/SVG/EPS.

Weaknesses

  • less systematic than code-first approaches,
  • style consistency must be managed carefully across a book,
  • manual editing can become time-consuming if overused,
  • complex mathematics is less elegant than LaTeX-native workflows.

Best outputs SVG, PDF, PNG, EPS.

JSXGraph Stack

Best for interactive teaching figures
Use JSXGraph when diagrams must be parameter-dependent, slider-based, or dynamically manipulable for learning and demonstrations.

Ideal problem areas

  • interactive mechanics diagrams and geometry problems,
  • optics simulations (movable object and image),
  • projectile and circular motion,
  • oscillations and wave motion,
  • electric/magnetic field visualization with adjustable parameters.

Example problem patterns

  • ball sliding on sphere: draggable point along a circle, live $\theta$, changing tangent and normal directions,
  • projectile motion: sliders for $u$, $\theta$, $g$, live range and height,
  • lens ray tracing: movable object, variable focal length, real/virtual transitions,
  • SHM: oscillating point plus $x(t)$, $v(t)$, $a(t)$ plots,
  • Lorentz-force geometry: adjustable $q$, $m$, $v$, $B$ with circular trajectory.

Strengths

  • strong conceptual clarity through interactivity,
  • sliders expose parameter dependence,
  • excellent for web courses and demonstrations.

Weaknesses

  • not primarily designed for print workflows,
  • requires a JavaScript/web environment,
  • static exports require extra steps and are not the main goal.

Best outputs Interactive HTML, web app, SVG/PNG screenshots.