►V Reference
On this page:
58.15.1 Coordinate and Calculus Helpers
graph-point
graph-label
vertical-line-to-graph
horizontal-line-to-graph
tangent-line
secant-line
secant-slope-group
area-under-graph
area-between-curves
riemann-rectangles
58.15.2 Deterministic Traced Paths
traced-path
9.3

58.15 Graph Helpers and Traced Paths🔗ℹ

These helpers construct axes-aware graph annotations and areas from numeric procedures. Tangents are numerical approximations, not symbolic derivatives. traced-path is driven by an explicit phase value and reconstructs its sampled history without depending on previously rendered frames.

See also Function, Parametric, and Data Plots, ODE Trajectories and Streamlines.

    58.15.1 Coordinate and Calculus Helpers

    58.15.2 Deterministic Traced Paths

58.15.1 Coordinate and Calculus Helpers🔗ℹ

Coordinate and calculus helpers construct static, axes-aware teaching diagrams. They evaluate numeric procedures during construction and return ordinary immutable Visuals or points. For an animated construction, place one of these calls inside derived-visual and rebuild it from the sampled parameter value.

procedure

(graph-point axes function x) → vec2?

  axes : axes-visual?
  function : (procedure-arity-includes/c 1)
  x : finite-real?
Evaluates function at numeric x and converts the resulting coordinate through axes-coordinates->point. The result is in the axes’ containing world coordinate system.

The result is a point, not a rendered marker.

