▼V Reference
52 Find a task or a name
53 Modules to require
54 Scenes and sampling
55 Scene states
56 Animation requests
57 Native model details
58 Visuals
59 Geometry
60 Number Lines and Coordinate Decorations
61 Point Markers, Scatter Plots, and Filled Areas
62 Probability and Statistical Diagrams
63 Calculus lessons
64 Colors
65 Slides
66 Slide command-line tools
67 Source Programs and Authored Timelines
68 Interactive Preview and Inspection
69 Preview controls and diagnostics
70 Projects and Final Rendering
71 Project execution and cache details
72 Pict Renderer Protocol
73 3D reference map
74 3D:   Objects, groups, and paths
75 3D:   Cameras and projection
76 3D:   Views inside a Scene
77 3D:   Animating 3D objects
78 3D:   Animating the 3D camera
79 3D:   Cuts, caps, and section measurements
80 3D:   Supplementary surface, section, and annotation bindings
81 3D:   Cuts, sections, and numerical volume
82 3D:   Vectors
83 3D:   Linear maps and rotations
84 3D:   Affine transforms
85 3D:   Bounds, rays, and planes
86 3D:   Spatial maps and homotopies
87 3D:   Materials and lights
88 3D:   Lighting inspection
89 3D:   Shadow descriptors and stable bounds
90 3D:   Finite-light animation
91 3D:   Software finite-light evaluation
92 3D:   Colour space and final output
93 3D:   Relations and geometric annotations
94 3D:   Projected labels
95 3D:   Textured billboards
96 3D:   Spatial curves and vector diagrams
97 3D:   Spatial anchors and label layout
98 3D:   Anchors and projected labels
99 3D:   Parametric surfaces and calculus
100 3D:   Adaptive, trimmed, and implicit surfaces
101 3D:   Constructive solids
102 3D:   Surface constructors and queries
103 3D:   Meshes
104 3D:   Triangle topology
105 3D:   Polygonal faces
106 3D:   Deterministic convex hulls
107 3D:   Polyhedral duals
108 3D:   Schlegel diagrams and polyhedral nets
109 3D:   Conservative mesh correspondence
110 3D:   Topology-safe mesh matching
111 3D:   Checking and repairing mesh orientation
112 3D:   Clipping, sections, and transparency
113 3D:   Prepared spatial ODE trajectories and vector fields
114 3D:   Seeds and streamline sets
115 3D:   Poincare sections and return maps
116 3D:   Equilibria and local linearization
117 3D:   Flow maps and volume change
118 3D:   Drawing and inspecting trajectories
119 3D:   Reading prepared trajectories
120 3D:   Drawing vector fields and particles
121 3D:   Trajectory display
122 3D:   Spatial inspection and exact picking
123 3D:   Retained renderer backends
124 3D:   Compiled geometry and instances
125 3D:   Frame requests and results
126 3D:   Software rendering and statistics
127 3D:   Optional Racket/  Open  GL backend
128 Experimental Derived Visuals
129 Source Package Hygiene
On this page:
prepare-ode-trajectory3d
ode-field3d
fixed-rk4-solver3d
adaptive-rk45-solver3d
ode-event3d
ode-event-hit3d?
trajectory-termination3d
trajectory-termination3d?
trajectory-termination-hit3d?
streamline-sample-policy3d
prepare-streamline3d
prepared-streamline3d?
adaptive-streamline3d
9.3

113 3D: Prepared spatial ODE trajectories and vector fields🔗ℹ

3D reference map · First 3D picture

Prepared spatial trajectories are immutable data with event-aware preparation, explicit stopping policies, display-ready adaptive streamlines, and deterministic seed sets. prepare-ode-trajectory3d records dense RK4 or Dormand–Prince segments once; subsequent position, tangent, arc-length, and event-hit lookup accepts any supported time in any order and never calls the author field. A field accepts either (field x y z) or (field time x y z) and must return exactly one finite vec3. Use ode-field3d when the field needs an explicit cache identity or when its autonomous status matters to later flow analysis.

An ode-event3d evaluates a finite scalar on the stored trajectory while it is prepared. Its procedure accepts either (event point) or (event time point). A sign-changing root is found by deterministic bisection of the dense Hermite segment; a zero at a shared accepted node is reported once. Event directions always mean increasing physical time, including when the requested range runs backward. A terminal event becomes a canonical end node and shortens the relevant side of the returned range; nonterminal hits remain in the immutable hit vector.

trajectory-termination3d makes every other stopping condition explicit: a symmetric time budget about the seed, an AABB exit, an accumulated arc-length budget, a low-speed threshold, a maximum step count, policy-owned events, and a choice between reporting or tolerating an author-field failure. Terminal events are checked on every accepted solver step: the first root clips that step and prevents later steps from being accepted. Other termination policies are resolved on the retained dense Hermite segments and recorded as immutable termination hits. An AABB exit reports the outward face normal. On one branch, simultaneous candidates are ordered as field failure, terminal event in declaration order, bounds exit, arc-length limit, low speed, maximum steps, then the requested time limit. The returned range ends exactly at the selected dense point when that condition can be located inside a segment.

