Use rational? instead of regular-real?, cut some cruft
Make docs compile without warnings
This commit is contained in:
parent
e788c6f49e
commit
a23808dd95
|
@ -146,10 +146,10 @@
|
|||
|
||||
(defproc (ivl->string [i ivl?] [extra-digits exact-integer? 3]) string?
|
||||
(match-define (ivl a b) i)
|
||||
(cond [(and (not (regular-real? a)) (not (regular-real? b)))
|
||||
(cond [(and (not (rational? a)) (not (rational? b)))
|
||||
(format "[~a,~a]" (format-special a) (format-special b))]
|
||||
[(not (regular-real? a)) (format "[~a,~a]" (format-special a) (real->plot-label b 15))]
|
||||
[(not (regular-real? b)) (format "[~a,~a]" (real->plot-label a 15) (format-special b))]
|
||||
[(not (rational? a)) (format "[~a,~a]" (format-special a) (real->plot-label b 15))]
|
||||
[(not (rational? b)) (format "[~a,~a]" (real->plot-label a 15) (format-special b))]
|
||||
[else
|
||||
(define digits (digits-for-range a b extra-digits))
|
||||
(format "[~a,~a]"
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
(defproc (infinite? [x any/c]) boolean?
|
||||
(and (flonum? x) (or (unsafe-fl= x +inf.0) (unsafe-fl= x -inf.0))))
|
||||
|
||||
(defproc (special-real? [x any/c]) boolean?
|
||||
(and (flonum? x) (or (unsafe-fl= x +inf.0) (unsafe-fl= x -inf.0) (eqv? x +nan.0))))
|
||||
|
||||
(defproc (flblend [x flonum?] [y flonum?] [α flonum?]) flonum?
|
||||
(cond [(not (flonum? x)) (raise-type-error 'flblend "flonum" 0 x y α)]
|
||||
[(not (flonum? y)) (raise-type-error 'flblend "flonum" 1 x y α)]
|
||||
|
@ -95,16 +92,13 @@
|
|||
;; ===================================================================================================
|
||||
;; Reals
|
||||
|
||||
(defproc (regular-real? [x any/c]) boolean?
|
||||
(and (real? x) (not (special-real? x))))
|
||||
|
||||
(defproc (maybe-inexact->exact [x (or/c regular-real? #f)]) (or/c regular-real? #f)
|
||||
(cond [x (unless (regular-real? x)
|
||||
(raise-type-error 'maybe-inexact->exact "regular real or #f" x))
|
||||
(defproc (maybe-inexact->exact [x (or/c rational? #f)]) (or/c rational? #f)
|
||||
(cond [x (unless (rational? x)
|
||||
(raise-type-error 'maybe-inexact->exact "rational or #f" x))
|
||||
(inexact->exact x)]
|
||||
[else #f]))
|
||||
|
||||
(defproc (flonum-ok-for-range? [x-min regular-real?] [x-max regular-real?]
|
||||
(defproc (flonum-ok-for-range? [x-min rational?] [x-max rational?]
|
||||
[size exact-positive-integer?]) boolean?
|
||||
(let/ec return
|
||||
(let ([x-min (inexact->exact (min x-min x-max))]
|
||||
|
@ -112,16 +106,16 @@
|
|||
(define step-size (/ (- x-max x-min) size))
|
||||
|
||||
(define inexact-x-min (exact->inexact x-min))
|
||||
(unless (regular-real? inexact-x-min) (return #f))
|
||||
(unless (rational? inexact-x-min) (return #f))
|
||||
|
||||
(define inexact-x-max (exact->inexact x-max))
|
||||
(unless (regular-real? inexact-x-max) (return #f))
|
||||
(unless (rational? inexact-x-max) (return #f))
|
||||
|
||||
(define inexact-x-max-prev (flprev inexact-x-max))
|
||||
(unless (regular-real? inexact-x-max-prev) (return #f))
|
||||
(unless (rational? inexact-x-max-prev) (return #f))
|
||||
|
||||
(define inexact-x-min-next (flnext inexact-x-min))
|
||||
(unless (regular-real? inexact-x-min-next) (return #f))
|
||||
(unless (rational? inexact-x-min-next) (return #f))
|
||||
|
||||
(define max-diff (- x-max (inexact->exact inexact-x-max-prev)))
|
||||
(define min-diff (- (inexact->exact inexact-x-min-next) x-min))
|
||||
|
@ -423,27 +417,12 @@
|
|||
(cond [(= d 0) 0]
|
||||
[else (/ d (vmag v1) (vmag v2))]))
|
||||
|
||||
(define-syntax-rule (unsafe-flspecial? x)
|
||||
(or (unsafe-fl= x +inf.0) (unsafe-fl= x -inf.0) (eqv? x +nan.0)))
|
||||
|
||||
(define-syntax-rule (unsafe-flregular? x)
|
||||
(not (unsafe-flspecial? x)))
|
||||
|
||||
(defproc (vregular? [v (vectorof real?)]) boolean?
|
||||
(defproc (vrational? [v (vectorof real?)]) boolean?
|
||||
(match v
|
||||
[(vector (? real? x) (? real? y))
|
||||
(not (or (and (flonum? x) (unsafe-flspecial? x))
|
||||
(and (flonum? y) (unsafe-flspecial? y))))]
|
||||
[(vector (? real? x) (? real? y) (? real? z))
|
||||
(not (or (and (flonum? x) (unsafe-flspecial? x))
|
||||
(and (flonum? y) (unsafe-flspecial? y))
|
||||
(and (flonum? z) (unsafe-flspecial? z))))]
|
||||
[_ (cond [(vector-andmap real? v) (let/ec break
|
||||
(for ([x (in-vector v)])
|
||||
(when (and (flonum? x) (unsafe-flspecial? x))
|
||||
(break #f)))
|
||||
#t)]
|
||||
[else (raise-type-error 'vregular? "vector of real numbers" v)])]))
|
||||
[(vector (? rational? x) (? rational? y)) #t]
|
||||
[(vector (? rational? x) (? rational? y) (? rational? z)) #t]
|
||||
[(? vector?) (vector-andmap rational? v)]
|
||||
[_ (raise-type-error 'vrational? "vector" v)]))
|
||||
|
||||
(defproc (v= [v1 (vectorof real?)] [v2 (vectorof real?)]) boolean?
|
||||
(match v1
|
||||
|
@ -488,12 +467,12 @@
|
|||
(define maxs (vector-map (λ (xs) (apply max xs)) xss))
|
||||
(unrolled-vmap2 'vcenter (λ (x1 x2) (* 1/2 (+ x1 x2))) mins maxs)]))
|
||||
|
||||
(define (vregular-sublists vs)
|
||||
(define (vrational-sublists vs)
|
||||
(define res
|
||||
(let loop ([vs vs])
|
||||
(cond [(null? vs) (list null)]
|
||||
[(vregular? (car vs)) (define rst (loop (cdr vs)))
|
||||
(cons (cons (car vs) (car rst)) (cdr rst))]
|
||||
[(vrational? (car vs)) (define rst (loop (cdr vs)))
|
||||
(cons (cons (car vs) (car rst)) (cdr rst))]
|
||||
[else (cons null (loop (cdr vs)))])))
|
||||
(cond [(and (not (null? res)) (null? (car res))) (cdr res)]
|
||||
[else res]))
|
||||
|
@ -554,12 +533,12 @@
|
|||
(match-define (ivl a b) i)
|
||||
(and a b #t))
|
||||
|
||||
(defproc (ivl-regular? [i ivl?]) boolean?
|
||||
(defproc (ivl-rational? [i ivl?]) boolean?
|
||||
(match-define (ivl a b) i)
|
||||
(and (regular-real? a) (regular-real? b)))
|
||||
(and (rational? a) (rational? b)))
|
||||
|
||||
(defproc (regular-ivl? [i any/c]) boolean?
|
||||
(and (ivl? i) (ivl-regular? i)))
|
||||
(defproc (rational-ivl? [i any/c]) boolean?
|
||||
(and (ivl? i) (ivl-rational? i)))
|
||||
|
||||
(defproc (ivl-singular? [i ivl?]) boolean?
|
||||
(match-define (ivl a b) i)
|
||||
|
@ -638,8 +617,11 @@
|
|||
(defproc (rect-known? [r (vectorof ivl?)]) boolean?
|
||||
(vector-andmap ivl-known? r))
|
||||
|
||||
(defproc (rect-regular? [r (vectorof ivl?)]) boolean?
|
||||
(vector-andmap ivl-regular? r))
|
||||
(defproc (rect-rational? [r (vectorof ivl?)]) boolean?
|
||||
(vector-andmap ivl-rational? r))
|
||||
|
||||
(defproc (rational-rect? [r any/c]) boolean?
|
||||
(and (vector? r) (vector-andmap rational-ivl? r)))
|
||||
|
||||
(defproc (rect-area [r (vectorof ivl?)]) (or/c real? #f)
|
||||
(let/ec break
|
||||
|
|
|
@ -26,22 +26,22 @@
|
|||
(cond [(= (vector-length r) 3) (values empty empty empty empty ts far-ts)]
|
||||
[else (raise-type-error 'z-ticks-fun "3-vector of ivls" r)])))
|
||||
|
||||
(defproc (x-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) non-renderer?
|
||||
(non-renderer #f #f (x-ticks-fun ts far?)))
|
||||
(defproc (x-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) nonrenderer?
|
||||
(nonrenderer #f #f (x-ticks-fun ts far?)))
|
||||
|
||||
(defproc (y-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) non-renderer?
|
||||
(non-renderer #f #f (y-ticks-fun ts far?)))
|
||||
(defproc (y-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) nonrenderer?
|
||||
(nonrenderer #f #f (y-ticks-fun ts far?)))
|
||||
|
||||
(defproc (z-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) non-renderer?
|
||||
(non-renderer #f #f (z-ticks-fun ts far?)))
|
||||
(defproc (z-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) nonrenderer?
|
||||
(nonrenderer #f #f (z-ticks-fun ts far?)))
|
||||
|
||||
(defproc (invisible-rect [x-min (or/c regular-real? #f)] [x-max (or/c regular-real? #f)]
|
||||
[y-min (or/c regular-real? #f)] [y-max (or/c regular-real? #f)]
|
||||
) non-renderer?
|
||||
(non-renderer (vector (ivl x-min x-max) (ivl y-min y-max)) #f #f))
|
||||
(defproc (invisible-rect [x-min (or/c rational? #f)] [x-max (or/c rational? #f)]
|
||||
[y-min (or/c rational? #f)] [y-max (or/c rational? #f)]
|
||||
) nonrenderer?
|
||||
(nonrenderer (vector (ivl x-min x-max) (ivl y-min y-max)) #f #f))
|
||||
|
||||
(defproc (invisible-rect3d [x-min (or/c regular-real? #f)] [x-max (or/c regular-real? #f)]
|
||||
[y-min (or/c regular-real? #f)] [y-max (or/c regular-real? #f)]
|
||||
[z-min (or/c regular-real? #f)] [z-max (or/c regular-real? #f)]
|
||||
) non-renderer?
|
||||
(non-renderer (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f #f))
|
||||
(defproc (invisible-rect3d [x-min (or/c rational? #f)] [x-max (or/c rational? #f)]
|
||||
[y-min (or/c rational? #f)] [y-max (or/c rational? #f)]
|
||||
[z-min (or/c rational? #f)] [z-max (or/c rational? #f)]
|
||||
) nonrenderer?
|
||||
(nonrenderer (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f #f))
|
|
@ -254,12 +254,12 @@
|
|||
(send dc set-alpha old-alpha))
|
||||
|
||||
(define/public (draw-point v)
|
||||
(when (vregular? v)
|
||||
(when (vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
(send dc draw-point x y)))
|
||||
|
||||
(define/public (draw-polygon vs)
|
||||
(when (andmap vregular? vs)
|
||||
(when (andmap vrational? vs)
|
||||
(let ([vs (map coord->cons vs)])
|
||||
(cond [(eq? pen-style 'transparent)
|
||||
(send dc set-smoothing 'unsmoothed)
|
||||
|
@ -275,22 +275,22 @@
|
|||
(draw-lines/pen-style dc (cons (last vs) vs) pen-style)]))))
|
||||
|
||||
(define/public (draw-rect r)
|
||||
(when (rect-regular? r)
|
||||
(when (rect-rational? r)
|
||||
(match-define (vector (ivl x1 x2) (ivl y1 y2)) r)
|
||||
(draw-polygon (list (vector x1 y1) (vector x1 y2) (vector x2 y2) (vector x2 y1)))))
|
||||
|
||||
(define/public (draw-lines vs)
|
||||
(when (andmap vregular? vs)
|
||||
(when (andmap vrational? vs)
|
||||
(draw-lines/pen-style dc (map coord->cons vs) pen-style)))
|
||||
|
||||
(define/public (draw-line v1 v2)
|
||||
(when (and (vregular? v1) (vregular? v2))
|
||||
(when (and (vrational? v1) (vrational? v2))
|
||||
(match-define (vector x1 y1) v1)
|
||||
(match-define (vector x2 y2) v2)
|
||||
(draw-line/pen-style dc x1 y1 x2 y2 pen-style)))
|
||||
|
||||
(define/public (draw-text str v [anchor 'top-left] [angle 0] #:outline? [outline? #f])
|
||||
(when (vregular? v)
|
||||
(when (vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
|
||||
(when outline?
|
||||
|
@ -309,14 +309,14 @@
|
|||
(draw-text/anchor dc str x y anchor #t 0 angle)))
|
||||
|
||||
(define/public (get-text-corners str v [anchor 'top-left] [angle 0])
|
||||
(cond [(vregular? v)
|
||||
(cond [(vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
(map (λ (v) (vector-map inexact->exact v))
|
||||
(get-text-corners/anchor dc str x y anchor #t 0 angle))]
|
||||
[else empty]))
|
||||
|
||||
(define/public (draw-arrow v1 v2)
|
||||
(when (and (vregular? v1) (vregular? v2))
|
||||
(when (and (vrational? v1) (vrational? v2))
|
||||
(match-define (vector x1 y1) v1)
|
||||
(match-define (vector x2 y2) v2)
|
||||
(define dx (- x2 x1))
|
||||
|
@ -337,14 +337,14 @@
|
|||
;; Glyph (point sym) primitives
|
||||
|
||||
(define/public ((make-draw-circle-glyph r) v)
|
||||
(when (vregular? v)
|
||||
(when (vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
(send dc draw-ellipse (- x r -1/2) (- y r -1/2) (* 2 r) (* 2 r))))
|
||||
|
||||
(define/public (make-draw-polygon-glyph r sides start-angle)
|
||||
(define angles (linear-seq start-angle (+ start-angle (* 2 pi)) (+ 1 sides)))
|
||||
(λ (v)
|
||||
(when (vregular? v)
|
||||
(when (vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
(send dc draw-polygon (map (λ (a) (cons (+ x (* (cos a) r)) (+ y (* (sin a) r))))
|
||||
angles)))))
|
||||
|
@ -352,7 +352,7 @@
|
|||
(define/public (make-draw-star-glyph r sides start-angle)
|
||||
(define angles (linear-seq start-angle (+ start-angle (* 2 pi)) (+ 1 (* 2 sides))))
|
||||
(λ (v)
|
||||
(when (vregular? v)
|
||||
(when (vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
(define pts
|
||||
(for/list ([a (in-list angles)] [i (in-naturals)])
|
||||
|
@ -366,7 +366,7 @@
|
|||
(define step (/ (* 2 pi) sticks))
|
||||
(define angles (build-list sticks (λ (n) (+ start-angle (* n step)))))
|
||||
(λ (v)
|
||||
(when (vregular? v)
|
||||
(when (vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
(for ([a (in-list angles)])
|
||||
(send dc draw-line x y (+ x (* (cos a) r)) (+ y (* (sin a) r)))))))
|
||||
|
@ -381,7 +381,7 @@
|
|||
(define dx (* (cos angle) r))
|
||||
(define dy (* (sin angle) r))
|
||||
(λ (v)
|
||||
(when (vregular? v)
|
||||
(when (vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
(send dc draw-line (- x dx) (- y dy) (+ x dx) (+ y dy)))))
|
||||
|
||||
|
@ -398,7 +398,7 @@
|
|||
(define dx2 (* (cos (- angle head-angle)) head-r))
|
||||
(define dy2 (* (sin (- angle head-angle)) head-r))
|
||||
(λ (v)
|
||||
(when (vregular? v)
|
||||
(when (vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
(define head-x (+ x dx))
|
||||
(define head-y (+ y dy))
|
||||
|
@ -416,7 +416,7 @@
|
|||
(define dx (* 1/2 x-size))
|
||||
(define dy (* 1/2 y-size))
|
||||
(λ (v)
|
||||
(when (vregular? v)
|
||||
(when (vrational? v)
|
||||
(match-define (vector x y) v)
|
||||
(send dc draw-text str (- x dx) (- y dy) #t))))
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
(provide (all-defined-out))
|
||||
|
||||
(struct plot-element (bounds-rect bounds-fun ticks-fun) #:transparent)
|
||||
(struct non-renderer plot-element () #:transparent)
|
||||
(struct nonrenderer plot-element () #:transparent)
|
||||
(struct renderer2d plot-element (render-proc) #:transparent)
|
||||
(struct renderer3d plot-element (render-proc) #:transparent)
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
(λ ()
|
||||
(define xs (nonlinear-seq x-min x-max x-samples tx))
|
||||
(define ys (map* f xs))
|
||||
(define rys (filter regular-real? ys))
|
||||
(define rys (filter rational? ys))
|
||||
(define-values (y-min y-max)
|
||||
(cond [(empty? rys) (values #f #f)]
|
||||
[else (values (apply min* rys) (apply max* rys))]))
|
||||
|
@ -121,7 +121,7 @@
|
|||
(define zss (for/vector #:length y-samples ([y (in-list ys)])
|
||||
(for/vector #:length x-samples ([x (in-list xs)])
|
||||
(let ([z (f x y)])
|
||||
(when (regular-real? z)
|
||||
(when (rational? z)
|
||||
(unless (and z-min (z . >= . z-min)) (set! z-min z))
|
||||
(unless (and z-max (z . <= . z-max)) (set! z-max z)))
|
||||
z))))
|
||||
|
@ -152,7 +152,7 @@
|
|||
(for/vector #:length y-samples ([y (in-list ys)])
|
||||
(for/vector #:length x-samples ([x (in-list xs)])
|
||||
(let ([d (f x y z)])
|
||||
(when (regular-real? d)
|
||||
(when (rational? d)
|
||||
(unless (and d-min (d . >= . d-min)) (set! d-min d))
|
||||
(unless (and d-max (d . <= . d-max)) (set! d-max d)))
|
||||
d)))))
|
||||
|
@ -227,22 +227,22 @@
|
|||
(exact->inexact d))))
|
||||
d-min d-max))
|
||||
|
||||
(defproc (flonum-ok-for-2d? [x-min regular-real?] [x-max regular-real?]
|
||||
[y-min regular-real?] [y-max regular-real?]) boolean?
|
||||
(defproc (flonum-ok-for-2d? [x-min rational?] [x-max rational?]
|
||||
[y-min rational?] [y-max rational?]) boolean?
|
||||
(and (flonum-ok-for-range? x-min x-max 10000)
|
||||
(flonum-ok-for-range? y-min y-max 10000)))
|
||||
|
||||
(defproc (flonum-ok-for-3d? [x-min regular-real?] [x-max regular-real?]
|
||||
[y-min regular-real?] [y-max regular-real?]
|
||||
[z-min regular-real?] [z-max regular-real?]) boolean?
|
||||
(defproc (flonum-ok-for-3d? [x-min rational?] [x-max rational?]
|
||||
[y-min rational?] [y-max rational?]
|
||||
[z-min rational?] [z-max rational?]) boolean?
|
||||
(and (flonum-ok-for-range? x-min x-max 10000)
|
||||
(flonum-ok-for-range? y-min y-max 10000)
|
||||
(flonum-ok-for-range? z-min z-max 10000)))
|
||||
|
||||
(defproc (flonum-ok-for-4d? [x-min regular-real?] [x-max regular-real?]
|
||||
[y-min regular-real?] [y-max regular-real?]
|
||||
[z-min regular-real?] [z-max regular-real?]
|
||||
[d-min regular-real?] [d-max regular-real?]) boolean?
|
||||
(defproc (flonum-ok-for-4d? [x-min rational?] [x-max rational?]
|
||||
[y-min rational?] [y-max rational?]
|
||||
[z-min rational?] [z-max rational?]
|
||||
[d-min rational?] [d-max rational?]) boolean?
|
||||
(and (flonum-ok-for-range? x-min x-max 10000)
|
||||
(flonum-ok-for-range? y-min y-max 10000)
|
||||
(flonum-ok-for-range? z-min z-max 10000)
|
||||
|
|
|
@ -5,32 +5,32 @@
|
|||
(require "../common/math.rkt")
|
||||
(provide equal?*
|
||||
;; Flonums
|
||||
nan? infinite? special-real?
|
||||
nan? infinite?
|
||||
flblend flatan2 flsum flmodulo fldistance
|
||||
(activate-contract-out flonum->ordinal ordinal->flonum flstep flnext flprev
|
||||
flonum-ok-for-range?)
|
||||
-max.0 -min.0 +min.0 +max.0
|
||||
;; Reals
|
||||
regular-real? maybe-inexact->exact
|
||||
maybe-inexact->exact
|
||||
min* max* degrees->radians radians->degrees blend atan2 sum real-modulo distance
|
||||
floor-log/base ceiling-log/base
|
||||
polar->cartesian 3d-polar->3d-cartesian
|
||||
;; Vectors
|
||||
vcross vcross2 v+ v- vneg v* v/ vmag^2 vmag vnormalize vdot vcos-angle vregular? v= vcenter)
|
||||
vcross vcross2 v+ v- vneg v* v/ vmag^2 vmag vnormalize vdot vcos-angle vrational? v= vcenter)
|
||||
|
||||
;; Intervals
|
||||
(provide (contract-out (struct ivl ([min (or/c real? #f)] [max (or/c real? #f)]))
|
||||
[ivl-meet (->* () () #:rest (listof ivl?) ivl?)]
|
||||
[ivl-join (->* () () #:rest (listof ivl?) ivl?)])
|
||||
empty-ivl unknown-ivl regular-ivl?
|
||||
empty-ivl unknown-ivl rational-ivl?
|
||||
(activate-contract-out
|
||||
ivl-empty? ivl-known? ivl-regular? ivl-singular? ivl-length ivl-center ivl-zero-length?
|
||||
ivl-empty? ivl-known? ivl-rational? ivl-singular? ivl-length ivl-center ivl-zero-length?
|
||||
ivl-inexact->exact ivl-contains? bounds->intervals))
|
||||
|
||||
;; Rectangles
|
||||
(provide (contract-out [rect-meet (->* () () #:rest (listof (vectorof ivl?)) (vectorof ivl?))]
|
||||
[rect-join (->* () () #:rest (listof (vectorof ivl?)) (vectorof ivl?))])
|
||||
(activate-contract-out
|
||||
empty-rect unknown-rect bounding-rect
|
||||
rect-empty? rect-known? rect-regular? rect-area rect-center rect-zero-area? rect-singular?
|
||||
empty-rect unknown-rect bounding-rect rational-rect?
|
||||
rect-empty? rect-known? rect-rational? rect-area rect-center rect-zero-area? rect-singular?
|
||||
rect-inexact->exact rect-contains?))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
([bounds-rect (or/c (vectorof ivl?) #f)]
|
||||
[bounds-fun (or/c bounds-fun/c #f)]
|
||||
[ticks-fun (or/c ticks-fun/c #f)]))
|
||||
(struct (non-renderer plot-element)
|
||||
(struct (nonrenderer plot-element)
|
||||
([bounds-rect (or/c (vectorof ivl?) #f)]
|
||||
[bounds-fun (or/c bounds-fun/c #f)]
|
||||
[ticks-fun (or/c ticks-fun/c #f)]))
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
"../common/math.rkt")
|
||||
(provide (contract-out (struct sample ([xs (listof real?)]
|
||||
[ys (listof real?)]
|
||||
[y-min (or/c regular-real? #f)]
|
||||
[y-max (or/c regular-real? #f)]))
|
||||
[y-min (or/c rational? #f)]
|
||||
[y-max (or/c rational? #f)]))
|
||||
(struct 2d-sample ([xs (listof real?)]
|
||||
[ys (listof real?)]
|
||||
[zss (vectorof (vectorof real?))]
|
||||
[z-min (or/c regular-real? #f)]
|
||||
[z-max (or/c regular-real? #f)]))
|
||||
[z-min (or/c rational? #f)]
|
||||
[z-max (or/c rational? #f)]))
|
||||
(struct 3d-sample ([xs (listof real?)]
|
||||
[ys (listof real?)]
|
||||
[zs (listof real?)]
|
||||
[dsss (vectorof (vectorof (vectorof real?)))]
|
||||
[d-min (or/c regular-real? #f)]
|
||||
[d-max (or/c regular-real? #f)])))
|
||||
[d-min (or/c rational? #f)]
|
||||
[d-max (or/c rational? #f)])))
|
||||
(activate-contract-out build-linear-seq linear-seq linear-seq* nonlinear-seq
|
||||
sampler/c 2d-sampler/c 3d-sampler/c
|
||||
make-function->sampler
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"common/ticks.rkt"
|
||||
"common/math.rkt"
|
||||
"common/plot-element.rkt"
|
||||
"common/non-renderer.rkt"
|
||||
"common/nonrenderer.rkt"
|
||||
"common/format.rkt"
|
||||
"common/sample.rkt"
|
||||
"common/draw.rkt"
|
||||
|
@ -27,7 +27,7 @@
|
|||
(all-from-out "common/ticks.rkt")
|
||||
(all-from-out "common/math.rkt")
|
||||
(all-from-out "common/plot-element.rkt")
|
||||
(all-from-out "common/non-renderer.rkt")
|
||||
(all-from-out "common/nonrenderer.rkt")
|
||||
(all-from-out "common/format.rkt")
|
||||
(all-from-out "common/sample.rkt")
|
||||
(all-from-out "common/draw.rkt")
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
plot-time->seconds seconds->plot-time
|
||||
datetime->real)
|
||||
|
||||
(require "common/non-renderer.rkt")
|
||||
(require "common/nonrenderer.rkt")
|
||||
(provide (activate-contract-out x-ticks y-ticks z-ticks invisible-rect invisible-rect3d))
|
||||
|
||||
;; ===================================================================================================
|
||||
|
|
|
@ -34,10 +34,8 @@
|
|||
|
||||
(defproc (isoline
|
||||
[f (real? real? . -> . real?)] [z real?]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
|
@ -85,10 +83,8 @@
|
|||
|
||||
(defproc (contours
|
||||
[f (real? real? . -> . real?)]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)]
|
||||
[#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)]
|
||||
[#:colors colors (plot-colors/c (listof real?)) (contour-colors)]
|
||||
|
@ -161,10 +157,8 @@
|
|||
|
||||
(defproc (contour-intervals
|
||||
[f (real? real? . -> . real?)]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)]
|
||||
[#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)]
|
||||
[#:colors colors (plot-colors/c (listof ivl?)) (contour-interval-colors)]
|
||||
|
|
|
@ -35,10 +35,8 @@
|
|||
(defproc (lines-interval
|
||||
[v1s (listof (vector/c real? real?))]
|
||||
[v2s (listof (vector/c real? real?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (interval-color)]
|
||||
[#:style style plot-brush-style/c (interval-style)]
|
||||
[#:line1-color line1-color plot-color/c (interval-line1-color)]
|
||||
|
@ -50,7 +48,7 @@
|
|||
[#:alpha alpha (real-in 0 1) (interval-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(define rvs (filter vregular? (append v1s v2s)))
|
||||
(define rvs (filter vrational? (append v1s v2s)))
|
||||
(cond
|
||||
[(empty? rvs) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
|
@ -68,11 +66,9 @@
|
|||
(defproc (parametric-interval
|
||||
[f1 (real? . -> . (vector/c real? real?))]
|
||||
[f2 (real? . -> . (vector/c real? real?))]
|
||||
[t-min real?] [t-max real?]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[t-min rational?] [t-max rational?]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (interval-color)]
|
||||
[#:style style plot-brush-style/c (interval-style)]
|
||||
|
@ -96,11 +92,9 @@
|
|||
|
||||
(defproc (polar-interval
|
||||
[f1 (real? . -> . real?)] [f2 (real? . -> . real?)]
|
||||
[θ-min real? 0] [θ-max real? (* 2 pi)]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[θ-min rational? 0] [θ-max rational? (* 2 pi)]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (interval-color)]
|
||||
[#:style style plot-brush-style/c (interval-style)]
|
||||
|
@ -145,10 +139,8 @@
|
|||
|
||||
(defproc (function-interval
|
||||
[f1 (real? . -> . real?)] [f2 (real? . -> . real?)]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (interval-color)]
|
||||
[#:style style plot-brush-style/c (interval-style)]
|
||||
|
@ -193,10 +185,8 @@
|
|||
|
||||
(defproc (inverse-interval
|
||||
[f1 (real? . -> . real?)] [f2 (real? . -> . real?)]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (interval-color)]
|
||||
[#:style style plot-brush-style/c (interval-style)]
|
||||
|
|
|
@ -82,8 +82,8 @@
|
|||
(define series-terms 9)
|
||||
|
||||
(defproc (kde [xs (listof real?)] [h real?]) (values mapped-function?
|
||||
(or/c regular-real? #f)
|
||||
(or/c regular-real? #f))
|
||||
(or/c rational? #f)
|
||||
(or/c rational? #f))
|
||||
(if (empty? xs)
|
||||
(values (mapped-function (λ (y) 0) (λ (ys) (map (λ _ 0.0) ys))) #f #f)
|
||||
(let* ([xs (list->vector (sort (map exact->inexact xs) fl<))]
|
||||
|
@ -132,10 +132,8 @@
|
|||
(values (mapped-function (λ (x) (first (fmap (list x)))) fmap) x-min x-max))))
|
||||
|
||||
(defproc (density [xs (listof real?)] [bw-adjust real? 1]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
|
|
|
@ -20,17 +20,15 @@
|
|||
[else empty]))
|
||||
|
||||
(defproc (lines [vs (listof (vector/c real? real?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
[#:style style plot-pen-style/c (line-style)]
|
||||
[#:alpha alpha (real-in 0 1) (line-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(define rvs (filter vregular? vs))
|
||||
(define rvs (filter vrational? vs))
|
||||
(cond [(empty? rvs) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector rxs rys) ...) rvs)
|
||||
|
@ -42,11 +40,9 @@
|
|||
(lines-render-proc vs color width style alpha label)))]))
|
||||
|
||||
(defproc (parametric [f (real? . -> . (vector/c real? real?))]
|
||||
[t-min regular-real?] [t-max regular-real?]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[t-min rational?] [t-max rational?]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
|
@ -61,10 +57,8 @@
|
|||
|
||||
(defproc (polar [f (real? . -> . real?)]
|
||||
[θ-min real? 0] [θ-max real? (* 2 pi)]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
|
@ -93,10 +87,8 @@
|
|||
[else empty]))
|
||||
|
||||
(defproc (function [f (real? . -> . real?)]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
|
@ -125,10 +117,8 @@
|
|||
[else empty]))
|
||||
|
||||
(defproc (inverse [f (real? . -> . real?)]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
|
|
|
@ -405,7 +405,7 @@
|
|||
;; Shapes
|
||||
|
||||
(define/public (put-lines vs)
|
||||
(for ([vs (vregular-sublists vs)])
|
||||
(for ([vs (vrational-sublists vs)])
|
||||
(for ([vs (if clipping?
|
||||
(in-list (clip-lines vs clip-x-min clip-x-max
|
||||
clip-y-min clip-y-max))
|
||||
|
@ -415,7 +415,7 @@
|
|||
(send pd draw-lines (map (λ (v) (plot->dc* v)) vs)))))))
|
||||
|
||||
(define/public (put-line v1 v2)
|
||||
(when (and (vregular? v1) (vregular? v2))
|
||||
(when (and (vrational? v1) (vrational? v2))
|
||||
(let-values ([(v1 v2) (if clipping?
|
||||
(clip-line v1 v2 clip-x-min clip-x-max
|
||||
clip-y-min clip-y-max)
|
||||
|
@ -427,7 +427,7 @@
|
|||
(subdivide-line plot->dc* v1 v2))))))))
|
||||
|
||||
(define/public (put-polygon vs)
|
||||
(when (andmap vregular? vs)
|
||||
(when (andmap vrational? vs)
|
||||
(let* ([vs (if clipping?
|
||||
(clip-polygon vs clip-x-min clip-x-max
|
||||
clip-y-min clip-y-max)
|
||||
|
@ -439,26 +439,26 @@
|
|||
(subdivide-polygon plot->dc* vs))))))))
|
||||
|
||||
(define/public (put-rect r)
|
||||
(when (rect-regular? r)
|
||||
(when (rect-rational? r)
|
||||
(match-define (vector (ivl x1 x2) (ivl y1 y2)) r)
|
||||
(put-polygon (list (vector x1 y1) (vector x2 y1) (vector x2 y2) (vector x1 y2)))))
|
||||
|
||||
(define/public (put-text str v [anchor 'top-left] [angle 0]
|
||||
#:outline? [outline? #f])
|
||||
(when (and (vregular? v) (in-bounds? v))
|
||||
(when (and (vrational? v) (in-bounds? v))
|
||||
(send pd draw-text str (plot->dc* v) anchor angle #:outline? outline?)))
|
||||
|
||||
(define/public (put-glyphs vs symbol size)
|
||||
(send pd draw-glyphs (map (λ (v) (plot->dc* v))
|
||||
(filter (λ (v) (and (vregular? v) (in-bounds? v)))
|
||||
(filter (λ (v) (and (vrational? v) (in-bounds? v)))
|
||||
vs))
|
||||
symbol size))
|
||||
|
||||
(define/public (put-arrow v1 v2)
|
||||
(when (and (vregular? v1) (vregular? v2) (in-bounds? v1))
|
||||
(when (and (vrational? v1) (vrational? v2) (in-bounds? v1))
|
||||
(send pd draw-arrow (plot->dc* v1) (plot->dc* v2))))
|
||||
|
||||
(define/public (put-tick v r angle)
|
||||
(when (and (vregular? v) (in-bounds? v))
|
||||
(when (and (vrational? v) (in-bounds? v))
|
||||
(send pd draw-tick (plot->dc* v) r angle)))
|
||||
))
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
(define (get-renderer-list renderer-tree)
|
||||
(for/list ([r (flatten (list renderer-tree))])
|
||||
(match r
|
||||
[(non-renderer bounds-rect bounds-fun ticks-fun)
|
||||
[(nonrenderer bounds-rect bounds-fun ticks-fun)
|
||||
(renderer2d bounds-rect bounds-fun ticks-fun #f)]
|
||||
[_ r])))
|
||||
|
||||
(define (get-bounds-rect renderer-list x-min x-max y-min y-max)
|
||||
(define given-bounds-rect (vector (ivl x-min x-max) (ivl y-min y-max)))
|
||||
(define plot-bounds-rect (bounds-fixpoint renderer-list given-bounds-rect))
|
||||
(when (or (not (rect-regular? plot-bounds-rect))
|
||||
(when (or (not (rect-rational? plot-bounds-rect))
|
||||
(rect-zero-area? plot-bounds-rect))
|
||||
(match-define (vector x-ivl y-ivl) plot-bounds-rect)
|
||||
(error 'plot "could not determine sensible plot bounds; got x ∈ ~a, y ∈ ~a"
|
||||
|
@ -74,13 +74,11 @@
|
|||
|
||||
(send area end-plot))
|
||||
|
||||
(defproc (plot/dc [renderer-tree (treeof (or/c renderer2d? non-renderer?))]
|
||||
(defproc (plot/dc [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
|
||||
[dc (is-a?/c dc<%>)]
|
||||
[x real?] [y real?] [width (>=/c 0)] [height (>=/c 0)]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:title title (or/c string? #f) (plot-title)]
|
||||
[#:x-label x-label (or/c string? #f) (plot-x-label)]
|
||||
[#:y-label y-label (or/c string? #f) (plot-y-label)]
|
||||
|
@ -101,11 +99,9 @@
|
|||
;; Plot to various other backends
|
||||
|
||||
;; Plot to a bitmap
|
||||
(defproc (plot-bitmap [renderer-tree (treeof (or/c renderer2d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot-bitmap [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:title title (or/c string? #f) (plot-title)]
|
||||
|
@ -124,11 +120,9 @@
|
|||
#:title title #:x-label x-label #:y-label y-label #:legend-anchor legend-anchor))
|
||||
width height))
|
||||
|
||||
(defproc (plot-pict [renderer-tree (treeof (or/c renderer2d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot-pict [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:title title (or/c string? #f) (plot-title)]
|
||||
|
@ -146,11 +140,9 @@
|
|||
width height))
|
||||
|
||||
;; Plot to a snip
|
||||
(defproc (plot-snip [renderer-tree (treeof (or/c renderer2d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot-snip [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:title title (or/c string? #f) (plot-title)]
|
||||
|
@ -166,11 +158,9 @@
|
|||
(make-object image-snip% bm))
|
||||
|
||||
;; Plot to a frame
|
||||
(defproc (plot-frame [renderer-tree (treeof (or/c renderer2d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot-frame [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:title title (or/c string? #f) (plot-title)]
|
||||
|
@ -186,13 +176,11 @@
|
|||
(make-snip-frame snip width height (if title (format "Plot: ~a" title) "Plot")))
|
||||
|
||||
;; Plot to a file
|
||||
(defproc (plot-file [renderer-tree (treeof (or/c renderer2d? non-renderer?))]
|
||||
(defproc (plot-file [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
|
||||
[output (or/c path-string? output-port?)]
|
||||
[kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:title title (or/c string? #f) (plot-title)]
|
||||
|
@ -231,11 +219,9 @@
|
|||
(void))
|
||||
|
||||
;; Plot to a frame or a snip, depending on (plot-new-window?)
|
||||
(defproc (plot [renderer-tree (treeof (or/c renderer2d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:title title (or/c string? #f) (plot-title)]
|
||||
|
@ -244,8 +230,7 @@
|
|||
[#:legend-anchor legend-anchor anchor/c (plot-legend-anchor)]
|
||||
[#:out-file out-file (or/c path-string? output-port? #f) #f]
|
||||
[#:out-kind out-kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
|
||||
[#:fgcolor fgcolor plot-color/c #f]
|
||||
[#:bgcolor bgcolor plot-color/c #f]
|
||||
[#:fgcolor fgcolor plot-color/c #f] [#:bgcolor bgcolor plot-color/c #f]
|
||||
[#:lncolor lncolor plot-color/c #f] ; unused
|
||||
) (or/c (is-a?/c snip%) void?)
|
||||
(when fgcolor
|
||||
|
|
|
@ -19,10 +19,8 @@
|
|||
(if label (point-legend-entry label sym color size line-width) empty))
|
||||
|
||||
(defproc (points [vs (listof (vector/c real? real?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:sym sym point-sym/c (point-sym)]
|
||||
[#:color color plot-color/c (point-color)]
|
||||
[#:size size (>=/c 0) (point-size)]
|
||||
|
@ -30,7 +28,7 @@
|
|||
[#:alpha alpha (real-in 0 1) (point-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(let ([vs (filter vregular? vs)])
|
||||
(let ([vs (filter vrational? vs)])
|
||||
(cond
|
||||
[(empty? vs) (renderer2d #f #f #f #f)]
|
||||
[else (match-define (list (vector xs ys) ...) vs)
|
||||
|
@ -53,7 +51,7 @@
|
|||
(define-values (xs ys dxs dys angles mags)
|
||||
(for*/lists (xs ys dxs dys angles mags) ([x (in-list xs0)]
|
||||
[y (in-list ys0)]
|
||||
[dv (in-value (f x y))] #:when (vregular? dv))
|
||||
[dv (in-value (f x y))] #:when (vrational? dv))
|
||||
(match-define (vector dx dy) dv)
|
||||
(values x y dx dy (atan2 dy dx) (sqrt (+ (sqr dx) (sqr dy))))))
|
||||
|
||||
|
@ -88,10 +86,8 @@
|
|||
(defproc (vector-field
|
||||
[f (or/c (real? real? . -> . (vector/c real? real?))
|
||||
((vector/c real? real?) . -> . (vector/c real? real?)))]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:samples samples exact-positive-integer? (vector-field-samples)]
|
||||
[#:scale scale (or/c real? (one-of/c 'auto 'normalized)) (vector-field-scale)]
|
||||
[#:color color plot-color/c (vector-field-color)]
|
||||
|
@ -126,17 +122,15 @@
|
|||
|
||||
(defproc (error-bars
|
||||
[bars (listof (vector/c real? real? real?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (error-bar-color)]
|
||||
[#:line-width line-width (>=/c 0) (error-bar-line-width)]
|
||||
[#:line-style line-style plot-pen-style/c (error-bar-line-style)]
|
||||
[#:width width (>=/c 0) (error-bar-width)]
|
||||
[#:alpha alpha (real-in 0 1) (error-bar-alpha)]
|
||||
) renderer2d?
|
||||
(let ([bars (filter vregular? bars)])
|
||||
(let ([bars (filter vrational? bars)])
|
||||
(cond [(empty? bars) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector xs ys hs) ...) bars)
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
(defproc (rectangles
|
||||
[rects (listof (vector/c ivl? ivl?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f] [#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (rectangle-color)]
|
||||
[#:style style plot-brush-style/c (rectangle-style)]
|
||||
[#:line-color line-color plot-color/c (rectangle-line-color)]
|
||||
|
@ -36,8 +36,8 @@
|
|||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(match-define (list (vector (ivl x1s x2s) (ivl y1s y2s)) ...) rects)
|
||||
(define rxs (filter regular-real? (append x1s x2s)))
|
||||
(define rys (filter regular-real? (append y1s y2s)))
|
||||
(define rxs (filter rational? (append x1s x2s)))
|
||||
(define rys (filter rational? (append y1s y2s)))
|
||||
(cond
|
||||
[(or (empty? rxs) (empty? rys)) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
|
@ -55,8 +55,8 @@
|
|||
(defproc (area-histogram
|
||||
[f (real? . -> . real?)]
|
||||
[bin-bounds (listof real?)]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (rectangle-color)]
|
||||
[#:style style plot-brush-style/c (rectangle-style)]
|
||||
|
@ -66,7 +66,7 @@
|
|||
[#:alpha alpha (real-in 0 1) (rectangle-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer2d?
|
||||
(let* ([bin-bounds (filter regular-real? bin-bounds)]
|
||||
(let* ([bin-bounds (filter rational? bin-bounds)]
|
||||
[bin-bounds (sort bin-bounds <)])
|
||||
(cond
|
||||
[((length bin-bounds) . < . 2) (renderer2d #f #f #f #f)]
|
||||
|
@ -106,8 +106,8 @@
|
|||
|
||||
(defproc (discrete-histogram
|
||||
[cat-vals (listof (vector/c any/c (or/c real? ivl? #f)))]
|
||||
[#:x-min x-min (or/c regular-real? #f) 0] [#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:gap gap (real-in 0 1) (discrete-histogram-gap)]
|
||||
[#:skip skip (>=/c 0) (discrete-histogram-skip)]
|
||||
[#:invert? invert? boolean? (discrete-histogram-invert?)]
|
||||
|
@ -121,10 +121,10 @@
|
|||
[#:far-ticks? far-ticks? boolean? #f]
|
||||
) renderer2d?
|
||||
(match-define (list (vector cats ys) ...) cat-vals)
|
||||
(define rys (filter regular-real? (append* (for/list ([y (in-list ys)])
|
||||
(match y
|
||||
[(ivl y1 y2) (list y1 y2)]
|
||||
[_ (list y)])))))
|
||||
(define rys (filter rational? (append* (for/list ([y (in-list ys)])
|
||||
(match y
|
||||
[(ivl y1 y2) (list y1 y2)]
|
||||
[_ (list y)])))))
|
||||
(cond
|
||||
[(empty? rys) (renderer2d #f #f #f #f)]
|
||||
[else
|
||||
|
@ -148,8 +148,8 @@
|
|||
|
||||
(defproc (stacked-histogram
|
||||
[cat-vals (listof (vector/c any/c (listof real?)))]
|
||||
[#:x-min x-min (or/c regular-real? #f) 0] [#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:gap gap (real-in 0 1) (discrete-histogram-gap)]
|
||||
[#:skip skip (>=/c 0) (discrete-histogram-skip)]
|
||||
[#:invert? invert? boolean? (discrete-histogram-invert?)]
|
||||
|
|
|
@ -35,12 +35,9 @@
|
|||
|
||||
(defproc (isoline3d
|
||||
[f (real? real? . -> . real?)] [z real?]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
|
@ -92,12 +89,9 @@
|
|||
|
||||
(defproc (contours3d
|
||||
[f (real? real? . -> . real?)]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
|
||||
[#:levels levels (or/c 'auto pos/c (listof real?)) (contour-levels)]
|
||||
[#:colors colors (plot-colors/c (listof real?)) (contour-colors)]
|
||||
|
@ -181,12 +175,9 @@
|
|||
|
||||
(defproc (contour-intervals3d
|
||||
[f (real? real? . -> . real?)]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
|
||||
[#:levels levels (or/c 'auto pos/c (listof real?)) (contour-levels)]
|
||||
[#:colors colors (plot-colors/c (listof ivl?)) (contour-interval-colors)]
|
||||
|
|
|
@ -36,13 +36,10 @@
|
|||
label color style line-color line-width line-style)]
|
||||
[else empty]))
|
||||
|
||||
(defproc (isosurface3d [f (real? real? real? . -> . real?)] [d real?]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[z-min (or/c regular-real? #f) #f]
|
||||
[z-max (or/c regular-real? #f) #f]
|
||||
(defproc (isosurface3d [f (real? real? real? . -> . real?)] [d rational?]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[z-min (or/c rational? #f) #f] [z-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
|
||||
[#:color color plot-color/c (surface-color)]
|
||||
[#:style style plot-brush-style/c (surface-style)]
|
||||
|
@ -112,10 +109,10 @@
|
|||
|
||||
(defproc (isosurfaces3d
|
||||
[f (real? real? real? . -> . real?)]
|
||||
[x-min (or/c regular-real? #f) #f] [x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f] [y-max (or/c regular-real? #f) #f]
|
||||
[z-min (or/c regular-real? #f) #f] [z-max (or/c regular-real? #f) #f]
|
||||
[#:d-min d-min (or/c regular-real? #f) #f] [#:d-max d-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[z-min (or/c rational? #f) #f] [z-max (or/c rational? #f) #f]
|
||||
[#:d-min d-min (or/c rational? #f) #f] [#:d-max d-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
|
||||
[#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (isosurface-levels)]
|
||||
[#:colors colors (plot-colors/c (listof real?)) (isosurface-colors)]
|
||||
|
@ -191,9 +188,9 @@
|
|||
|
||||
(defproc (polar3d
|
||||
[f (real? real? . -> . real?)]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f] [#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f] [#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
|
||||
[#:color color plot-color/c (surface-color)]
|
||||
[#:style style plot-brush-style/c (surface-style)]
|
||||
|
@ -206,7 +203,7 @@
|
|||
(define vs (for*/list ([θ (in-list (linear-seq 0.0 2pi (* 4 samples)))]
|
||||
[ρ (in-list (linear-seq (* -1/2 pi) (* 1/2 pi) (* 2 samples)))])
|
||||
(3d-polar->3d-cartesian θ ρ (f θ ρ))))
|
||||
(define rvs (filter vregular? vs))
|
||||
(define rvs (filter vrational? vs))
|
||||
(cond [(empty? rvs) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector rxs rys rzs) ...) rvs)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
(define (lines3d-renderer
|
||||
vs-thnk x-min x-max y-min y-max z-min z-max color width style alpha label)
|
||||
(define rvs (filter vregular? (vs-thnk)))
|
||||
(define rvs (filter vrational? (vs-thnk)))
|
||||
(cond [(empty? rvs) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector rxs rys rzs) ...) rvs)
|
||||
|
@ -34,12 +34,9 @@
|
|||
|
||||
(defproc (lines3d
|
||||
[vs (listof (vector/c real? real? real?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
[#:style style plot-pen-style/c (line-style)]
|
||||
|
@ -50,13 +47,10 @@
|
|||
|
||||
(defproc (parametric3d
|
||||
[f (real? . -> . (vector/c real? real? real?))]
|
||||
[t-min regular-real?] [t-max regular-real?]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[t-min rational?] [t-max rational?]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
|
||||
[#:color color plot-color/c (line-color)]
|
||||
[#:width width (>=/c 0) (line-width)]
|
||||
|
|
|
@ -803,7 +803,7 @@
|
|||
|
||||
(define/public (put-line v1 v2 [c (v* (v+ v1 v2) 1/2)])
|
||||
(let/ec return
|
||||
(unless (and (vregular? v1) (vregular? v2)) (return (void)))
|
||||
(unless (and (vrational? v1) (vrational? v2)) (return (void)))
|
||||
(let-values ([(v1 v2) (if clipping?
|
||||
(clip-line v1 v2 clip-x-min clip-x-max
|
||||
clip-y-min clip-y-max
|
||||
|
@ -820,14 +820,14 @@
|
|||
pen-color pen-width pen-style)))]))))
|
||||
|
||||
(define/public (put-lines vs)
|
||||
(for ([vs (vregular-sublists vs)])
|
||||
(for ([vs (vrational-sublists vs)])
|
||||
(when (not (empty? vs))
|
||||
(for ([v1 (in-list vs)] [v2 (in-list (rest vs))])
|
||||
(put-line v1 v2)))))
|
||||
|
||||
(define (add-polygon lst vs c)
|
||||
(let/ec return
|
||||
(when (or (empty? vs) (not (and (andmap vregular? vs) (vregular? c))))
|
||||
(when (or (empty? vs) (not (and (andmap vrational? vs) (vrational? c))))
|
||||
(return lst))
|
||||
|
||||
(define normal (vnormal (map plot->norm vs)))
|
||||
|
@ -853,7 +853,7 @@
|
|||
(add-shape! (shapes alpha (plot->norm c) lst))))
|
||||
|
||||
(define/public (put-rect r [c (rect-center r)])
|
||||
(when (rect-regular? r)
|
||||
(when (rect-rational? r)
|
||||
(let ([r (rect-meet r bounds-rect)])
|
||||
(match-define (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) r)
|
||||
(match-let ([(vector x-min y-min z-min) (plot->norm (vector x-min y-min z-min))]
|
||||
|
@ -863,19 +863,19 @@
|
|||
pen-color pen-width pen-style brush-color brush-style))))))
|
||||
|
||||
(define/public (put-text str v [anchor 'center] [angle 0])
|
||||
(when (and (vregular? v) (in-bounds? v))
|
||||
(when (and (vrational? v) (in-bounds? v))
|
||||
(add-shape! (text alpha (plot->norm v) anchor angle str
|
||||
font-size font-family text-foreground))))
|
||||
|
||||
(define/public (put-glyphs vs symbol size)
|
||||
(for ([v (in-list vs)])
|
||||
(when (and (vregular? v) (in-bounds? v))
|
||||
(when (and (vrational? v) (in-bounds? v))
|
||||
(add-shape!
|
||||
(glyph alpha (plot->norm v) symbol size
|
||||
pen-color pen-width pen-style brush-color brush-style)))))
|
||||
|
||||
(define/public (put-arrow v1 v2 [c (v* (v+ v1 v2) 1/2)])
|
||||
(when (and (vregular? v1) (vregular? v2) (in-bounds? v1))
|
||||
(when (and (vrational? v1) (vrational? v2) (in-bounds? v1))
|
||||
(cond [(in-bounds? v2)
|
||||
(add-shape!
|
||||
(arrow-glyph alpha (plot->norm c) (plot->norm v1) (plot->norm v2)
|
||||
|
@ -886,7 +886,7 @@
|
|||
[else (put-line v1 v2)])))
|
||||
|
||||
(define/public (put-tick v radius angle)
|
||||
(when (and (vregular? v) (in-bounds? v))
|
||||
(when (and (vrational? v) (in-bounds? v))
|
||||
(add-shape! (tick-glyph alpha (plot->norm v) radius angle
|
||||
pen-color pen-width pen-style))))
|
||||
)) ; end class
|
||||
|
|
|
@ -30,14 +30,14 @@
|
|||
(define (get-renderer-list renderer-tree)
|
||||
(for/list ([r (flatten (list renderer-tree))])
|
||||
(match r
|
||||
[(non-renderer bounds-rect bounds-fun ticks-fun)
|
||||
[(nonrenderer bounds-rect bounds-fun ticks-fun)
|
||||
(renderer3d bounds-rect bounds-fun ticks-fun #f)]
|
||||
[_ r])))
|
||||
|
||||
(define (get-bounds-rect renderer-list x-min x-max y-min y-max z-min z-max)
|
||||
(define given-bounds-rect (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)))
|
||||
(define plot-bounds-rect (bounds-fixpoint renderer-list given-bounds-rect))
|
||||
(when (or (not (rect-regular? plot-bounds-rect))
|
||||
(when (or (not (rect-rational? plot-bounds-rect))
|
||||
(rect-zero-area? plot-bounds-rect))
|
||||
(match-define (vector x-ivl y-ivl z-ivl) plot-bounds-rect)
|
||||
(error 'plot "could not determine sensible plot bounds; got x ∈ ~a, y ∈ ~a, z ∈ ~a"
|
||||
|
@ -84,15 +84,12 @@
|
|||
(send area end-plot))
|
||||
|
||||
|
||||
(defproc (plot3d/dc [renderer-tree (treeof (or/c renderer3d? non-renderer?))]
|
||||
(defproc (plot3d/dc [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
|
||||
[dc (is-a?/c dc<%>)]
|
||||
[x real?] [y real?] [width (>=/c 0)] [height (>=/c 0)]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:angle angle real? (plot3d-angle)] [#:altitude altitude real? (plot3d-altitude)]
|
||||
[#:title title (or/c string? #f) (plot-title)]
|
||||
[#:x-label x-label (or/c string? #f) (plot-x-label)]
|
||||
|
@ -119,13 +116,10 @@
|
|||
;; Plot to various other backends
|
||||
|
||||
;; Plot to a bitmap
|
||||
(defproc (plot3d-bitmap [renderer-tree (treeof (or/c renderer3d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot3d-bitmap [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:angle angle real? (plot3d-angle)]
|
||||
|
@ -144,13 +138,10 @@
|
|||
#:z-label z-label #:legend-anchor legend-anchor))
|
||||
width height))
|
||||
|
||||
(defproc (plot3d-pict [renderer-tree (treeof (or/c renderer3d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot3d-pict [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:angle angle real? (plot3d-angle)]
|
||||
|
@ -171,13 +162,10 @@
|
|||
width height))
|
||||
|
||||
;; Plot to a snip
|
||||
(defproc (plot3d-snip [renderer-tree (treeof (or/c renderer3d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot3d-snip [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:angle angle real? (plot3d-angle)]
|
||||
|
@ -238,13 +226,10 @@
|
|||
angle altitude saved-plot-parameters)))
|
||||
|
||||
;; Plot to a frame
|
||||
(defproc (plot3d-frame [renderer-tree (treeof (or/c renderer3d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot3d-frame [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:angle angle real? (plot3d-angle)]
|
||||
|
@ -264,15 +249,12 @@
|
|||
(make-snip-frame snip width height (if title (format "Plot: ~a" title) "Plot")))
|
||||
|
||||
;; Plot to any supported kind of file
|
||||
(defproc (plot3d-file [renderer-tree (treeof (or/c renderer3d? non-renderer?))]
|
||||
(defproc (plot3d-file [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
|
||||
[output (or/c path-string? output-port?)]
|
||||
[kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:angle angle real? (plot3d-angle)]
|
||||
|
@ -316,13 +298,10 @@
|
|||
(void))
|
||||
|
||||
;; Plot to a frame or a snip, depending on the value of plot-new-window?
|
||||
(defproc (plot3d [renderer-tree (treeof (or/c renderer3d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
(defproc (plot3d [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:angle angle real? #f] [#:altitude altitude real? #f]
|
||||
|
@ -334,8 +313,7 @@
|
|||
[#:legend-anchor legend-anchor anchor/c (plot-legend-anchor)]
|
||||
[#:out-file out-file (or/c path-string? output-port? #f) #f]
|
||||
[#:out-kind out-kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
|
||||
[#:fgcolor fgcolor plot-color/c #f]
|
||||
[#:bgcolor bgcolor plot-color/c #f]
|
||||
[#:fgcolor fgcolor plot-color/c #f] [#:bgcolor bgcolor plot-color/c #f]
|
||||
[#:lncolor lncolor plot-color/c #f] ; unused
|
||||
) (or/c (is-a?/c snip%) void?)
|
||||
(when fgcolor
|
||||
|
|
|
@ -18,12 +18,9 @@
|
|||
|
||||
(defproc (points3d
|
||||
[vs (listof (vector/c real? real? real?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:sym sym point-sym/c (point-sym)]
|
||||
[#:color color plot-color/c (point-color)]
|
||||
[#:size size (>=/c 0) (point-size)]
|
||||
|
@ -31,7 +28,7 @@
|
|||
[#:alpha alpha (real-in 0 1) (point-alpha)]
|
||||
[#:label label (or/c string? #f) #f]
|
||||
) renderer3d?
|
||||
(let ([vs (filter vregular? vs)])
|
||||
(let ([vs (filter vrational? vs)])
|
||||
(cond [(empty? vs) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
(match-define (list (vector xs ys zs) ...) vs)
|
||||
|
@ -59,7 +56,7 @@
|
|||
(for*/lists (vs dxs dys dzs norms mags) ([x (in-list xs0)]
|
||||
[y (in-list ys0)]
|
||||
[z (in-list zs0)]
|
||||
[dv (in-value (f x y z))] #:when (vregular? dv))
|
||||
[dv (in-value (f x y z))] #:when (vrational? dv))
|
||||
(match-define (vector dx dy dz) dv)
|
||||
(values (vector x y z) dx dy dz (vnormalize dv) (vmag dv))))
|
||||
|
||||
|
@ -94,12 +91,9 @@
|
|||
(defproc (vector-field3d
|
||||
[f (or/c (real? real? real? . -> . (vector/c real? real? real?))
|
||||
((vector/c real? real? real?) . -> . (vector/c real? real? real?)))]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[z-min (or/c regular-real? #f) #f]
|
||||
[z-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[z-min (or/c rational? #f) #f] [z-max (or/c rational? #f) #f]
|
||||
[#:samples samples exact-positive-integer? ( vector-field3d-samples)]
|
||||
[#:scale scale (or/c real? (one-of/c 'auto 'normalized)) (vector-field-scale)]
|
||||
[#:color color plot-color/c (vector-field-color)]
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
(defproc (rectangles3d
|
||||
[rects (listof (vector/c ivl? ivl? ivl?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f] [#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f] [#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:color color plot-color/c (rectangle-color)]
|
||||
[#:style style plot-brush-style/c (rectangle-style)]
|
||||
[#:line-color line-color plot-color/c (rectangle-line-color)]
|
||||
|
@ -37,9 +37,9 @@
|
|||
[#:label label (or/c string? #f) #f]
|
||||
) renderer3d?
|
||||
(match-define (list (vector (ivl x1s x2s) (ivl y1s y2s) (ivl z1s z2s)) ...) rects)
|
||||
(define rxs (filter regular-real? (append x1s x2s)))
|
||||
(define rys (filter regular-real? (append y1s y2s)))
|
||||
(define rzs (filter regular-real? (append z1s z2s)))
|
||||
(define rxs (filter rational? (append x1s x2s)))
|
||||
(define rys (filter rational? (append y1s y2s)))
|
||||
(define rzs (filter rational? (append z1s z2s)))
|
||||
(cond
|
||||
[(or (empty? rxs) (empty? rys) (empty? rzs)) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
|
@ -78,9 +78,9 @@
|
|||
|
||||
(defproc (discrete-histogram3d
|
||||
[cat-vals (listof (vector/c any/c any/c (or/c real? ivl? #f)))]
|
||||
[#:x-min x-min (or/c regular-real? #f) 0] [#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) 0] [#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) 0] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:gap gap (real-in 0 1) (discrete-histogram-gap)]
|
||||
[#:color color plot-color/c (rectangle-color)]
|
||||
[#:style style plot-brush-style/c (rectangle-style)]
|
||||
|
@ -93,10 +93,10 @@
|
|||
[#:y-far-ticks? y-far-ticks? boolean? #f]
|
||||
) renderer3d?
|
||||
(match-define (list (vector cat1s cat2s zs) ...) cat-vals)
|
||||
(define rzs (filter regular-real? (append* (for/list ([z (in-list zs)])
|
||||
(match z
|
||||
[(ivl z1 z2) (list z1 z2)]
|
||||
[_ (list z)])))))
|
||||
(define rzs (filter rational? (append* (for/list ([z (in-list zs)])
|
||||
(match z
|
||||
[(ivl z1 z2) (list z1 z2)]
|
||||
[_ (list z)])))))
|
||||
(cond
|
||||
[(empty? rzs) (renderer3d #f #f #f #f)]
|
||||
[else
|
||||
|
@ -137,9 +137,9 @@
|
|||
|
||||
(defproc (stacked-histogram3d
|
||||
[cat-vals (listof (vector/c any/c any/c (listof real?)))]
|
||||
[#:x-min x-min (or/c regular-real? #f) 0] [#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) 0] [#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) 0] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) 0] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:gap gap (real-in 0 1) (discrete-histogram-gap)]
|
||||
[#:colors colors (plot-colors/c nat/c) (stacked-histogram-colors)]
|
||||
[#:styles styles (plot-brush-styles/c nat/c) (stacked-histogram-styles)]
|
||||
|
|
|
@ -31,12 +31,9 @@
|
|||
|
||||
(defproc (surface3d
|
||||
[f (real? real? . -> . real?)]
|
||||
[x-min (or/c regular-real? #f) #f]
|
||||
[x-max (or/c regular-real? #f) #f]
|
||||
[y-min (or/c regular-real? #f) #f]
|
||||
[y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
[x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
|
||||
[y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
|
||||
[#:color color plot-color/c (surface-color)]
|
||||
[#:style style plot-brush-style/c (surface-style)]
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
@declare-exporting[plot/utils]
|
||||
|
||||
The following API is provided by @racketmodname[plot/utils].
|
||||
|
||||
@section{Plot Elements}
|
||||
|
||||
@defstruct[plot-element ([bounds-rect (or/c (vectorof ivl?) #f)]
|
||||
|
@ -13,7 +15,7 @@
|
|||
[ticks-fun (or/c ticks-fun/c #f)])]{
|
||||
}
|
||||
|
||||
@defstruct[(non-renderer plot-element) ()]{
|
||||
@defstruct[(nonrenderer plot-element) ()]{
|
||||
Examples: @racket[x-ticks], @racket[y-ticks], @racket[z-ticks], @racket[invisible-rect] and @racket[invisible-rect3d]
|
||||
}
|
||||
|
||||
|
@ -50,6 +52,37 @@ Examples: @racket[x-ticks], @racket[y-ticks], @racket[z-ticks], @racket[invisibl
|
|||
#f)])]{
|
||||
}
|
||||
|
||||
|
||||
@section{Memoized Function Samplers}
|
||||
|
||||
@defstruct[sample ([xs (listof real?)]
|
||||
[ys (listof real?)]
|
||||
[y-min (or/c rational? #f)]
|
||||
[y-max (or/c rational? #f)])]{
|
||||
}
|
||||
|
||||
@defstruct[2d-sample ([xs (listof real?)]
|
||||
[ys (listof real?)]
|
||||
[zss (vectorof (vectorof real?))]
|
||||
[z-min (or/c rational? #f)]
|
||||
[z-max (or/c rational? #f)])]{
|
||||
}
|
||||
|
||||
@defstruct[3d-sample ([xs (listof real?)]
|
||||
[ys (listof real?)]
|
||||
[zs (listof real?)]
|
||||
[dsss (vectorof (vectorof (vectorof real?)))]
|
||||
[d-min (or/c rational? #f)]
|
||||
[d-max (or/c rational? #f)])]{
|
||||
}
|
||||
|
||||
@doc-apply[sampler/c]
|
||||
|
||||
@doc-apply[2d-sampler/c]
|
||||
|
||||
@doc-apply[3d-sampler/c]
|
||||
|
||||
|
||||
@section{Legend Entries}
|
||||
|
||||
@defstruct[legend-entry ([label string?]
|
||||
|
|
21
collects/plot/scribblings/nonrenderer.scrbl
Normal file
21
collects/plot/scribblings/nonrenderer.scrbl
Normal file
|
@ -0,0 +1,21 @@
|
|||
#lang scribble/manual
|
||||
|
||||
@(require "common.rkt")
|
||||
|
||||
@declare-exporting[plot]
|
||||
|
||||
@title[#:tag "nonrenderer"]{Nonrenderers}
|
||||
|
||||
@defproc[(nonrenderer? [value any/c]) boolean?]{
|
||||
}
|
||||
|
||||
@doc-apply[x-ticks]
|
||||
|
||||
@doc-apply[y-ticks]
|
||||
|
||||
@doc-apply[z-ticks]
|
||||
|
||||
@doc-apply[invisible-rect]
|
||||
|
||||
@doc-apply[invisible-rect3d]
|
||||
|
|
@ -31,6 +31,8 @@ If you have code written for PLoT 5.1.3 or earlier, please see @secref["porting"
|
|||
|
||||
@include-section["renderer3d.scrbl"]
|
||||
|
||||
@include-section["nonrenderer.scrbl"]
|
||||
|
||||
@include-section["ticks.scrbl"]
|
||||
|
||||
@include-section["utils.scrbl"]
|
||||
|
|
|
@ -7,11 +7,9 @@
|
|||
|
||||
@title[#:tag "plot2d"]{2D Plot Procedures}
|
||||
|
||||
@defproc[(plot [renderer-tree (treeof (or/c renderer2d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
@defproc[(plot [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:title title (or/c string? #f) (plot-title)]
|
||||
|
@ -52,14 +50,14 @@ The @(racket #:lncolor) keyword argument is also accepted for backward compatibi
|
|||
}
|
||||
|
||||
@deftogether[
|
||||
(@defproc[(plot-file [renderer-tree (treeof (or/c renderer2d? non-renderer?))]
|
||||
(@defproc[(plot-file [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
|
||||
[output (or/c path-string? output-port?)]
|
||||
[kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
|
||||
[#:<plot-keyword> <plot-keyword> <plot-keyword-contract>] ...) void?]
|
||||
@defproc[(plot-pict [renderer-tree (treeof (or/c renderer2d? non-renderer?))] ...) pict?]
|
||||
@defproc[(plot-bitmap [renderer-tree (treeof (or/c renderer2d? non-renderer?))] ...) (is-a?/c bitmap%)]
|
||||
@defproc[(plot-snip [renderer-tree (treeof (or/c renderer2d? non-renderer?))] ...) (is-a?/c image-snip%)]
|
||||
@defproc[(plot-frame [renderer-tree (treeof (or/c renderer2d? non-renderer?))] ...) (is-a?/c frame%)])]{
|
||||
@defproc[(plot-pict [renderer-tree (treeof (or/c renderer2d? nonrenderer?))] ...) pict?]
|
||||
@defproc[(plot-bitmap [renderer-tree (treeof (or/c renderer2d? nonrenderer?))] ...) (is-a?/c bitmap%)]
|
||||
@defproc[(plot-snip [renderer-tree (treeof (or/c renderer2d? nonrenderer?))] ...) (is-a?/c image-snip%)]
|
||||
@defproc[(plot-frame [renderer-tree (treeof (or/c renderer2d? nonrenderer?))] ...) (is-a?/c frame%)])]{
|
||||
Plot to different backends. Each of these procedures has the same keyword arguments as @(racket plot), except for deprecated keywords.
|
||||
|
||||
Use @(racket plot-file) to save a plot to a file.
|
||||
|
|
|
@ -8,13 +8,10 @@
|
|||
|
||||
Each 3D plot procedure corresponds with a @(secref "plot2d") procedure. Each behaves the same way as its corresponding 2D procedure, but takes the additional keyword arguments @(racket #:z-min), @(racket #:z-max), @(racket #:angle), @(racket #:altitude) and @(racket #:z-label).
|
||||
|
||||
@defproc[(plot3d [renderer-tree (treeof (or/c renderer3d? non-renderer?))]
|
||||
[#:x-min x-min (or/c regular-real? #f) #f]
|
||||
[#:x-max x-max (or/c regular-real? #f) #f]
|
||||
[#:y-min y-min (or/c regular-real? #f) #f]
|
||||
[#:y-max y-max (or/c regular-real? #f) #f]
|
||||
[#:z-min z-min (or/c regular-real? #f) #f]
|
||||
[#:z-max z-max (or/c regular-real? #f) #f]
|
||||
@defproc[(plot3d [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
|
||||
[#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
|
||||
[#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
|
||||
[#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #f) #f]
|
||||
[#:width width exact-positive-integer? (plot-width)]
|
||||
[#:height height exact-positive-integer? (plot-height)]
|
||||
[#:angle angle real? (plot3d-angle)]
|
||||
|
@ -43,14 +40,14 @@ The @(racket #:az) and @(racket #:alt) keyword arguments are backward-compatible
|
|||
}
|
||||
|
||||
@deftogether[
|
||||
(@defproc[(plot3d-file [renderer-tree (treeof (or/c renderer3d? non-renderer?))]
|
||||
(@defproc[(plot3d-file [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
|
||||
[output (or/c path-string? output-port?)]
|
||||
[kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
|
||||
[#:<plot-keyword> <plot-keyword> <plot-keyword-contract>] ...) void?]
|
||||
@defproc[(plot3d-pict [renderer-tree (treeof (or/c renderer3d? non-renderer?))] ...) pict?]
|
||||
@defproc[(plot3d-bitmap [renderer-tree (treeof (or/c renderer3d? non-renderer?))] ...) (is-a?/c bitmap%)]
|
||||
@defproc[(plot3d-snip [renderer-tree (treeof (or/c renderer3d? non-renderer?))] ...) (is-a?/c image-snip%)]
|
||||
@defproc[(plot3d-frame [renderer-tree (treeof (or/c renderer3d? non-renderer?))] ...) (is-a?/c frame%)])]{
|
||||
@defproc[(plot3d-pict [renderer-tree (treeof (or/c renderer3d? nonrenderer?))] ...) pict?]
|
||||
@defproc[(plot3d-bitmap [renderer-tree (treeof (or/c renderer3d? nonrenderer?))] ...) (is-a?/c bitmap%)]
|
||||
@defproc[(plot3d-snip [renderer-tree (treeof (or/c renderer3d? nonrenderer?))] ...) (is-a?/c image-snip%)]
|
||||
@defproc[(plot3d-frame [renderer-tree (treeof (or/c renderer3d? nonrenderer?))] ...) (is-a?/c frame%)])]{
|
||||
Plot to different backends. Each of these procedures has the same keyword arguments as @(racket plot3d), except for deprecated keywords.
|
||||
|
||||
These procedures correspond with @(racket plot-file), @(racket plot-pict), @(racket plot-bitmap), @(racket plot-snip) and @(racket plot-frame).
|
||||
|
|
|
@ -137,9 +137,6 @@ Integer brush styles repeat starting at @(racket 7).
|
|||
|
||||
@subsection{Real Numbers}
|
||||
|
||||
@doc-apply[regular-real?]{
|
||||
}
|
||||
|
||||
@doc-apply[degrees->radians]{
|
||||
Converts degrees to radians.
|
||||
}
|
||||
|
@ -185,6 +182,7 @@ This is used to generate samples for transformed axes.
|
|||
|
||||
@subsection[#:tag "math.vectors"]{Vectors}
|
||||
|
||||
|
||||
@subsection[#:tag "math.intervals"]{Intervals}
|
||||
|
||||
@doc-apply[bounds->intervals]{
|
||||
|
@ -196,8 +194,23 @@ Use this to construct inputs for @(racket rectangles) and @(racket rectangles3d)
|
|||
|
||||
@subsection[#:tag "math.rectangles"]{Rectangles}
|
||||
|
||||
|
||||
@section{Dates and Times}
|
||||
|
||||
@doc-apply[datetime->real]{
|
||||
}
|
||||
|
||||
@defstruct[plot-time ([second (and/c (>=/c 0) (</c 60))]
|
||||
[minute (integer-in 0 59)]
|
||||
[hour (integer-in 0 23)]
|
||||
[day exact-integer?])]{
|
||||
}
|
||||
|
||||
@doc-apply[plot-time->seconds]
|
||||
|
||||
@doc-apply[seconds->plot-time]
|
||||
|
||||
|
||||
@section{Sampling}
|
||||
|
||||
@defstruct[mapped-function ([f (any/c . -> . any/c)] [fmap ((listof any/c) . -> . (listof any/c))])]{
|
||||
|
|
|
@ -98,8 +98,8 @@
|
|||
;; ===================================================================================================
|
||||
;; Intervals
|
||||
|
||||
(check-false (ivl-regular? (ivl #f #f)))
|
||||
(check-false (ivl-regular? (ivl +nan.0 +nan.0)))
|
||||
(check-false (ivl-rational? (ivl #f #f)))
|
||||
(check-false (ivl-rational? (ivl +nan.0 +nan.0)))
|
||||
|
||||
(check-true (ivl-empty? (ivl-meet empty-ivl (ivl 0 3))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user