diff --git a/plot-lib/plot/private/common/plot-device.rkt b/plot-lib/plot/private/common/plot-device.rkt index c692bf60..9a1c81cc 100644 --- a/plot-lib/plot/private/common/plot-device.rkt +++ b/plot-lib/plot/private/common/plot-device.rkt @@ -636,8 +636,8 @@ ;; get max widths and heights per row/column (define-values (max-label-widths max-label-heights) (let-values ([(width height) - (for/fold ([width : (HashTable Integer Exact-Rational) #hash()] - [height : (HashTable Integer Exact-Rational) #hash()]) + (for/fold ([width : (Immutable-HashTable Integer Exact-Rational) #hash()] + [height : (Immutable-HashTable Integer Exact-Rational) #hash()]) ([label (in-list labels)] [k (in-naturals)]) (define-values (i j) @@ -666,7 +666,7 @@ ;; different gaps (define-values (horiz-gap min-label-height baseline _1) (get-text-extent " ")) - + (define top-gap baseline) (define bottom-gap (* 1/2 baseline)) (define in-label-gap (* 3 horiz-gap)) @@ -724,7 +724,7 @@ (define draw-x-mins (for/list : (Listof Real) ([x (in-list label-x-mins)] [w (in-list max-label-widths)]) (+ x w in-label-gap))) - + (values legend-rect max-label-heights draw-x-size label-x-mins draw-x-mins draw-y-size label-y-mins @@ -801,7 +801,7 @@ (define max-label-height (list-ref max-label-heights i)) (define label-y-min (+ legend-entry-y-min (* 1/2 (- max-label-height label-height)))) - + (if (pict? label) (draw-pict label (vector label-x-min label-y-min) 'top-left 0) (draw-text label (vector label-x-min label-y-min) 'top-left 0 0 #t)) diff --git a/plot-lib/plot/private/plot3d/bsp-trees.rkt b/plot-lib/plot/private/plot3d/bsp-trees.rkt index d34b3842..52c5b997 100644 --- a/plot-lib/plot/private/plot3d/bsp-trees.rkt +++ b/plot-lib/plot/private/plot3d/bsp-trees.rkt @@ -7,26 +7,26 @@ (provide (all-defined-out)) -(: build-bsp-trees (-> (HashTable Integer (Listof BSP-Shape)) - (HashTable Integer BSP-Tree))) +(: build-bsp-trees (-> (Immutable-HashTable Integer (Listof BSP-Shape)) + (Immutable-HashTable Integer BSP-Tree))) (define (build-bsp-trees structural-shapes) - (for/hasheq : (HashTable Integer BSP-Tree) ([(layer ss) (in-hash structural-shapes)]) + (for/hasheq : (Immutable-HashTable Integer BSP-Tree) ([(layer ss) (in-hash structural-shapes)]) (values layer (build-bsp-tree ss)))) -(: walk-bsp-trees (-> (HashTable Integer BSP-Tree) +(: walk-bsp-trees (-> (Immutable-HashTable Integer BSP-Tree) FlVector - (HashTable Integer (Listof BSP-Shape)) - (HashTable Integer (Listof BSP-Shape)))) + (Immutable-HashTable Integer (Listof BSP-Shape)) + (Immutable-HashTable Integer (Listof BSP-Shape)))) (define (walk-bsp-trees bsp-trees view-dir detail-shapes) (define vx (flvector-ref view-dir 0)) (define vy (flvector-ref view-dir 1)) (define vz (flvector-ref view-dir 2)) - + (define layers (sort (append (hash-keys bsp-trees) (hash-keys detail-shapes)) >)) - (for/hasheq : (HashTable Integer (Listof BSP-Shape)) ([layer (in-list layers)]) + (for/hasheq : (Immutable-HashTable Integer (Listof BSP-Shape)) ([layer (in-list layers)]) (define bsp (hash-ref bsp-trees layer (λ () (bsp-leaf empty)))) (define ss (hash-ref detail-shapes layer (λ () empty))) - + (: in-order-ss (Listof BSP-Shape)) (define in-order-ss (let loop ([bsp (bsp-tree-insert bsp ss)]) @@ -40,5 +40,5 @@ (if (cos-angle . > . -1e-16) (append (loop neg) (loop pos)) (append (loop pos) (loop neg)))]))) - + (values layer in-order-ss))) diff --git a/plot-lib/plot/private/plot3d/bsp.rkt b/plot-lib/plot/private/plot3d/bsp.rkt index 89920188..72587691 100644 --- a/plot-lib/plot/private/plot3d/bsp.rkt +++ b/plot-lib/plot/private/plot3d/bsp.rkt @@ -143,7 +143,7 @@ [(n . = . 2) (list (line data (first vs) (second vs)))] [else (list (lines data vs))])) vss))) - + (define-values (vss1 vss2) (split-lines3d vs plane)) (values (vertices->lines vss2) (vertices->lines vss1))])) @@ -254,7 +254,7 @@ (define n (length ivls)) (define-values (ivls1 ivls2) (split-at ivls (quotient n 2))) (interval-list-union (loop ivls1) (loop ivls2))]))) - + (cond [(empty? ivls) #f] [(empty? (rest ivls)) #f] [else @@ -408,7 +408,7 @@ (match s [(points _ vs) (if (empty? vs) empty (list s))] - [(line _ v1 v2) + [(line _ v1 v2) (if (equal? v1 v2) empty (list s))] [(poly data vs ls norm) (let-values ([(vs ls) (canonical-polygon3d vs ls)]) @@ -513,17 +513,17 @@ [else (define axes (vertices->axes (bsp-polys->vertices ps))) (define center (list->flvector (map axis-mid axes))) - + ;; Planes defined by neighboring polygon vertices (define polygon-planes (delay (sort-planes (append* (map bsp-poly-planes ps)) center))) - + (: try-bsp-split/polygon-planes (-> Boolean (U #f BSP-Tree))) ;; Tries splitting using polygon-planes (define (try-bsp-split/polygon-planes disjoint?) (define planes (force polygon-planes)) (cond [(and disjoint? ((length planes) . > . 10)) #f] [else (try-bsp-split/planes ss planes disjoint?)])) - + (let* ([bsp #f] [bsp (if bsp bsp (try-bsp-split/axial-planes ss axes))] [bsp (if bsp bsp (try-bsp-split/bounding-planes ss ps center))] @@ -543,17 +543,17 @@ [else (define axes (vertices->axes (bsp-lines->vertices ls))) (define center (list->flvector (map axis-mid axes))) - + ;; Planes defined by line segments and basis vectors (i.e. one basis in normal is zero) (define line-planes (delay (sort-planes (append* (map bsp-line-planes ls)) center))) - + (: try-bsp-split/line-planes (-> Boolean (U #f BSP-Tree))) ;; Tries splitting using line-planes (define (try-bsp-split/line-planes disjoint?) (define planes (force line-planes)) (cond [(and disjoint? ((length planes) . > . 10)) #f] [else (try-bsp-split/planes ss planes disjoint?)])) - + (let* ([bsp #f] [bsp (if bsp bsp (try-bsp-split/axial-planes ss axes))] [bsp (if bsp bsp (try-bsp-split/line-planes #t))] @@ -573,7 +573,7 @@ (define axes (vertices->axes (append (append* (map lines-vertices ls)) (append* (map points-vertices ps))))) (define center (list->flvector (map axis-mid axes))) - + (: try-nondisjoint-split (-> (U #f BSP-Tree))) (define (try-nondisjoint-split) (match-define (axis i size _mn _mx mid) (argmax axis-size axes)) @@ -581,7 +581,7 @@ [else (define plane (axial-plane i mid)) (try-bsp-split ss plane #f (λ () #f))])) - + (let* ([bsp #f] [bsp (if bsp bsp (try-bsp-split/axial-planes ss axes))] [bsp (if bsp bsp (try-nondisjoint-split))]) diff --git a/plot-lib/plot/private/plot3d/plot-area.rkt b/plot-lib/plot/private/plot3d/plot-area.rkt index 27af815e..eb43be4f 100644 --- a/plot-lib/plot/private/plot3d/plot-area.rkt +++ b/plot-lib/plot/private/plot3d/plot-area.rkt @@ -34,9 +34,9 @@ (: plot3d-subdivisions (Parameterof Natural)) (define plot3d-subdivisions (make-parameter 0)) -(struct render-tasks ([structural-shapes : (HashTable Integer (Listof BSP-Shape))] - [detail-shapes : (HashTable Integer (Listof BSP-Shape))] - [bsp-trees : (HashTable Integer BSP-Tree)])) +(struct render-tasks ([structural-shapes : (Immutable-HashTable Integer (Listof BSP-Shape))] + [detail-shapes : (Immutable-HashTable Integer (Listof BSP-Shape))] + [bsp-trees : (Immutable-HashTable Integer BSP-Tree)])) (struct data ([alpha : Nonnegative-Real]) #:transparent) @@ -153,16 +153,16 @@ (init-field bounds-rect rx-ticks rx-far-ticks ry-ticks ry-far-ticks rz-ticks rz-far-ticks legend) (init-field dc dc-x-min dc-y-min dc-x-size dc-y-size aspect-ratio) (super-new) - + (: pd (Instance Plot-Device%)) (define pd (make-object plot-device% dc dc-x-min dc-y-min dc-x-size dc-y-size)) (send pd reset-drawing-params) - + (: char-height Exact-Rational) (: half-char-height Exact-Rational) (define char-height (send pd get-char-height)) (define half-char-height (* 1/2 char-height)) - + (define: x-min : Real 0) (define: x-max : Real 0) (define: y-min : Real 0) @@ -170,7 +170,7 @@ (define: z-min : Real 0) (define: z-max : Real 0) (let () - (match-define (vector (ivl x-min-val x-max-val) + (match-define (vector (ivl x-min-val x-max-val) (ivl y-min-val y-max-val) (ivl z-min-val z-max-val)) bounds-rect) @@ -183,7 +183,7 @@ (set! z-max z-max-val)] [else (raise-argument-error '3d-plot-area% "rect-known?" bounds-rect)])) - + (: x-size Real) (: y-size Real) (: z-size Real) @@ -196,7 +196,7 @@ (define x-mid (* 1/2 (+ x-min x-max))) (define y-mid (* 1/2 (+ y-min y-max))) (define z-mid (* 1/2 (+ z-min z-max))) - + (: clipping? Boolean) (: clip-x-min Real) (: clip-x-max Real) @@ -211,7 +211,7 @@ (define clip-y-max y-max) (define clip-z-min z-min) (define clip-z-max z-max) - + (define/public (put-clip-rect rect) (match-define (vector (ivl rx-min rx-max) (ivl ry-min ry-max) (ivl rz-min rz-max)) rect) (define cx-min (if rx-min (max* x-min rx-min) x-min)) @@ -233,30 +233,30 @@ (set! clip-z-min cz-min) (set! clip-z-max cz-max)) (set! clipping? #t)) - + (define/public (clear-clip-rect) (set! clipping? #f)) - + (: in-bounds? (-> (Vectorof Real) Boolean)) (define/private (in-bounds? v) (or (not clipping?) (point-in-bounds? v clip-x-min clip-x-max clip-y-min clip-y-max clip-z-min clip-z-max))) - + (define/public (get-x-ticks) x-ticks) (define/public (get-y-ticks) y-ticks) (define/public (get-z-ticks) z-ticks) (define/public (get-x-far-ticks) x-far-ticks) (define/public (get-y-far-ticks) y-far-ticks) (define/public (get-z-far-ticks) z-far-ticks) - + (define/public (get-bounds-rect) bounds-rect) - + (define/public (get-clip-rect) (if clipping? (vector (ivl clip-x-min clip-x-max) (ivl clip-y-min clip-y-max) (ivl clip-z-min clip-z-max)) bounds-rect)) - + (: angle Real) (: altitude Real) (: theta Real) @@ -267,14 +267,14 @@ ;; or 270, the x/y/z tick labels are drawn on the left side. (define theta (+ (degrees->radians angle) 0.00001)) (define rho (degrees->radians altitude)) - + ;; There are four coordinate systems: ;; 1. Plot coordinates (original, user-facing coordinate system) ;; 2. Normalized coordinates (from plot coordinates: for each axis: transform, center, and scale ;; to [-0.5,0.5]) - these are always flvectors ;; 3. View coordinates (from normalized coordinates: rotate) ;; 4. Device context coordinates (from view coordinates: project to 2D) - + (define: fx : (-> Real Real) (λ ([x : Real]) x)) (define: gx : (-> Real Real) (λ ([x : Real]) x)) (define: fy : (-> Real Real) (λ ([y : Real]) y)) @@ -291,13 +291,13 @@ (set! gy gy-val) (set! fz fz-val) (set! gz gz-val)) - + (: identity-transforms? Boolean) (define identity-transforms? (and (equal? (plot-x-transform) id-transform) (equal? (plot-y-transform) id-transform) (equal? (plot-z-transform) id-transform))) - + (: plot->norm (-> (Vectorof Real) FlVector)) (define/private (plot->norm v) (match v @@ -320,14 +320,14 @@ [s (in-list (list x-size y-size z-size))] [g (in-list (list gx gy gz))]) (g (+ (* c s) m)))) - + (: rotate-theta-matrix M3) (: rotate-rho-matrix M3) (: rotation-matrix M3) (define rotate-theta-matrix (m3-rotate-z theta)) (define rotate-rho-matrix (m3-rotate-x rho)) (define rotation-matrix (m3* rotate-rho-matrix rotate-theta-matrix)) - + (: norm->view (-> FlVector FlVector)) (: plot->view (-> (Vectorof Real) FlVector)) (: plot->view/no-rho (-> (Vectorof Real) FlVector)) @@ -338,17 +338,17 @@ (define/private (plot->view/no-rho v) (m3-apply rotate-theta-matrix (plot->norm v))) (define/private (norm->view/no-rho v) (m3-apply rotate-theta-matrix v)) (define/private (rotate/rho v) (m3-apply rotate-rho-matrix v)) - + (: unrotation-matrix M3) (: view->norm (-> FlVector FlVector)) (define unrotation-matrix (m3-transpose rotation-matrix)) (define/private (view->norm v) (m3-apply unrotation-matrix v)) - + (: plot->dc (-> (Vectorof Real) (Vectorof Real))) - (: norm->dc (-> FlVector (Vectorof Real))) + (: norm->dc (-> FlVector (Vectorof Real))) (define (plot->dc v) (view->dc (plot->view v))) (define/private (norm->dc v) (view->dc (norm->view v))) - + (define: view-x-size : Real 0) (define: view-y-size : Real 0) (define: view-z-size : Real 0) @@ -365,7 +365,7 @@ (set! view-x-size view-x-size-val) (set! view-y-size view-y-size-val) (set! view-z-size view-z-size-val)) - + (: make-view->dc (-> Real Real Real Real (-> FlVector (Vectorof Real)))) (define/private (make-view->dc left right top bottom) (define area-x-min left) @@ -400,7 +400,7 @@ (: dc->plot (-> (Vectorof Real) (Vectorof Real))) (define (dc->plot v) (norm->plot (view->norm (dc->view v)))) - + (: title-margin Real) (define title-margin (let ([title (plot-title)]) @@ -455,36 +455,36 @@ (match-define (vector dx dy) (v- (norm->dc (flvector 0.5 0.0 0.0)) (norm->dc (flvector -0.5 0.0 0.0)))) (- (atan2 (- dy) dx))) - + (: y-axis-angle (-> Real)) (define (y-axis-angle) (match-define (vector dx dy) (v- (norm->dc (flvector 0.0 0.5 0.0)) (norm->dc (flvector 0.0 -0.5 0.0)))) (- (atan2 (- dy) dx))) - + (: x-axis-dir (-> (Vectorof Real))) (define (x-axis-dir) (vnormalize (v- (norm->dc (flvector 0.5 0.0 0.0)) (norm->dc (flvector -0.5 0.0 0.0))))) - + (: y-axis-dir (-> (Vectorof Real))) (define (y-axis-dir) (vnormalize (v- (norm->dc (flvector 0.0 0.5 0.0)) (norm->dc (flvector 0.0 -0.5 0.0))))) - + ;; =============================================================================================== ;; Tick and label constants - + (: tick-radius Real) (: half-tick-radius Real) (define tick-radius (* 1/2 (plot-tick-size))) (define half-tick-radius (* 1/2 tick-radius)) - + (: x-axis-y-min? Boolean) (: y-axis-x-min? Boolean) (define x-axis-y-min? ((cos theta) . >= . 0)) ; #t iff x near labels should be drawn at y-min (define y-axis-x-min? ((sin theta) . >= . 0)) ; #t iff y near labels should be drawn at x-min - + (: x-axis-y Real) (: y-axis-x Real) (: z-axis-x Real) @@ -493,7 +493,7 @@ (define y-axis-x (if y-axis-x-min? x-min x-max)) (define z-axis-x (if x-axis-y-min? x-min x-max)) (define z-axis-y (if y-axis-x-min? y-max y-min)) - + (: x-far-axis-y Real) (: y-far-axis-x Real) (: z-far-axis-x Real) @@ -502,7 +502,7 @@ (define y-far-axis-x (if y-axis-x-min? x-max x-min)) (define z-far-axis-x (if x-axis-y-min? x-max x-min)) (define z-far-axis-y (if y-axis-x-min? y-min y-max)) - + (: x-axis-norm-y Flonum) (: y-axis-norm-x Flonum) (: z-axis-norm-x Flonum) @@ -511,7 +511,7 @@ (define y-axis-norm-x (if y-axis-x-min? -0.5 0.5)) (define z-axis-norm-x (if x-axis-y-min? -0.5 0.5)) (define z-axis-norm-y (if y-axis-x-min? 0.5 -0.5)) - + (: x-far-axis-norm-y Flonum) (: y-far-axis-norm-x Flonum) (: z-far-axis-norm-x Flonum) @@ -520,29 +520,29 @@ (define y-far-axis-norm-x (if y-axis-x-min? 0.5 -0.5)) (define z-far-axis-norm-x (if x-axis-y-min? 0.5 -0.5)) (define z-far-axis-norm-y (if y-axis-x-min? -0.5 0.5)) - + (: near-dist^2 Real) (define near-dist^2 (sqr (* 3 (plot-line-width)))) - + (: vnear? (-> (Vectorof Real) (Vectorof Real) Boolean)) (define/private (vnear? v1 v2) ((vmag^2 (v- (plot->dc v1) (plot->dc v2))) . <= . near-dist^2)) - + (: x-ticks-near? (-> Real (-> pre-tick pre-tick Boolean))) (define/private ((x-ticks-near? y) t1 t2) (vnear? (vector (pre-tick-value t1) y z-min) (vector (pre-tick-value t2) y z-min))) - + (: y-ticks-near? (-> Real (-> pre-tick pre-tick Boolean))) (define/private ((y-ticks-near? x) t1 t2) (vnear? (vector x (pre-tick-value t1) z-min) (vector x (pre-tick-value t2) z-min))) - + (: z-ticks-near? (-> Real Real (-> pre-tick pre-tick Boolean))) (define/private ((z-ticks-near? x y) t1 t2) (vnear? (vector x y (pre-tick-value t1)) (vector x y (pre-tick-value t2)))) - + (: x-ticks (Listof tick)) (: y-ticks (Listof tick)) (: z-ticks (Listof tick)) @@ -558,7 +558,7 @@ (collapse-ticks (filter (λ ([t : tick]) (<= z-min (pre-tick-value t) z-max)) (map tick-inexact->exact rz-ticks)) (z-ticks-near? z-axis-x z-axis-y))) - + (: x-far-ticks (Listof tick)) (: y-far-ticks (Listof tick)) (: z-far-ticks (Listof tick)) @@ -574,18 +574,18 @@ (collapse-ticks (filter (λ ([t : tick]) (<= z-min (pre-tick-value t) z-max)) (map tick-inexact->exact rz-far-ticks)) (z-ticks-near? z-far-axis-x z-far-axis-y))) - + ;; =============================================================================================== ;; Tick and label parameters, and fixpoint margin computation - + ;; From here through "All parameters" are functions that compute *just the parameters* of ticks ;; and labels that will be drawn on the plot. We have to separate computing parameters from ;; actually drawing the ticks and labels so we can solve for the plot margins using a fixpoint ;; computation. See ../common/draw.rkt for more explanation. (Search for 'margin-fixpoint'.) - + ;; ----------------------------------------------------------------------------------------------- ;; Tick parameters - + (: x-tick-value->view (-> Real FlVector)) (: y-tick-value->view (-> Real FlVector)) (: x-far-tick-value->view (-> Real FlVector)) @@ -594,7 +594,7 @@ (define/private (y-tick-value->view y) (plot->view (vector y-axis-x y z-min))) (define/private (x-far-tick-value->view x) (plot->view (vector x x-far-axis-y z-min))) (define/private (y-far-tick-value->view y) (plot->view (vector y-far-axis-x y z-min))) - + (: x-tick-value->dc (-> Real (Vectorof Real))) (: y-tick-value->dc (-> Real (Vectorof Real))) (: z-tick-value->dc (-> Real (Vectorof Real))) @@ -607,49 +607,49 @@ (define/private (x-far-tick-value->dc x) (view->dc (x-far-tick-value->view x))) (define/private (y-far-tick-value->dc y) (view->dc (y-far-tick-value->view y))) (define/private (z-far-tick-value->dc z) (plot->dc (vector z-far-axis-x z-far-axis-y z))) - + (: get-tick-params (-> (Listof tick) (-> Real (Vectorof Real)) Real (Listof Tick-Params))) (define/private (get-tick-params ts tick-value->dc angle) (for/list : (Listof Tick-Params) ([t (in-list ts)]) (match-define (tick p major? _) t) (list major? (tick-value->dc p) (if major? tick-radius half-tick-radius) angle))) - + (: get-x-tick-params (-> (Listof Tick-Params))) (define (get-x-tick-params) (if (plot-x-axis?) (get-tick-params x-ticks (λ ([x : Real]) (x-tick-value->dc x)) (y-axis-angle)) empty)) - + (: get-y-tick-params (-> (Listof Tick-Params))) (define (get-y-tick-params) (if (plot-y-axis?) (get-tick-params y-ticks (λ ([y : Real]) (y-tick-value->dc y)) (x-axis-angle)) empty)) - + (: get-z-tick-params (-> (Listof Tick-Params))) (define (get-z-tick-params) (if (plot-z-axis?) (get-tick-params z-ticks (λ ([z : Real]) (z-tick-value->dc z)) 0) empty)) - + (: get-x-far-tick-params (-> (Listof Tick-Params))) (define (get-x-far-tick-params) (if (plot-x-far-axis?) (get-tick-params x-far-ticks (λ ([x : Real]) (x-far-tick-value->dc x)) (y-axis-angle)) empty)) - + (: get-y-far-tick-params (-> (Listof Tick-Params))) (define (get-y-far-tick-params) (if (plot-y-far-axis?) (get-tick-params y-far-ticks (λ ([y : Real]) (y-far-tick-value->dc y)) (x-axis-angle)) empty)) - + (: get-z-far-tick-params (-> (Listof Tick-Params))) (define (get-z-far-tick-params) (if (plot-z-far-axis?) (get-tick-params z-far-ticks (λ ([z : Real]) (z-far-tick-value->dc z)) 0) empty)) - + ;; ----------------------------------------------------------------------------------------------- ;; Tick label parameters @@ -677,13 +677,13 @@ (if (eq? flag 'auto) (and (plot-z-axis?) (equal? z-ticks z-far-ticks)) flag))) - + (: sort-ticks (-> (Listof tick) (-> Real FlVector) (Listof tick))) (define/private (sort-ticks ts tick-value->view) ((inst sort tick Flonum) ts fl> #:key (λ ([t : tick]) (flvector-ref (tick-value->view (pre-tick-value t)) 2)) #:cache-keys? #t)) - + (: x-tick-label-anchor Anchor) (define x-tick-label-anchor (let ([s (sin theta)]) @@ -692,7 +692,7 @@ [(s . < . (sin (degrees->radians 22.5))) 'top] [(s . < . (sin (degrees->radians 67.5))) (if x-axis-y-min? 'top-left 'top-right)] [else (if x-axis-y-min? 'top-left 'top-right)]))) - + (: y-tick-label-anchor Anchor) (define y-tick-label-anchor (let ([c (cos theta)]) @@ -701,17 +701,17 @@ [(c . > . (cos (degrees->radians 112.5))) 'top] [(c . > . (cos (degrees->radians 157.5))) (if y-axis-x-min? 'top-left 'top-right)] [else (if y-axis-x-min? 'top-left 'top-right)]))) - + (: z-tick-label-anchor Anchor) (define z-tick-label-anchor 'right) - + (: x-far-tick-label-anchor Anchor) (: y-far-tick-label-anchor Anchor) (: z-far-tick-label-anchor Anchor) (define x-far-tick-label-anchor (opposite-anchor x-tick-label-anchor)) (define y-far-tick-label-anchor (opposite-anchor y-tick-label-anchor)) (define z-far-tick-label-anchor 'left) - + (: get-tick-label-params (-> (Listof tick) (-> Real (Vectorof Real)) (Vectorof Real) Anchor (Listof Label-Params))) (define/private (get-tick-label-params ts tick-value->dc offset-dir anchor) @@ -719,7 +719,7 @@ (for/list : (Listof Label-Params) ([t (in-list ts)] #:when (pre-tick-major? t)) (match-define (tick x _ label) t) (list label (v+ (tick-value->dc x) (v* offset-dir dist)) anchor 0))) - + (: get-x-tick-label-params (-> (Listof Label-Params))) (define (get-x-tick-label-params) (if (and (plot-x-axis?) draw-x-tick-labels?) @@ -729,7 +729,7 @@ offset x-tick-label-anchor)) empty)) - + (: get-y-tick-label-params (-> (Listof Label-Params))) (define (get-y-tick-label-params) (if (and (plot-y-axis?) draw-y-tick-labels?) @@ -739,7 +739,7 @@ offset y-tick-label-anchor)) empty)) - + (: get-z-tick-label-params (-> (Listof Label-Params))) (define (get-z-tick-label-params) (if (and (plot-z-axis?) draw-z-tick-labels?) @@ -748,7 +748,7 @@ #(-1 0) z-tick-label-anchor) empty)) - + (: get-x-far-tick-label-params (-> (Listof Label-Params))) (define (get-x-far-tick-label-params) (if (and (plot-x-far-axis?) draw-x-far-tick-labels?) @@ -759,7 +759,7 @@ offset x-far-tick-label-anchor)) empty)) - + (: get-y-far-tick-label-params (-> (Listof Label-Params))) (define (get-y-far-tick-label-params) (if (and (plot-y-far-axis?) draw-y-far-tick-labels?) @@ -770,7 +770,7 @@ offset y-far-tick-label-anchor)) empty)) - + (: get-z-far-tick-label-params (-> (Listof Label-Params))) (define (get-z-far-tick-label-params) (if (and (plot-z-far-axis?) draw-z-far-tick-labels?) @@ -779,16 +779,16 @@ #(1 0) z-far-tick-label-anchor) empty)) - + ;; ----------------------------------------------------------------------------------------------- ;; Axis label parameters - + (: max-tick-offset (-> (Listof tick) Real)) (define/private (max-tick-offset ts) (cond [(empty? ts) 0] [(ormap pre-tick-major? ts) (+ (pen-gap) tick-radius)] [else (+ (pen-gap) (* 1/4 (plot-tick-size)))])) - + (: max-x-tick-offset Real) (: max-y-tick-offset Real) (: max-x-far-tick-offset Real) @@ -797,16 +797,16 @@ (define max-y-tick-offset (if (plot-y-axis?) (max-tick-offset y-ticks) 0)) (define max-x-far-tick-offset (if (plot-x-far-axis?) (max-tick-offset x-far-ticks) 0)) (define max-y-far-tick-offset (if (plot-y-far-axis?) (max-tick-offset y-far-ticks) 0)) - + (: max-tick-label-height (-> (Listof tick) Real)) (define/private (max-tick-label-height ts) (if (ormap pre-tick-major? ts) char-height 0)) - + (: max-tick-label-width (-> (Listof tick) Real)) (define/private (max-tick-label-width ts) (apply max 0 (for/list : (Listof Real) ([t (in-list ts)] #:when (pre-tick-major? t)) (send pd get-text-width (tick-label t))))) - + (: max-x-tick-label-width Real) (: max-y-tick-label-width Real) (: max-z-tick-label-width Real) @@ -819,7 +819,7 @@ (define max-x-tick-label-height (max-tick-label-height x-ticks)) (define max-y-tick-label-height (max-tick-label-height y-ticks)) (define max-z-tick-label-height (max-tick-label-height z-ticks)) - + (: max-x-far-tick-label-width Real) (: max-y-far-tick-label-width Real) (: max-z-far-tick-label-width Real) @@ -832,81 +832,81 @@ (define max-x-far-tick-label-height (max-tick-label-height x-far-ticks)) (define max-y-far-tick-label-height (max-tick-label-height y-far-ticks)) (define max-z-far-tick-label-height (max-tick-label-height z-far-ticks)) - + (: max-tick-label-diag (-> (Vectorof Real) Real Real Real)) (define/private (max-tick-label-diag axis-dc-dir max-tick-label-width max-tick-label-height) (match-define (vector dx dy) axis-dc-dir) (+ (* (abs dx) max-tick-label-width) (* (abs dy) max-tick-label-height))) - + (: max-x-tick-label-diag (-> Real)) (define (max-x-tick-label-diag) (if (and (plot-x-axis?) draw-x-tick-labels?) (max-tick-label-diag (y-axis-dir) max-x-tick-label-width max-x-tick-label-height) 0)) - + (: max-y-tick-label-diag (-> Real)) (define (max-y-tick-label-diag) (if (and (plot-y-axis?) draw-y-far-tick-labels?) (max-tick-label-diag (x-axis-dir) max-y-tick-label-width max-y-tick-label-height) 0)) - + (: max-x-far-tick-label-diag (-> Real)) (define (max-x-far-tick-label-diag) (if (and (plot-x-far-axis?) draw-x-far-tick-labels?) (max-tick-label-diag (y-axis-dir) max-x-far-tick-label-width max-x-far-tick-label-height) 0)) - + (: max-y-far-tick-label-diag (-> Real)) (define (max-y-far-tick-label-diag) (if (and (plot-y-far-axis?) draw-y-far-tick-labels?) (max-tick-label-diag (x-axis-dir) max-y-far-tick-label-width max-y-far-tick-label-height) 0)) - + (: get-x-label-params (-> Label-Params)) (define (get-x-label-params) (define v0 (norm->dc (flvector 0.0 x-axis-norm-y -0.5))) (define dist (+ max-x-tick-offset (max-x-tick-label-diag) half-char-height)) (list (plot-x-label) (v+ v0 (v* (y-axis-dir) (if x-axis-y-min? (- dist) dist))) 'top (- (if x-axis-y-min? 0 pi) (x-axis-angle)))) - + (: get-y-label-params (-> Label-Params)) (define (get-y-label-params) (define v0 (norm->dc (flvector y-axis-norm-x 0.0 -0.5))) (define dist (+ max-y-tick-offset (max-y-tick-label-diag) half-char-height)) (list (plot-y-label) (v+ v0 (v* (x-axis-dir) (if y-axis-x-min? (- dist) dist))) 'top (- (if y-axis-x-min? pi 0) (y-axis-angle)))) - + (: get-z-label-params (-> Label-Params)) (define (get-z-label-params) (list (plot-z-label) (v+ (plot->dc (vector z-axis-x z-axis-y z-max)) (vector 0 (- half-char-height))) 'bottom-left 0)) - + (: get-x-far-label-params (-> Label-Params)) (define (get-x-far-label-params) (define v0 (norm->dc (flvector 0.0 x-far-axis-norm-y -0.5))) (define dist (+ max-x-far-tick-offset (max-x-far-tick-label-diag) half-char-height)) (list (plot-x-far-label) (v+ v0 (v* (y-axis-dir) (if x-axis-y-min? dist (- dist)))) 'bottom (- (if x-axis-y-min? 0 pi) (x-axis-angle)))) - + (: get-y-far-label-params (-> Label-Params)) (define (get-y-far-label-params) (define v0 (norm->dc (flvector y-far-axis-norm-x 0.0 -0.5))) (define dist (+ max-y-far-tick-offset (max-y-far-tick-label-diag) half-char-height)) (list (plot-y-far-label) (v+ v0 (v* (x-axis-dir) (if y-axis-x-min? dist (- dist)))) 'bottom (- (if y-axis-x-min? pi 0) (y-axis-angle)))) - + (: get-z-far-label-params (-> Label-Params)) (define (get-z-far-label-params) (list (plot-z-far-label) (v+ (plot->dc (vector z-far-axis-x z-far-axis-y z-max)) (vector 0 (- half-char-height))) 'bottom-right 0)) - + ;; ----------------------------------------------------------------------------------------------- ;; All parameters - + ;; Within each get-back-* or get-front-*, the parameters are ordered (roughly) back-to-front - + (: get-back-label-params (-> (Listof Label-Params))) (define (get-back-label-params) (if (plot-decorations?) @@ -915,7 +915,7 @@ (get-x-far-tick-label-params) (get-y-far-tick-label-params)) empty)) - + (: get-front-label-params (-> (Listof Label-Params))) (define (get-front-label-params) (if (plot-decorations?) @@ -928,11 +928,11 @@ (if (plot-z-label) (list (get-z-label-params)) empty) (if (plot-z-far-label) (list (get-z-far-label-params)) empty)) empty)) - + (: get-all-label-params (-> (Listof Label-Params))) (define (get-all-label-params) (append (get-back-label-params) (get-front-label-params))) - + (: get-back-tick-params (-> (Listof Tick-Params))) (define (get-back-tick-params) (if (plot-decorations?) @@ -941,22 +941,22 @@ (if (plot-x-axis?) (get-x-tick-params) empty) (if (plot-y-axis?) (get-y-tick-params) empty)) empty)) - + (: get-front-tick-params (-> (Listof Tick-Params))) (define (get-front-tick-params) (if (plot-decorations?) (append (if (plot-z-axis?) (get-z-tick-params) empty) (if (plot-z-far-axis?) (get-z-far-tick-params) empty)) empty)) - + (: get-all-tick-params (-> (Listof Tick-Params))) (define (get-all-tick-params) (append (get-back-tick-params) (get-front-tick-params))) - - + + ;; ----------------------------------------------------------------------------------------------- ;; Fixpoint margin computation - + (: get-param-vs/set-view->dc! (-> Real Real Real Real (Listof (Vectorof Real)))) (define/private (get-param-vs/set-view->dc! left right top bottom) ;(printf "margins: ~v ~v ~v ~v~n" left right top bottom) @@ -973,7 +973,7 @@ (match-define (list _ v radius angle) p) (send pd get-tick-endpoints v radius angle)) (get-all-tick-params))))) - + (define: left : Real 0) (define: right : Real 0) (define: top : Real 0) @@ -1006,7 +1006,7 @@ (set! view->dc (make-view->dc left right top bottom))) (define/public (get-aspect-ratio) aspect-ratio) - + (: area-x-min Real) (: area-x-max Real) (: area-y-min Real) @@ -1015,13 +1015,13 @@ (define area-x-max (- dc-x-size right)) (define area-y-min top) (define area-y-max (- dc-y-size bottom)) - + (define/public (get-area-bounds-rect) (vector (ivl area-x-min area-x-max) (ivl area-y-min area-y-max))) ;; =============================================================================================== ;; Plot decoration - + (: draw-title (-> Void)) (define/private (draw-title) (define title (plot-title)) @@ -1029,7 +1029,7 @@ (if (string? title) (send pd draw-text title (vector (* 1/2 dc-x-size) (ann 0 Real)) 'top) (send pd draw-pict title (vector (* 1/2 dc-x-size) (ann 0 Real)) 'top 0)))) - + (: draw-back-axes (-> Void)) (define/private (draw-back-axes) (when (plot-decorations?) @@ -1050,7 +1050,7 @@ (send pd draw-line (norm->dc (flvector y-far-axis-norm-x -0.5 -0.5)) (norm->dc (flvector y-far-axis-norm-x 0.5 -0.5)))))) - + (: draw-front-axes (-> Void)) (define/private (draw-front-axes) (when (plot-decorations?) @@ -1063,14 +1063,14 @@ (send pd draw-line (norm->dc (flvector z-far-axis-norm-x z-far-axis-norm-y -0.5)) (norm->dc (flvector z-far-axis-norm-x z-far-axis-norm-y 0.5)))))) - + (: draw-ticks (-> (Listof Tick-Params) Void)) (define/private (draw-ticks ps) (for ([p (in-list ps)]) (match-define (list major? v r angle) p) (if major? (send pd set-major-pen) (send pd set-minor-pen)) (send pd draw-tick v r angle))) - + (: draw-labels (-> (Listof Label-Params) Void)) (define/private (draw-labels ps) (for ([p (in-list ps)]) @@ -1079,23 +1079,23 @@ (send pd draw-text label v anchor angle 0 #t)) ((pict? label) (send pd draw-pict label v anchor 0))))) - + ;; =============================================================================================== ;; Render list and its BSP representation - - (: structural-shapes (HashTable Integer (Listof BSP-Shape))) + + (: structural-shapes (Immutable-HashTable Integer (Listof BSP-Shape))) ;; View-independent shapes, used to built initial BSP trees (define structural-shapes ((inst make-immutable-hash Integer (Listof BSP-Shape)))) - - (: detail-shapes (HashTable Integer (Listof BSP-Shape))) + + (: detail-shapes (Immutable-HashTable Integer (Listof BSP-Shape))) ;; View-dependent shapes, inserted into BSP trees before each refresh (define detail-shapes ((inst make-immutable-hash Integer (Listof BSP-Shape)))) - - (: bsp-trees (U #f (HashTable Integer BSP-Tree))) + + (: bsp-trees (Option (Immutable-HashTable Integer BSP-Tree))) ;; Structural shapes partitioned in BSP trees, indexed by drawing layer ;; #f means not in sync with structural-shapes (define bsp-trees #f) - + (: add-shape! (-> Integer BSP-Shape Void)) (define/private (add-shape! layer s) (cond [(structural-shape? s) @@ -1105,38 +1105,38 @@ [else (define ss detail-shapes) (set! detail-shapes (hash-set ss layer (cons s (hash-ref ss layer (λ () empty)))))])) - + (: add-shapes! (-> Integer (Listof BSP-Shape) Void)) (define/private (add-shapes! layer ss) (for ([s (in-list ss)]) (add-shape! layer s))) - + (: clear-shapes! (-> Void)) (define/private (clear-shapes!) (set! structural-shapes ((inst make-immutable-hash Integer (Listof BSP-Shape)))) (set! detail-shapes ((inst make-immutable-hash Integer (Listof BSP-Shape)))) (set! bsp-trees #f)) - + (define/public (get-render-tasks) (define bsp-trees (sync-bsp-trees)) (render-tasks structural-shapes detail-shapes bsp-trees)) - + (define/public (set-render-tasks tasks) (match-define (render-tasks sts dts bsps) tasks) (set! structural-shapes sts) (set! detail-shapes dts) (set! bsp-trees bsps)) - - (: sync-bsp-trees (-> (HashTable Integer BSP-Tree))) + + (: sync-bsp-trees (-> (Immutable-HashTable Integer BSP-Tree))) (define/private (sync-bsp-trees) (define bsp-trees-val bsp-trees) (cond - [bsp-trees-val bsp-trees-val] + [bsp-trees-val bsp-trees-val] [else (define bsp-trees-val (build-bsp-trees structural-shapes)) (set! bsp-trees bsp-trees-val) bsp-trees-val])) - + (: adjust-detail-shapes (-> (Listof BSP-Shape) (Listof BSP-Shape))) (define/private (adjust-detail-shapes ss) (define d (view->norm view-dir)) @@ -1145,7 +1145,7 @@ (define dz (flvector-ref d 2)) (define area-size (fl (min (- area-x-max area-x-min) (- area-y-max area-y-min)))) - + (for/list : (Listof BSP-Shape) ([s (in-list ss)]) (match s [(points data vs) @@ -1158,7 +1158,7 @@ [(line data v1 v2) ;; Bring line forward by about half its apparent thickness (define frac (* 0.5 (/ pen-width area-size))) - (line data + (line data (flvector (+ (flvector-ref v1 0) (* dx frac)) (+ (flvector-ref v1 1) (* dy frac)) (+ (flvector-ref v1 2) (* dz frac))) @@ -1173,54 +1173,54 @@ (+ (flvector-ref v 1) (* dy frac)) (+ (flvector-ref v 2) (* dz frac)))))] [_ s]))) - + (: draw-all-shapes (-> Void)) (define/private (draw-all-shapes) (define bsp-trees (sync-bsp-trees)) - + (define adj-detail-shapes - (for/hasheq : (HashTable Integer (Listof BSP-Shape)) ([(layer ss) (in-hash detail-shapes)]) + (for/hasheq : (Immutable-HashTable Integer (Listof BSP-Shape)) ([(layer ss) (in-hash detail-shapes)]) (values layer (adjust-detail-shapes ss)))) - + (define all-shapes (walk-bsp-trees bsp-trees (view->norm view-dir) adj-detail-shapes)) - + (for* ([layer (in-list (sort (hash-keys all-shapes) >))] [s (in-list (hash-ref all-shapes layer))]) (draw-shape s))) - + ;; =============================================================================================== ;; Lighting - + (: light FlVector) ;; Light position, in normalized view coordinates: 5 units up, ~3 units back and to the left ;; (simulates non-noon daylight conditions) (define light (m3-apply rotate-rho-matrix (flvector (- -0.5 2.0) (- -0.5 2.0) (+ 0.5 5.0)))) - + ;; Do lighting only by direction so we can precalculate light-dir and half-dir ;; Conceptually, the viewer and light are at infinity - + (: light-dir FlVector) ;; Light direction (define light-dir (vector->flvector (vnormalize (flv3->v light)))) - + (: view-dir FlVector) ;; View direction, in normalized view coordinates (define view-dir (flvector 0.0 -1.0 0.0)) - + (: half-dir FlVector) ;; Blinn-Phong "half angle" direction (define half-dir (vector->flvector (vnormalize (v* (v+ (flv3->v light-dir) (flv3->v view-dir)) 0.5)))) - + (: diffuse-light? Boolean) (: specular-light? Boolean) (: ambient-light Flonum) (define diffuse-light? (plot3d-diffuse-light?)) (define specular-light? (plot3d-specular-light?)) (define ambient-light (fl (plot3d-ambient-light))) - + (: get-light-values (-> FlVector (Values Flonum Flonum))) (define/private (get-light-values normal) (cond @@ -1238,17 +1238,17 @@ ;; Blend ambient light with diffuse light, return specular as it is ;; As ambient-light -> 1.0, contribution of diffuse -> 0.0 (values (fl+ ambient-light (fl* (fl- 1.0 ambient-light) diff)) spec)])) - + (: illuminate (-> (List Real Real Real) Real Real (List Real Real Real))) (define/private (illuminate c diff spec) (match-define (list r g b) c) (list (+ (* r diff) spec) (+ (* g diff) spec) (+ (* b diff) spec))) - + ;; =============================================================================================== ;; Drawing - + (: draw-polygon (-> poly Void)) (define/private (draw-polygon s) (match-define (poly (poly-data alpha center @@ -1283,21 +1283,21 @@ [v2 (in-list vs)] [l (in-list ls)]) (when l (send pd draw-line v1 v2)))]))])) - + (: draw-line (-> line Void)) (define/private (draw-line s) (match-define (line (line-data alpha pen-color pen-width pen-style) v1 v2) s) (send pd set-alpha alpha) (send pd set-pen pen-color pen-width pen-style) (send pd draw-line (norm->dc v1) (norm->dc v2))) - + (: draw-lines (-> lines Void)) (define/private (draw-lines s) (match-define (lines (line-data alpha pen-color pen-width pen-style) vs) s) (send pd set-alpha alpha) (send pd set-pen pen-color pen-width pen-style) (send pd draw-lines (map (λ ([v : FlVector]) (norm->dc v)) vs))) - + (: draw-glyph (-> glyph-data (Listof FlVector) Void)) (define/private (draw-glyph data vs) (match-define (glyph-data alpha symbol size @@ -1308,7 +1308,7 @@ (send pd set-pen pen-color pen-width pen-style) (send pd set-brush brush-color brush-style) (send pd draw-glyphs (map (λ ([v : FlVector]) (norm->dc v)) vs) symbol size)) - + (: draw-text (-> text-data (Listof FlVector) Void)) (define/private (draw-text data vs) (match-define (text-data alpha anchor angle dist str font-size font-family color outline?) data) @@ -1317,7 +1317,7 @@ (send pd set-text-foreground color) (for ([v (in-list vs)]) (send pd draw-text str (norm->dc v) anchor angle dist outline?))) - + (: draw-arrow (-> arrow-data Void)) (define/private (draw-arrow data) (match-define (arrow-data alpha v1 v2 outline-color pen-color pen-width pen-style size-or-scale angle) data) @@ -1329,14 +1329,14 @@ (send pd set-pen pen-color pen-width pen-style) (send pd set-arrow-head size-or-scale angle) (send pd draw-arrow v1 v2))) - + (: draw-points (-> points Void)) (define/private (draw-points s) (match-define (points data vs) s) (cond [(glyph-data? data) (draw-glyph data vs)] [(text-data? data) (draw-text data vs)] [(arrow-data? data) (draw-arrow data)])) - + (: draw-shape (-> BSP-Shape Void)) (define/private (draw-shape s) (cond [(poly? s) (draw-polygon s)] @@ -1344,10 +1344,10 @@ [(lines? s) (draw-lines s)] [(points? s) (draw-points s)] [else (raise-argument-error 'draw-shape "known shape" s)])) - + ;; =============================================================================================== ;; Public drawing control (used by plot3d/dc) - + (define/public (start-plot) (send pd reset-drawing-params) (send pd clear) @@ -1361,11 +1361,11 @@ (vector (ivl (+ 1/2 (- area-x-min (plot-line-width))) (+ area-x-max (plot-line-width))) (ivl (+ 1/2 (- area-y-min (plot-line-width))) (+ area-y-max (plot-line-width))))) (clear-shapes!)) - + (define/public (start-renderer rend-bounds-rect) (reset-drawing-params) (put-clip-rect rend-bounds-rect)) - + (define/public (end-renderers) (clear-clip-rect) (draw-all-shapes) @@ -1375,7 +1375,7 @@ (draw-labels (get-front-label-params)) (when (and (not (empty? legend)) (inside-anchor? (plot-legend-anchor))) (draw-legend legend))) - + (define/public (draw-legend legend-entries) (define outside? (outside-anchor? (plot-legend-anchor))) (define gap-size (+ (pen-gap) (if outside? 0 tick-radius))) @@ -1387,40 +1387,40 @@ (send pd draw-legend legend-entries (vector (ivl (+ x-min gap-size) (- x-max gap-size)) (ivl (+ y-min gap-size) (- y-max gap-size))))) - + (define/public (end-plot) (send pd restore-drawing-params)) - + ;; =============================================================================================== ;; Public drawing interface (used by renderers) - + ;; Drawing parameters - + (: alpha Nonnegative-Real) (define alpha 1) - + (: pen-color (List Real Real Real)) (: pen-width Nonnegative-Real) (: pen-style Plot-Pen-Style-Sym) (define pen-color '(0 0 0)) (define pen-width 1) (define pen-style 'solid) - + (: brush-color (List Real Real Real)) (: brush-style Plot-Brush-Style-Sym) (define brush-color '(255 255 255)) (define brush-style 'solid) - + (: background-color (List Real Real Real)) (define background-color '(255 255 255)) - + (: font-size Nonnegative-Real) (: font-face (U #f String)) (: font-family Font-Family) (define font-size 11) (define font-face #f) (define font-family 'roman) - + (: text-foreground (List Real Real Real)) (define text-foreground '(0 0 0)) @@ -1429,41 +1429,41 @@ (define pa-arrow-head-size-or-scale (arrow-head-size-or-scale)) (define pa-arrow-head-angle (arrow-head-angle)) - + ;; Drawing parameter accessors - + (define/public (put-alpha a) (set! alpha a)) - + (define/public (put-pen color width style) (set! pen-color (->pen-color color)) (set! pen-width width) (set! pen-style (->pen-style style))) - + (define/public (put-major-pen [style 'solid]) (put-pen (plot-foreground) (plot-line-width) style)) - + (define/public (put-minor-pen [style 'solid]) (put-pen (plot-foreground) (* 1/2 (plot-line-width)) style)) - + (define/public (put-brush color style) (set! brush-color (->brush-color color)) (set! brush-style (->brush-style style))) - + (define/public (put-background color) (set! background-color (->brush-color color))) - + (define/public (put-font-size size) (set! font-size size)) (define/public (put-font-face face) (set! font-face face)) (define/public (put-font-family family) (set! font-family family)) - + (define/public (put-font-attribs size face family) (put-font-size size) (put-font-face face) (put-font-family family)) - + (define/public (put-text-foreground c) (set! text-foreground (->pen-color c))) - + (define/public (put-arrow-head size-or-scale angle) (set! pa-arrow-head-size-or-scale size-or-scale) (set! pa-arrow-head-angle angle)) @@ -1475,9 +1475,9 @@ (put-background (plot-background)) (put-font-attribs (plot-font-size) (plot-font-face) (plot-font-family)) (put-text-foreground (plot-foreground))) - + ;; Drawing shapes - + (define/public (put-line v1 v2) (let ([v1 (exact-vector3d v1)] [v2 (exact-vector3d v2)]) @@ -1499,7 +1499,7 @@ (add-shape! plot3d-area-layer (lines (line-data alpha pen-color pen-width pen-style) (map (λ ([v : (Vectorof Real)]) (plot->norm v)) vs)))])))))) - + (define/public (put-lines vs) (for ([vs (in-list (exact-vector3d-sublists vs))]) (let ([vss (if clipping? @@ -1519,7 +1519,7 @@ (add-shape! plot3d-area-layer (lines (line-data alpha pen-color pen-width pen-style) (map (λ ([v : (Vectorof Real)]) (plot->norm v)) vs)))))])))) - + (define/public (put-polygon vs [face 'both] [ls (make-list (length vs) #t)]) (let-values ([(vs ls) (exact-polygon3d vs ls)]) (unless (empty? vs) @@ -1542,7 +1542,7 @@ pen-color pen-width pen-style brush-color brush-style face) norm-vs ls normal))))))) - + (define/public (put-rect r) (let ([r (if (rect-rational? r) (rect-meet r bounds-rect) r)]) (when (rect-rational? r) @@ -1565,7 +1565,7 @@ (define z-mid (* 0.5 (+ z-max z-min))) ;; Faces are a list of center, normal, then vertices (define faces - (list + (list ;; Bottom (z-min) face (list (flvector x-mid y-mid z-min) (flvector 0.0 0.0 -1.0) (flvector x-min y-min z-min) (flvector x-max y-min z-min) @@ -1598,7 +1598,7 @@ pen-color pen-width pen-style brush-color brush-style 'front) vs ls normal))))))) - + (define/public (put-text str v [anchor 'center] [angle 0] [dist 0] [outline? #f] [layer plot3d-area-layer]) (let ([v (exact-vector3d v)]) @@ -1606,7 +1606,7 @@ (add-shape! layer (points (text-data alpha anchor angle dist str font-size font-family text-foreground outline?) (list (plot->norm v))))))) - + (define/public (put-glyphs vs symbol size [layer plot3d-area-layer]) (let ([vs (filter (λ ([v : (U #f (Vectorof Real))]) (and v (in-bounds? v))) (map exact-vector3d vs))]) @@ -1617,7 +1617,7 @@ (map (λ ([v : (U #f (Vectorof Real))]) (plot->norm (assert v values))) vs)))))) - + (define/public (put-arrow v1 v2 [draw-outside? #f]) (let ([v1 (exact-vector3d v1)] [v2 (exact-vector3d v2)])