flow-particle3d is a semantic spatial relation. Before an image or preview worker resolves it, Animate samples its requested phase values into an immutable table. Thus worker rendering reads positions and tangents only; it does not evaluate the field procedure. The fixed solver’s #:checkpoint-every value is diagnostic preparation metadata; it does not change lookup cost.

prepare-streamline3d uses the same dense prepared trajectory but adds an explicit choice of parameterization. 'time means dp/ds = F(p), preserving the field’s speed. 'arc-length means dp/ds = F(p)/||F(p)||; it therefore requires an autonomous field and ends at an equilibrium rather than inventing a direction. The prepared display samples are recursively subdivided in world coordinates until the chord error, tangent turn, and segment length satisfy an immutable streamline-sample-policy3d. Camera zoom does not change their points. For a bidirectional streamline, the returned samples run from the backward end through one copy of the seed to the forward end; the seed index and per-branch diagnostics remain inspectable.

(define lorenz-path
  (prepare-ode-trajectory3d
   (ode-field3d
    (lambda (x y z) (vec3 (* 10 (- y x)) (- (* x (- 28 z)) y)
                          (- (* x y) (* 8/3 z))))
    #:cache-key 'lorenz-10-28-8/3)
   (vec3 0 1 21/20)
   #:time-range (cons 0 20)
   #:solver (adaptive-rk45-solver3d #:relative-tolerance 1e-6)))
 
(define phase (parameter 'time 0))
(flow-particle3d lorenz-path phase #:id 'particle #:tangent-length 1)

procedure

(prepare-ode-trajectory3d 
  field 
  seed 
  #:time-range time-range 
  [#:step-size step-size 
  #:checkpoint-every checkpoint-every 
  #:solver solver 
  #:events events 
  #:termination termination 
  #:cancellation-token cancellation-token]) 
 → ode-trajectory3d?
  field : any/c
  seed : vec3?
  time-range : (cons/c finite-real? finite-real?)
  step-size : (and/c finite-real? positive?) = 1/20
  checkpoint-every : exact-positive-integer? = 16
  solver : any/c = #f
  events : list? = '()
  termination : (or/c false/c trajectory-termination3d?) = #f
  cancellation-token : any/c = #f
Prepares one immutable spatial trajectory over the closed range (cons start-time end-time). The seed is at time zero; the range may extend on either side of it. Terminal event hits may shorten that closed range. #:events and policy-owned events form one declaration-ordered set whose identifiers must be distinct. A preview cancellation token is checked before and between solver steps and before event root refinement; cancellation raises rather than returning a partial trajectory.

procedure

(ode-field3d procedure    
  [#:cache-key cache-key    
  #:autonomous? autonomous?    
  #:parallel-safe? parallel-safe?]) → any/c
  procedure : procedure?
  cache-key : any/c = #f
  autonomous? : (or/c boolean? 'auto) = 'auto
  parallel-safe? : boolean? = #f
Constructs explicit author-time field metadata. The procedure is used only during numerical preparation; a prepared trajectory retains its cache key but not this procedure. In 'auto mode, a three-argument field is autonomous and a four-argument field is non-autonomous; a procedure accepting both arities requires an explicit declaration. parallel-safe? is an author assertion permitting #:parallel? 'auto preparation to use worker threads. It defaults to #f.

procedure

(fixed-rk4-solver3d [#:step-size step-size]) → any/c

  step-size : positive? = 1/20
Constructs fixed-step RK4 solver settings.

procedure

(adaptive-rk45-solver3d 
  [#:relative-tolerance relative-tolerance 
  #:absolute-tolerance absolute-tolerance 
  #:initial-step initial-step 
  #:minimum-step minimum-step 
  #:maximum-step maximum-step 
  #:maximum-steps maximum-steps]) 
 → any/c
  relative-tolerance : positive? = 1e-6
  absolute-tolerance : positive? = 1e-9
  initial-step : positive? = 1/20
  minimum-step : positive? = 1e-9
  maximum-step : positive? = 1
  maximum-steps : exact-positive-integer? = 100000
Constructs immutable adaptive RK45 settings. An adaptive-rk45 setting is also accepted.

procedure

(ode-event3d #:id id 
  #:function function 
  [#:direction direction 
  #:terminal? terminal? 
  #:value-tolerance value-tolerance 
  #:time-tolerance time-tolerance 
  #:maximum-iterations maximum-iterations 
  #:cache-key cache-key 
  #:parallel-safe? parallel-safe? 
  #:root-kind root-kind 
  #:initial-subdivisions initial-subdivisions 
  #:maximum-depth maximum-depth]) 
 → any/c
  id : symbol?
  function : procedure?
  direction : (or/c 'any 'increasing 'decreasing) = 'any
  terminal? : boolean? = #t
  value-tolerance : positive? = 1e-9
  time-tolerance : positive? = 1e-9
  maximum-iterations : exact-positive-integer? = 64
  cache-key : any/c = #f
  parallel-safe? : boolean? = #f
  root-kind : (or/c 'crossing 'touching 'both) = 'crossing
  initial-subdivisions : exact-positive-integer? = 4
  maximum-depth : exact-nonnegative-integer? = 12
Constructs an event descriptor. Event identifiers must be distinct in one preparation call. The optional cache key describes the opaque event procedure for a future persistent preparation cache; the completed trajectory itself never retains the procedure. A non-safe event makes automatic parallel preparation fall back to serial execution. Initial uniform dense-segment subdivisions isolate multiple sign-changing roots; 'touching retains a sampled contact whose neighbouring event values have the same sign, and 'both retains both kinds. Root finding remains tolerance-limited.

procedure

(ode-event-hit3d? value) → boolean?

  value : any/c
Recognizes one immutable prepared event-hit record. Its accessors begin with ode-event-hit3d-, including ode-event-hit3d-time, ode-event-hit3d-position, and ode-event-hit3d-provenance.

procedure

(trajectory-termination3d [#:time-limit time-limit 
  #:arc-length-limit arc-length-limit 
  #:bounds bounds 
  #:minimum-speed minimum-speed 
  #:maximum-steps maximum-steps 
  #:events events 
  #:on-field-error on-field-error]) 
 → trajectory-termination3d?
  time-limit : (or/c false/c nonnegative-real?) = #f
  arc-length-limit : (or/c false/c nonnegative-real?) = #f
  bounds : (or/c false/c aabb3?) = #f
  minimum-speed : (or/c false/c nonnegative-real?) = #f
  maximum-steps : exact-positive-integer? = 100000
  events : list? = '()
  on-field-error : (or/c 'error 'terminate) = 'error
Constructs an immutable stopping policy. A time limit constrains absolute physical time to (- time-limit) through time-limit. An AABB means the first exit from a nonempty box, not a request to clip the displayed mesh. The arc budget is measured independently from the seed on each branch. A field error normally remains an author error; 'terminate instead ends at the last accepted node and records a 'field-error hit.

procedure

(trajectory-termination3d? value) → boolean?

  value : any/c
Recognizes a termination policy. Accessors begin with trajectory-termination3d-.

procedure

(trajectory-termination-hit3d? value) → boolean?

  value : any/c
Recognizes an immutable winning-policy record. Its accessors begin with trajectory-termination-hit3d-; reason, time, position, and details are deliberately serializable inspection data.

procedure

(streamline-sample-policy3d 
  [#:maximum-chord-error maximum-chord-error 
  #:maximum-turn-angle maximum-turn-angle 
  #:maximum-segment-length maximum-segment-length 
  #:minimum-segment-length minimum-segment-length]) 
 → streamline-sample-policy3d?
  maximum-chord-error : nonnegative-real? = 1/100
  maximum-turn-angle : nonnegative-real? = (/ pi 12)
  maximum-segment-length : positive? = 1/4
  minimum-segment-length : positive? = 1/2000
Constructs an immutable, world-space display resampling policy. The minimum length is an explicit recursion floor and must not exceed the maximum length. Accessors begin with streamline-sample-policy3d-.

procedure

(prepare-streamline3d field 
  seed 
  [#:direction direction 
  #:parameterization parameterization 
  #:solver solver 
  #:termination termination 
  #:sample-policy sample-policy 
  #:cancellation-token cancellation-token]) 
 → prepared-streamline3d?
  field : any/c
  seed : vec3?
  direction : (or/c 'forward 'backward 'both) = 'forward
  parameterization : (or/c 'time 'arc-length) = 'time
  solver : any/c = (adaptive-rk45-solver3d)
  termination : (or/c false/c trajectory-termination3d?) = #f
  sample-policy : streamline-sample-policy3d?
   = (streamline-sample-policy3d)
  cancellation-token : any/c = #f
Prepares one immutable streamline. If no policy is supplied, preparation uses a finite eight-unit time budget. A supplied policy with no time limit uses the same finite safety horizon unless another termination condition ends first. A preview worker can pass its cooperative cancellation token; cancellation is checked before numerical steps and while the retained curve is resampled, and returns no partial streamline.

procedure

(prepared-streamline3d? value) → boolean?

  value : any/c
Recognizes an immutable prepared streamline. Its accessors begin with prepared-streamline3d-; curve-samples is an immutable vector of world-space vec3 values and seed-index names the seed’s sole joined occurrence.

procedure

(adaptive-streamline3d prepared    
  #:id id    
  #:style style    
  [#:opacity opacity]) → spatial-visual?
  prepared : prepared-streamline3d?
  id : symbol?
  style : any/c
  opacity : real? = 1
Converts prepared display samples to an ordinary spatial curve. A zero-length prepared streamline lowers to an empty named group rather than a fictitious segment.