Examples:
> (define sample
    (graph-point (axes #:id 'coordinates) (lambda (x) (* x x)) 1))
> (vec2? sample)

#t

procedure

(graph-label axes    
  function    
  x    
  label    
  #:id id    
  [#:offset offset    
  #:font-size font-size    
  #:color color]) → text-visual?
  axes : axes-visual?
  function : (procedure-arity-includes/c 1)
  x : finite-real?
  label : string?
  id : symbol?
  offset : vec2? = (vec2 1/5 1/5)
  font-size : finite-real? = 1/4
  color : any/c = "black"
Creates plain text at (graph-point axes function x) plus the world-space offset.

procedure

(vertical-line-to-graph axes 
  function 
  x 
  #:id id 
  [#:baseline baseline 
  #:opacity opacity 
  #:stroke stroke 
  #:stroke-width stroke-width]) 
 → path-visual?
  axes : axes-visual?
  function : (procedure-arity-includes/c 1)
  x : finite-real?
  id : symbol?
  baseline : finite-real? = 0
  opacity : opacity? = 1
  stroke : any/c = "gray"
  stroke-width : (and/c finite-real? (>=/c 0)) = 2
Creates the axes-aware vertical projection from (x, baseline) to (x, function(x)). On a logarithmic y axis, the default baseline is the minimum visible y value rather than zero.

procedure

(horizontal-line-to-graph axes 
  function 
  x 
  #:id id 
  [#:baseline baseline 
  #:opacity opacity 
  #:stroke stroke 
  #:stroke-width stroke-width]) 
 → path-visual?
  axes : axes-visual?
  function : (procedure-arity-includes/c 1)
  x : finite-real?
  id : symbol?
  baseline : finite-real? = 0
  opacity : opacity? = 1
  stroke : any/c = "gray"
  stroke-width : (and/c finite-real? (>=/c 0)) = 2
Creates the horizontal projection from (baseline, function(x)) to the graph point. On a logarithmic x axis, the default baseline is the minimum visible x value.

procedure

(tangent-line axes    
  function    
  x    
  #:id id    
  [#:dx dx    
  #:length length    
  #:opacity opacity    
  #:stroke stroke    
  #:stroke-width stroke-width]) → path-visual?
  axes : axes-visual?
  function : (procedure-arity-includes/c 1)
  x : finite-real?
  id : symbol?
  dx : (and/c finite-real? (>/c 0)) = 1/100
  length : (and/c finite-real? (>/c 0)) = 2
  opacity : opacity? = 1
  stroke : any/c = "crimson"
  stroke-width : (and/c finite-real? (>=/c 0)) = 3
Estimates a tangent with the symmetric numeric difference at x. The visible segment has world-space length and is centred on the graph point. It is a numeric approximation, not symbolic differentiation.

procedure

(secant-line axes    
  function    
  x    
  dx    
  #:id id    
  [#:opacity opacity    
  #:stroke stroke    
  #:stroke-width stroke-width]) → path-visual?
  axes : axes-visual?
  function : (procedure-arity-includes/c 1)
  x : finite-real?
  dx : (and/c finite-real? (not/c zero?))
  id : symbol?
  opacity : opacity? = 1
  stroke : any/c = "darkorange"
  stroke-width : (and/c finite-real? (>=/c 0)) = 3
Connects the graph points at x and (+ x dx).

procedure

(secant-slope-group axes 
  function 
  x 
  dx 
  #:id id 
  [#:opacity opacity 
  #:secant-stroke secant-stroke 
  #:guide-stroke guide-stroke 
  #:stroke-width stroke-width 
  #:marker-radius marker-radius]) 
 → group-visual?
  axes : axes-visual?
  function : (procedure-arity-includes/c 1)
  x : finite-real?
  dx : (and/c finite-real? (not/c zero?))
  id : symbol?
  opacity : opacity? = 1
  secant-stroke : any/c = "darkorange"
  guide-stroke : any/c = "gray"
  stroke-width : (and/c finite-real? (>=/c 0)) = 3
  marker-radius : (and/c finite-real? (>/c 0)) = 1/10
Builds a secant, endpoint markers, dashed Δx/Δy legs, and labels. Its stable children are named from id: id-secant, id-delta-x, id-delta-y, id-first-point, id-second-point, and the two corresponding label names.

procedure

(area-under-graph axes    
  function    
  #:id id    
  [#:x-min x-min    
  #:x-max x-max    
  #:baseline baseline    
  #:sample-count sample-count    
  #:opacity opacity    
  #:fill fill    
  #:stroke stroke    
  #:stroke-width stroke-width]) → path-visual?
  axes : axes-visual?
  function : (procedure-arity-includes/c 1)
  id : symbol?
  x-min : (or/c finite-real? false/c) = #f
  x-max : (or/c finite-real? false/c) = #f
  baseline : finite-real? = 0
  sample-count : (and/c exact-integer? (>=/c 2)) = 101
  opacity : opacity? = 2/5
  fill : any/c = "cornflowerblue"
  stroke : any/c = #f
  stroke-width : (and/c finite-real? (>=/c 0)) = 0
Samples one finite function and closes the result to baseline. The result copies the current axes transform and uses one closed path subpath.

procedure

(area-between-curves axes 
  first-function 
  second-function 
  #:id id 
  [#:x-min x-min 
  #:x-max x-max 
  #:sample-count sample-count 
  #:opacity opacity 
  #:fill fill 
  #:stroke stroke 
  #:stroke-width stroke-width]) 
 → path-visual?
  axes : axes-visual?
  first-function : (procedure-arity-includes/c 1)
  second-function : (procedure-arity-includes/c 1)
  id : symbol?
  x-min : (or/c finite-real? false/c) = #f
  x-max : (or/c finite-real? false/c) = #f
  sample-count : (and/c exact-integer? (>=/c 2)) = 101
  opacity : opacity? = 2/5
  fill : any/c = "mediumpurple"
  stroke : any/c = #f
  stroke-width : (and/c finite-real? (>=/c 0)) = 0
Samples two finite functions over one domain and returns their closed filled band in axes-local geometry.

procedure

(riemann-rectangles axes    
  function    
  #:id id    
  [#:x-min x-min    
  #:x-max x-max    
  #:count count    
  #:baseline baseline    
  #:opacity opacity    
  #:fill fill    
  #:stroke stroke    
  #:stroke-width stroke-width]) → path-visual?
  axes : axes-visual?
  function : (procedure-arity-includes/c 1)
  id : symbol?
  x-min : (or/c finite-real? false/c) = #f
  x-max : (or/c finite-real? false/c) = #f
  count : exact-positive-integer? = 8
  baseline : finite-real? = 0
  opacity : opacity? = 2/5
  fill : any/c = "seagreen"
  stroke : any/c = "darkgreen"
  stroke-width : (and/c finite-real? (>=/c 0)) = 1
Creates one closed midpoint rectangle per display-space interval. On a logarithmic x axis the rectangles are evenly spaced in log display coordinates, not by raw numeric width.

58.15.2 Deterministic Traced Paths🔗ℹ

procedure

(traced-path phase 
  position 
  #:id id 
  [#:start-time start-time 
  #:sample-count sample-count 
  #:trail-length trail-length 
  #:dissipate? dissipate? 
  #:minimum-opacity minimum-opacity 
  #:opacity opacity 
  #:stroke stroke 
  #:stroke-width stroke-width]) 
 → derived-visual?
  phase : (or/c symbol? scene-parameter?)
  position : (-> derived-context? finite-real? vec2?)
  id : symbol?
  start-time : finite-real? = 0
  sample-count : (and/c exact-integer? (>=/c 2)) = 121
  trail-length : (or/c false/c (and/c finite-real? (>=/c 0)))
   = #f
  dissipate? : boolean? = #f
  minimum-opacity : opacity? = 0
  opacity : opacity? = 1
  stroke : any/c = "crimson"
  stroke-width : (and/c finite-real? (>=/c 0)) = 3
Creates a locus from an explicit scalar scene value. At every sampled frame, Animate calls position at deterministically spaced times from start-time to the current value of phase. Therefore a frame at time t is independent of previously rendered frames; this is unlike a mutable frame-history trail. The procedure receives the same read-only derived context as other derived Visuals and must return a vec2 for every sampled time.

With trail-length, the interval instead begins at the larger of start-time and current phase minus that length. With dissipate?, the resolved trace is an ordinary group of consecutive path segments whose opacity rises from minimum-opacity to opacity; otherwise it is one ordinary path Visual. No automatic tracking of arbitrary Visual motion or adaptive/discontinuity sampling is attempted.