Use rational? instead of regular-real?, cut some cruft

Make docs compile without warnings
This commit is contained in:
Neil Toronto 2011-11-20 23:10:12 -07:00
parent e788c6f49e
commit a23808dd95
34 changed files with 366 additions and 418 deletions

View File

@ -146,10 +146,10 @@
(defproc (ivl->string [i ivl?] [extra-digits exact-integer? 3]) string? (defproc (ivl->string [i ivl?] [extra-digits exact-integer? 3]) string?
(match-define (ivl a b) i) (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))] (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 (rational? 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? b)) (format "[~a,~a]" (real->plot-label a 15) (format-special b))]
[else [else
(define digits (digits-for-range a b extra-digits)) (define digits (digits-for-range a b extra-digits))
(format "[~a,~a]" (format "[~a,~a]"

View File

@ -14,9 +14,6 @@
(defproc (infinite? [x any/c]) boolean? (defproc (infinite? [x any/c]) boolean?
(and (flonum? x) (or (unsafe-fl= x +inf.0) (unsafe-fl= x -inf.0)))) (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? (defproc (flblend [x flonum?] [y flonum?] [α flonum?]) flonum?
(cond [(not (flonum? x)) (raise-type-error 'flblend "flonum" 0 x y α)] (cond [(not (flonum? x)) (raise-type-error 'flblend "flonum" 0 x y α)]
[(not (flonum? y)) (raise-type-error 'flblend "flonum" 1 x y α)] [(not (flonum? y)) (raise-type-error 'flblend "flonum" 1 x y α)]
@ -95,16 +92,13 @@
;; =================================================================================================== ;; ===================================================================================================
;; Reals ;; Reals
(defproc (regular-real? [x any/c]) boolean? (defproc (maybe-inexact->exact [x (or/c rational? #f)]) (or/c rational? #f)
(and (real? x) (not (special-real? x)))) (cond [x (unless (rational? x)
(raise-type-error 'maybe-inexact->exact "rational or #f" 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))
(inexact->exact x)] (inexact->exact x)]
[else #f])) [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? [size exact-positive-integer?]) boolean?
(let/ec return (let/ec return
(let ([x-min (inexact->exact (min x-min x-max))] (let ([x-min (inexact->exact (min x-min x-max))]
@ -112,16 +106,16 @@
(define step-size (/ (- x-max x-min) size)) (define step-size (/ (- x-max x-min) size))
(define inexact-x-min (exact->inexact x-min)) (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)) (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)) (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)) (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 max-diff (- x-max (inexact->exact inexact-x-max-prev)))
(define min-diff (- (inexact->exact inexact-x-min-next) x-min)) (define min-diff (- (inexact->exact inexact-x-min-next) x-min))
@ -423,27 +417,12 @@
(cond [(= d 0) 0] (cond [(= d 0) 0]
[else (/ d (vmag v1) (vmag v2))])) [else (/ d (vmag v1) (vmag v2))]))
(define-syntax-rule (unsafe-flspecial? x) (defproc (vrational? [v (vectorof real?)]) boolean?
(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?
(match v (match v
[(vector (? real? x) (? real? y)) [(vector (? rational? x) (? rational? y)) #t]
(not (or (and (flonum? x) (unsafe-flspecial? x)) [(vector (? rational? x) (? rational? y) (? rational? z)) #t]
(and (flonum? y) (unsafe-flspecial? y))))] [(? vector?) (vector-andmap rational? v)]
[(vector (? real? x) (? real? y) (? real? z)) [_ (raise-type-error 'vrational? "vector" v)]))
(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)])]))
(defproc (v= [v1 (vectorof real?)] [v2 (vectorof real?)]) boolean? (defproc (v= [v1 (vectorof real?)] [v2 (vectorof real?)]) boolean?
(match v1 (match v1
@ -488,12 +467,12 @@
(define maxs (vector-map (λ (xs) (apply max xs)) xss)) (define maxs (vector-map (λ (xs) (apply max xs)) xss))
(unrolled-vmap2 'vcenter (λ (x1 x2) (* 1/2 (+ x1 x2))) mins maxs)])) (unrolled-vmap2 'vcenter (λ (x1 x2) (* 1/2 (+ x1 x2))) mins maxs)]))
(define (vregular-sublists vs) (define (vrational-sublists vs)
(define res (define res
(let loop ([vs vs]) (let loop ([vs vs])
(cond [(null? vs) (list null)] (cond [(null? vs) (list null)]
[(vregular? (car vs)) (define rst (loop (cdr vs))) [(vrational? (car vs)) (define rst (loop (cdr vs)))
(cons (cons (car vs) (car rst)) (cdr rst))] (cons (cons (car vs) (car rst)) (cdr rst))]
[else (cons null (loop (cdr vs)))]))) [else (cons null (loop (cdr vs)))])))
(cond [(and (not (null? res)) (null? (car res))) (cdr res)] (cond [(and (not (null? res)) (null? (car res))) (cdr res)]
[else res])) [else res]))
@ -554,12 +533,12 @@
(match-define (ivl a b) i) (match-define (ivl a b) i)
(and a b #t)) (and a b #t))
(defproc (ivl-regular? [i ivl?]) boolean? (defproc (ivl-rational? [i ivl?]) boolean?
(match-define (ivl a b) i) (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? (defproc (rational-ivl? [i any/c]) boolean?
(and (ivl? i) (ivl-regular? i))) (and (ivl? i) (ivl-rational? i)))
(defproc (ivl-singular? [i ivl?]) boolean? (defproc (ivl-singular? [i ivl?]) boolean?
(match-define (ivl a b) i) (match-define (ivl a b) i)
@ -638,8 +617,11 @@
(defproc (rect-known? [r (vectorof ivl?)]) boolean? (defproc (rect-known? [r (vectorof ivl?)]) boolean?
(vector-andmap ivl-known? r)) (vector-andmap ivl-known? r))
(defproc (rect-regular? [r (vectorof ivl?)]) boolean? (defproc (rect-rational? [r (vectorof ivl?)]) boolean?
(vector-andmap ivl-regular? r)) (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) (defproc (rect-area [r (vectorof ivl?)]) (or/c real? #f)
(let/ec break (let/ec break

View File

@ -26,22 +26,22 @@
(cond [(= (vector-length r) 3) (values empty empty empty empty ts far-ts)] (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)]))) [else (raise-type-error 'z-ticks-fun "3-vector of ivls" r)])))
(defproc (x-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) non-renderer? (defproc (x-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) nonrenderer?
(non-renderer #f #f (x-ticks-fun ts far?))) (nonrenderer #f #f (x-ticks-fun ts far?)))
(defproc (y-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) non-renderer? (defproc (y-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) nonrenderer?
(non-renderer #f #f (y-ticks-fun ts far?))) (nonrenderer #f #f (y-ticks-fun ts far?)))
(defproc (z-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) non-renderer? (defproc (z-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) nonrenderer?
(non-renderer #f #f (z-ticks-fun ts far?))) (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)] (defproc (invisible-rect [x-min (or/c rational? #f)] [x-max (or/c rational? #f)]
[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)]
) non-renderer? ) nonrenderer?
(non-renderer (vector (ivl x-min x-max) (ivl y-min y-max)) #f #f)) (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)] (defproc (invisible-rect3d [x-min (or/c rational? #f)] [x-max (or/c rational? #f)]
[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)]
[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)]
) non-renderer? ) nonrenderer?
(non-renderer (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f #f)) (nonrenderer (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f #f))

View File

@ -254,12 +254,12 @@
(send dc set-alpha old-alpha)) (send dc set-alpha old-alpha))
(define/public (draw-point v) (define/public (draw-point v)
(when (vregular? v) (when (vrational? v)
(match-define (vector x y) v) (match-define (vector x y) v)
(send dc draw-point x y))) (send dc draw-point x y)))
(define/public (draw-polygon vs) (define/public (draw-polygon vs)
(when (andmap vregular? vs) (when (andmap vrational? vs)
(let ([vs (map coord->cons vs)]) (let ([vs (map coord->cons vs)])
(cond [(eq? pen-style 'transparent) (cond [(eq? pen-style 'transparent)
(send dc set-smoothing 'unsmoothed) (send dc set-smoothing 'unsmoothed)
@ -275,22 +275,22 @@
(draw-lines/pen-style dc (cons (last vs) vs) pen-style)])))) (draw-lines/pen-style dc (cons (last vs) vs) pen-style)]))))
(define/public (draw-rect r) (define/public (draw-rect r)
(when (rect-regular? r) (when (rect-rational? r)
(match-define (vector (ivl x1 x2) (ivl y1 y2)) 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))))) (draw-polygon (list (vector x1 y1) (vector x1 y2) (vector x2 y2) (vector x2 y1)))))
(define/public (draw-lines vs) (define/public (draw-lines vs)
(when (andmap vregular? vs) (when (andmap vrational? vs)
(draw-lines/pen-style dc (map coord->cons vs) pen-style))) (draw-lines/pen-style dc (map coord->cons vs) pen-style)))
(define/public (draw-line v1 v2) (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 x1 y1) v1)
(match-define (vector x2 y2) v2) (match-define (vector x2 y2) v2)
(draw-line/pen-style dc x1 y1 x2 y2 pen-style))) (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]) (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) (match-define (vector x y) v)
(when outline? (when outline?
@ -309,14 +309,14 @@
(draw-text/anchor dc str x y anchor #t 0 angle))) (draw-text/anchor dc str x y anchor #t 0 angle)))
(define/public (get-text-corners str v [anchor 'top-left] [angle 0]) (define/public (get-text-corners str v [anchor 'top-left] [angle 0])
(cond [(vregular? v) (cond [(vrational? v)
(match-define (vector x y) v) (match-define (vector x y) v)
(map (λ (v) (vector-map inexact->exact v)) (map (λ (v) (vector-map inexact->exact v))
(get-text-corners/anchor dc str x y anchor #t 0 angle))] (get-text-corners/anchor dc str x y anchor #t 0 angle))]
[else empty])) [else empty]))
(define/public (draw-arrow v1 v2) (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 x1 y1) v1)
(match-define (vector x2 y2) v2) (match-define (vector x2 y2) v2)
(define dx (- x2 x1)) (define dx (- x2 x1))
@ -337,14 +337,14 @@
;; Glyph (point sym) primitives ;; Glyph (point sym) primitives
(define/public ((make-draw-circle-glyph r) v) (define/public ((make-draw-circle-glyph r) v)
(when (vregular? v) (when (vrational? v)
(match-define (vector x y) v) (match-define (vector x y) v)
(send dc draw-ellipse (- x r -1/2) (- y r -1/2) (* 2 r) (* 2 r)))) (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/public (make-draw-polygon-glyph r sides start-angle)
(define angles (linear-seq start-angle (+ start-angle (* 2 pi)) (+ 1 sides))) (define angles (linear-seq start-angle (+ start-angle (* 2 pi)) (+ 1 sides)))
(λ (v) (λ (v)
(when (vregular? v) (when (vrational? v)
(match-define (vector x y) v) (match-define (vector x y) v)
(send dc draw-polygon (map (λ (a) (cons (+ x (* (cos a) r)) (+ y (* (sin a) r)))) (send dc draw-polygon (map (λ (a) (cons (+ x (* (cos a) r)) (+ y (* (sin a) r))))
angles))))) angles)))))
@ -352,7 +352,7 @@
(define/public (make-draw-star-glyph r sides start-angle) (define/public (make-draw-star-glyph r sides start-angle)
(define angles (linear-seq start-angle (+ start-angle (* 2 pi)) (+ 1 (* 2 sides)))) (define angles (linear-seq start-angle (+ start-angle (* 2 pi)) (+ 1 (* 2 sides))))
(λ (v) (λ (v)
(when (vregular? v) (when (vrational? v)
(match-define (vector x y) v) (match-define (vector x y) v)
(define pts (define pts
(for/list ([a (in-list angles)] [i (in-naturals)]) (for/list ([a (in-list angles)] [i (in-naturals)])
@ -366,7 +366,7 @@
(define step (/ (* 2 pi) sticks)) (define step (/ (* 2 pi) sticks))
(define angles (build-list sticks (λ (n) (+ start-angle (* n step))))) (define angles (build-list sticks (λ (n) (+ start-angle (* n step)))))
(λ (v) (λ (v)
(when (vregular? v) (when (vrational? v)
(match-define (vector x y) v) (match-define (vector x y) v)
(for ([a (in-list angles)]) (for ([a (in-list angles)])
(send dc draw-line x y (+ x (* (cos a) r)) (+ y (* (sin a) r))))))) (send dc draw-line x y (+ x (* (cos a) r)) (+ y (* (sin a) r)))))))
@ -381,7 +381,7 @@
(define dx (* (cos angle) r)) (define dx (* (cos angle) r))
(define dy (* (sin angle) r)) (define dy (* (sin angle) r))
(λ (v) (λ (v)
(when (vregular? v) (when (vrational? v)
(match-define (vector x y) v) (match-define (vector x y) v)
(send dc draw-line (- x dx) (- y dy) (+ x dx) (+ y dy))))) (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 dx2 (* (cos (- angle head-angle)) head-r))
(define dy2 (* (sin (- angle head-angle)) head-r)) (define dy2 (* (sin (- angle head-angle)) head-r))
(λ (v) (λ (v)
(when (vregular? v) (when (vrational? v)
(match-define (vector x y) v) (match-define (vector x y) v)
(define head-x (+ x dx)) (define head-x (+ x dx))
(define head-y (+ y dy)) (define head-y (+ y dy))
@ -416,7 +416,7 @@
(define dx (* 1/2 x-size)) (define dx (* 1/2 x-size))
(define dy (* 1/2 y-size)) (define dy (* 1/2 y-size))
(λ (v) (λ (v)
(when (vregular? v) (when (vrational? v)
(match-define (vector x y) v) (match-define (vector x y) v)
(send dc draw-text str (- x dx) (- y dy) #t)))) (send dc draw-text str (- x dx) (- y dy) #t))))

View File

@ -11,7 +11,7 @@
(provide (all-defined-out)) (provide (all-defined-out))
(struct plot-element (bounds-rect bounds-fun ticks-fun) #:transparent) (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 renderer2d plot-element (render-proc) #:transparent)
(struct renderer3d plot-element (render-proc) #:transparent) (struct renderer3d plot-element (render-proc) #:transparent)

View File

@ -96,7 +96,7 @@
(λ () (λ ()
(define xs (nonlinear-seq x-min x-max x-samples tx)) (define xs (nonlinear-seq x-min x-max x-samples tx))
(define ys (map* f xs)) (define ys (map* f xs))
(define rys (filter regular-real? ys)) (define rys (filter rational? ys))
(define-values (y-min y-max) (define-values (y-min y-max)
(cond [(empty? rys) (values #f #f)] (cond [(empty? rys) (values #f #f)]
[else (values (apply min* rys) (apply max* rys))])) [else (values (apply min* rys) (apply max* rys))]))
@ -121,7 +121,7 @@
(define zss (for/vector #:length y-samples ([y (in-list ys)]) (define zss (for/vector #:length y-samples ([y (in-list ys)])
(for/vector #:length x-samples ([x (in-list xs)]) (for/vector #:length x-samples ([x (in-list xs)])
(let ([z (f x y)]) (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-min (z . >= . z-min)) (set! z-min z))
(unless (and z-max (z . <= . z-max)) (set! z-max z))) (unless (and z-max (z . <= . z-max)) (set! z-max z)))
z)))) z))))
@ -152,7 +152,7 @@
(for/vector #:length y-samples ([y (in-list ys)]) (for/vector #:length y-samples ([y (in-list ys)])
(for/vector #:length x-samples ([x (in-list xs)]) (for/vector #:length x-samples ([x (in-list xs)])
(let ([d (f x y z)]) (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-min (d . >= . d-min)) (set! d-min d))
(unless (and d-max (d . <= . d-max)) (set! d-max d))) (unless (and d-max (d . <= . d-max)) (set! d-max d)))
d))))) d)))))
@ -227,22 +227,22 @@
(exact->inexact d)))) (exact->inexact d))))
d-min d-max)) d-min d-max))
(defproc (flonum-ok-for-2d? [x-min regular-real?] [x-max regular-real?] (defproc (flonum-ok-for-2d? [x-min rational?] [x-max rational?]
[y-min regular-real?] [y-max regular-real?]) boolean? [y-min rational?] [y-max rational?]) boolean?
(and (flonum-ok-for-range? x-min x-max 10000) (and (flonum-ok-for-range? x-min x-max 10000)
(flonum-ok-for-range? y-min y-max 10000))) (flonum-ok-for-range? y-min y-max 10000)))
(defproc (flonum-ok-for-3d? [x-min regular-real?] [x-max regular-real?] (defproc (flonum-ok-for-3d? [x-min rational?] [x-max rational?]
[y-min regular-real?] [y-max regular-real?] [y-min rational?] [y-max rational?]
[z-min regular-real?] [z-max regular-real?]) boolean? [z-min rational?] [z-max rational?]) boolean?
(and (flonum-ok-for-range? x-min x-max 10000) (and (flonum-ok-for-range? x-min x-max 10000)
(flonum-ok-for-range? y-min y-max 10000) (flonum-ok-for-range? y-min y-max 10000)
(flonum-ok-for-range? z-min z-max 10000))) (flonum-ok-for-range? z-min z-max 10000)))
(defproc (flonum-ok-for-4d? [x-min regular-real?] [x-max regular-real?] (defproc (flonum-ok-for-4d? [x-min rational?] [x-max rational?]
[y-min regular-real?] [y-max regular-real?] [y-min rational?] [y-max rational?]
[z-min regular-real?] [z-max regular-real?] [z-min rational?] [z-max rational?]
[d-min regular-real?] [d-max regular-real?]) boolean? [d-min rational?] [d-max rational?]) boolean?
(and (flonum-ok-for-range? x-min x-max 10000) (and (flonum-ok-for-range? x-min x-max 10000)
(flonum-ok-for-range? y-min y-max 10000) (flonum-ok-for-range? y-min y-max 10000)
(flonum-ok-for-range? z-min z-max 10000) (flonum-ok-for-range? z-min z-max 10000)

View File

@ -5,32 +5,32 @@
(require "../common/math.rkt") (require "../common/math.rkt")
(provide equal?* (provide equal?*
;; Flonums ;; Flonums
nan? infinite? special-real? nan? infinite?
flblend flatan2 flsum flmodulo fldistance flblend flatan2 flsum flmodulo fldistance
(activate-contract-out flonum->ordinal ordinal->flonum flstep flnext flprev (activate-contract-out flonum->ordinal ordinal->flonum flstep flnext flprev
flonum-ok-for-range?) flonum-ok-for-range?)
-max.0 -min.0 +min.0 +max.0 -max.0 -min.0 +min.0 +max.0
;; Reals ;; Reals
regular-real? maybe-inexact->exact maybe-inexact->exact
min* max* degrees->radians radians->degrees blend atan2 sum real-modulo distance min* max* degrees->radians radians->degrees blend atan2 sum real-modulo distance
floor-log/base ceiling-log/base floor-log/base ceiling-log/base
polar->cartesian 3d-polar->3d-cartesian polar->cartesian 3d-polar->3d-cartesian
;; Vectors ;; 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 ;; Intervals
(provide (contract-out (struct ivl ([min (or/c real? #f)] [max (or/c real? #f)])) (provide (contract-out (struct ivl ([min (or/c real? #f)] [max (or/c real? #f)]))
[ivl-meet (->* () () #:rest (listof ivl?) ivl?)] [ivl-meet (->* () () #:rest (listof ivl?) ivl?)]
[ivl-join (->* () () #: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 (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)) ivl-inexact->exact ivl-contains? bounds->intervals))
;; Rectangles ;; Rectangles
(provide (contract-out [rect-meet (->* () () #:rest (listof (vectorof ivl?)) (vectorof ivl?))] (provide (contract-out [rect-meet (->* () () #:rest (listof (vectorof ivl?)) (vectorof ivl?))]
[rect-join (->* () () #:rest (listof (vectorof ivl?)) (vectorof ivl?))]) [rect-join (->* () () #:rest (listof (vectorof ivl?)) (vectorof ivl?))])
(activate-contract-out (activate-contract-out
empty-rect unknown-rect bounding-rect empty-rect unknown-rect bounding-rect rational-rect?
rect-empty? rect-known? rect-regular? rect-area rect-center rect-zero-area? rect-singular? rect-empty? rect-known? rect-rational? rect-area rect-center rect-zero-area? rect-singular?
rect-inexact->exact rect-contains?)) rect-inexact->exact rect-contains?))

View File

@ -15,7 +15,7 @@
([bounds-rect (or/c (vectorof ivl?) #f)] ([bounds-rect (or/c (vectorof ivl?) #f)]
[bounds-fun (or/c bounds-fun/c #f)] [bounds-fun (or/c bounds-fun/c #f)]
[ticks-fun (or/c ticks-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-rect (or/c (vectorof ivl?) #f)]
[bounds-fun (or/c bounds-fun/c #f)] [bounds-fun (or/c bounds-fun/c #f)]
[ticks-fun (or/c ticks-fun/c #f)])) [ticks-fun (or/c ticks-fun/c #f)]))

View File

@ -6,19 +6,19 @@
"../common/math.rkt") "../common/math.rkt")
(provide (contract-out (struct sample ([xs (listof real?)] (provide (contract-out (struct sample ([xs (listof real?)]
[ys (listof real?)] [ys (listof real?)]
[y-min (or/c regular-real? #f)] [y-min (or/c rational? #f)]
[y-max (or/c regular-real? #f)])) [y-max (or/c rational? #f)]))
(struct 2d-sample ([xs (listof real?)] (struct 2d-sample ([xs (listof real?)]
[ys (listof real?)] [ys (listof real?)]
[zss (vectorof (vectorof real?))] [zss (vectorof (vectorof real?))]
[z-min (or/c regular-real? #f)] [z-min (or/c rational? #f)]
[z-max (or/c regular-real? #f)])) [z-max (or/c rational? #f)]))
(struct 3d-sample ([xs (listof real?)] (struct 3d-sample ([xs (listof real?)]
[ys (listof real?)] [ys (listof real?)]
[zs (listof real?)] [zs (listof real?)]
[dsss (vectorof (vectorof (vectorof real?)))] [dsss (vectorof (vectorof (vectorof real?)))]
[d-min (or/c regular-real? #f)] [d-min (or/c rational? #f)]
[d-max (or/c regular-real? #f)]))) [d-max (or/c rational? #f)])))
(activate-contract-out build-linear-seq linear-seq linear-seq* nonlinear-seq (activate-contract-out build-linear-seq linear-seq linear-seq* nonlinear-seq
sampler/c 2d-sampler/c 3d-sampler/c sampler/c 2d-sampler/c 3d-sampler/c
make-function->sampler make-function->sampler

View File

@ -11,7 +11,7 @@
"common/ticks.rkt" "common/ticks.rkt"
"common/math.rkt" "common/math.rkt"
"common/plot-element.rkt" "common/plot-element.rkt"
"common/non-renderer.rkt" "common/nonrenderer.rkt"
"common/format.rkt" "common/format.rkt"
"common/sample.rkt" "common/sample.rkt"
"common/draw.rkt" "common/draw.rkt"
@ -27,7 +27,7 @@
(all-from-out "common/ticks.rkt") (all-from-out "common/ticks.rkt")
(all-from-out "common/math.rkt") (all-from-out "common/math.rkt")
(all-from-out "common/plot-element.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/format.rkt")
(all-from-out "common/sample.rkt") (all-from-out "common/sample.rkt")
(all-from-out "common/draw.rkt") (all-from-out "common/draw.rkt")

View File

@ -22,7 +22,7 @@
plot-time->seconds seconds->plot-time plot-time->seconds seconds->plot-time
datetime->real) 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)) (provide (activate-contract-out x-ticks y-ticks z-ticks invisible-rect invisible-rect3d))
;; =================================================================================================== ;; ===================================================================================================

View File

@ -34,10 +34,8 @@
(defproc (isoline (defproc (isoline
[f (real? real? . -> . real?)] [z real?] [f (real? real? . -> . real?)] [z real?]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f]
[y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]
@ -85,10 +83,8 @@
(defproc (contours (defproc (contours
[f (real? real? . -> . real?)] [f (real? real? . -> . real?)]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f]
[y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)]
[#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)] [#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)]
[#:colors colors (plot-colors/c (listof real?)) (contour-colors)] [#:colors colors (plot-colors/c (listof real?)) (contour-colors)]
@ -161,10 +157,8 @@
(defproc (contour-intervals (defproc (contour-intervals
[f (real? real? . -> . real?)] [f (real? real? . -> . real?)]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f]
[y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)]
[#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)] [#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)]
[#:colors colors (plot-colors/c (listof ivl?)) (contour-interval-colors)] [#:colors colors (plot-colors/c (listof ivl?)) (contour-interval-colors)]

View File

@ -35,10 +35,8 @@
(defproc (lines-interval (defproc (lines-interval
[v1s (listof (vector/c real? real?))] [v1s (listof (vector/c real? real?))]
[v2s (listof (vector/c real? real?))] [v2s (listof (vector/c real? real?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:color color plot-color/c (interval-color)] [#:color color plot-color/c (interval-color)]
[#:style style plot-brush-style/c (interval-style)] [#:style style plot-brush-style/c (interval-style)]
[#:line1-color line1-color plot-color/c (interval-line1-color)] [#:line1-color line1-color plot-color/c (interval-line1-color)]
@ -50,7 +48,7 @@
[#:alpha alpha (real-in 0 1) (interval-alpha)] [#:alpha alpha (real-in 0 1) (interval-alpha)]
[#:label label (or/c string? #f) #f] [#:label label (or/c string? #f) #f]
) renderer2d? ) renderer2d?
(define rvs (filter vregular? (append v1s v2s))) (define rvs (filter vrational? (append v1s v2s)))
(cond (cond
[(empty? rvs) (renderer2d #f #f #f #f)] [(empty? rvs) (renderer2d #f #f #f #f)]
[else [else
@ -68,11 +66,9 @@
(defproc (parametric-interval (defproc (parametric-interval
[f1 (real? . -> . (vector/c real? real?))] [f1 (real? . -> . (vector/c real? real?))]
[f2 (real? . -> . (vector/c real? real?))] [f2 (real? . -> . (vector/c real? real?))]
[t-min real?] [t-max real?] [t-min rational?] [t-max rational?]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (interval-color)] [#:color color plot-color/c (interval-color)]
[#:style style plot-brush-style/c (interval-style)] [#:style style plot-brush-style/c (interval-style)]
@ -96,11 +92,9 @@
(defproc (polar-interval (defproc (polar-interval
[f1 (real? . -> . real?)] [f2 (real? . -> . real?)] [f1 (real? . -> . real?)] [f2 (real? . -> . real?)]
[θ-min real? 0] [θ-max real? (* 2 pi)] [θ-min rational? 0] [θ-max rational? (* 2 pi)]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (interval-color)] [#:color color plot-color/c (interval-color)]
[#:style style plot-brush-style/c (interval-style)] [#:style style plot-brush-style/c (interval-style)]
@ -145,10 +139,8 @@
(defproc (function-interval (defproc (function-interval
[f1 (real? . -> . real?)] [f2 (real? . -> . real?)] [f1 (real? . -> . real?)] [f2 (real? . -> . real?)]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (interval-color)] [#:color color plot-color/c (interval-color)]
[#:style style plot-brush-style/c (interval-style)] [#:style style plot-brush-style/c (interval-style)]
@ -193,10 +185,8 @@
(defproc (inverse-interval (defproc (inverse-interval
[f1 (real? . -> . real?)] [f2 (real? . -> . real?)] [f1 (real? . -> . real?)] [f2 (real? . -> . real?)]
[y-min (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[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]
[#:x-min x-min (or/c regular-real? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (interval-color)] [#:color color plot-color/c (interval-color)]
[#:style style plot-brush-style/c (interval-style)] [#:style style plot-brush-style/c (interval-style)]

View File

@ -82,8 +82,8 @@
(define series-terms 9) (define series-terms 9)
(defproc (kde [xs (listof real?)] [h real?]) (values mapped-function? (defproc (kde [xs (listof real?)] [h real?]) (values mapped-function?
(or/c regular-real? #f) (or/c rational? #f)
(or/c regular-real? #f)) (or/c rational? #f))
(if (empty? xs) (if (empty? xs)
(values (mapped-function (λ (y) 0) (λ (ys) (map (λ _ 0.0) ys))) #f #f) (values (mapped-function (λ (y) 0) (λ (ys) (map (λ _ 0.0) ys))) #f #f)
(let* ([xs (list->vector (sort (map exact->inexact xs) fl<))] (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)))) (values (mapped-function (λ (x) (first (fmap (list x)))) fmap) x-min x-max))))
(defproc (density [xs (listof real?)] [bw-adjust real? 1] (defproc (density [xs (listof real?)] [bw-adjust real? 1]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]

View File

@ -20,17 +20,15 @@
[else empty])) [else empty]))
(defproc (lines [vs (listof (vector/c real? real?))] (defproc (lines [vs (listof (vector/c real? real?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]
[#:style style plot-pen-style/c (line-style)] [#:style style plot-pen-style/c (line-style)]
[#:alpha alpha (real-in 0 1) (line-alpha)] [#:alpha alpha (real-in 0 1) (line-alpha)]
[#:label label (or/c string? #f) #f] [#:label label (or/c string? #f) #f]
) renderer2d? ) renderer2d?
(define rvs (filter vregular? vs)) (define rvs (filter vrational? vs))
(cond [(empty? rvs) (renderer2d #f #f #f #f)] (cond [(empty? rvs) (renderer2d #f #f #f #f)]
[else [else
(match-define (list (vector rxs rys) ...) rvs) (match-define (list (vector rxs rys) ...) rvs)
@ -42,11 +40,9 @@
(lines-render-proc vs color width style alpha label)))])) (lines-render-proc vs color width style alpha label)))]))
(defproc (parametric [f (real? . -> . (vector/c real? real?))] (defproc (parametric [f (real? . -> . (vector/c real? real?))]
[t-min regular-real?] [t-max regular-real?] [t-min rational?] [t-max rational?]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]
@ -61,10 +57,8 @@
(defproc (polar [f (real? . -> . real?)] (defproc (polar [f (real? . -> . real?)]
[θ-min real? 0] [θ-max real? (* 2 pi)] [θ-min real? 0] [θ-max real? (* 2 pi)]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]
@ -93,10 +87,8 @@
[else empty])) [else empty]))
(defproc (function [f (real? . -> . real?)] (defproc (function [f (real? . -> . real?)]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]
@ -125,10 +117,8 @@
[else empty])) [else empty]))
(defproc (inverse [f (real? . -> . real?)] (defproc (inverse [f (real? . -> . real?)]
[y-min (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[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]
[#:x-min x-min (or/c regular-real? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]

View File

@ -405,7 +405,7 @@
;; Shapes ;; Shapes
(define/public (put-lines vs) (define/public (put-lines vs)
(for ([vs (vregular-sublists vs)]) (for ([vs (vrational-sublists vs)])
(for ([vs (if clipping? (for ([vs (if clipping?
(in-list (clip-lines vs clip-x-min clip-x-max (in-list (clip-lines vs clip-x-min clip-x-max
clip-y-min clip-y-max)) clip-y-min clip-y-max))
@ -415,7 +415,7 @@
(send pd draw-lines (map (λ (v) (plot->dc* v)) vs))))))) (send pd draw-lines (map (λ (v) (plot->dc* v)) vs)))))))
(define/public (put-line v1 v2) (define/public (put-line v1 v2)
(when (and (vregular? v1) (vregular? v2)) (when (and (vrational? v1) (vrational? v2))
(let-values ([(v1 v2) (if clipping? (let-values ([(v1 v2) (if clipping?
(clip-line v1 v2 clip-x-min clip-x-max (clip-line v1 v2 clip-x-min clip-x-max
clip-y-min clip-y-max) clip-y-min clip-y-max)
@ -427,7 +427,7 @@
(subdivide-line plot->dc* v1 v2)))))))) (subdivide-line plot->dc* v1 v2))))))))
(define/public (put-polygon vs) (define/public (put-polygon vs)
(when (andmap vregular? vs) (when (andmap vrational? vs)
(let* ([vs (if clipping? (let* ([vs (if clipping?
(clip-polygon vs clip-x-min clip-x-max (clip-polygon vs clip-x-min clip-x-max
clip-y-min clip-y-max) clip-y-min clip-y-max)
@ -439,26 +439,26 @@
(subdivide-polygon plot->dc* vs)))))))) (subdivide-polygon plot->dc* vs))))))))
(define/public (put-rect r) (define/public (put-rect r)
(when (rect-regular? r) (when (rect-rational? r)
(match-define (vector (ivl x1 x2) (ivl y1 y2)) 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))))) (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] (define/public (put-text str v [anchor 'top-left] [angle 0]
#:outline? [outline? #f]) #: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?))) (send pd draw-text str (plot->dc* v) anchor angle #:outline? outline?)))
(define/public (put-glyphs vs symbol size) (define/public (put-glyphs vs symbol size)
(send pd draw-glyphs (map (λ (v) (plot->dc* v)) (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)) vs))
symbol size)) symbol size))
(define/public (put-arrow v1 v2) (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)))) (send pd draw-arrow (plot->dc* v1) (plot->dc* v2))))
(define/public (put-tick v r angle) (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))) (send pd draw-tick (plot->dc* v) r angle)))
)) ))

View File

@ -29,14 +29,14 @@
(define (get-renderer-list renderer-tree) (define (get-renderer-list renderer-tree)
(for/list ([r (flatten (list renderer-tree))]) (for/list ([r (flatten (list renderer-tree))])
(match r (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)] (renderer2d bounds-rect bounds-fun ticks-fun #f)]
[_ r]))) [_ r])))
(define (get-bounds-rect renderer-list x-min x-max y-min y-max) (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 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)) (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)) (rect-zero-area? plot-bounds-rect))
(match-define (vector x-ivl y-ivl) 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" (error 'plot "could not determine sensible plot bounds; got x ∈ ~a, y ∈ ~a"
@ -74,13 +74,11 @@
(send area end-plot)) (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<%>)] [dc (is-a?/c dc<%>)]
[x real?] [y real?] [width (>=/c 0)] [height (>=/c 0)] [x real?] [y real?] [width (>=/c 0)] [height (>=/c 0)]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:title title (or/c string? #f) (plot-title)] [#:title title (or/c string? #f) (plot-title)]
[#:x-label x-label (or/c string? #f) (plot-x-label)] [#:x-label x-label (or/c string? #f) (plot-x-label)]
[#:y-label y-label (or/c string? #f) (plot-y-label)] [#:y-label y-label (or/c string? #f) (plot-y-label)]
@ -101,11 +99,9 @@
;; Plot to various other backends ;; Plot to various other backends
;; Plot to a bitmap ;; Plot to a bitmap
(defproc (plot-bitmap [renderer-tree (treeof (or/c renderer2d? non-renderer?))] (defproc (plot-bitmap [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:title title (or/c string? #f) (plot-title)] [#: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)) #:title title #:x-label x-label #:y-label y-label #:legend-anchor legend-anchor))
width height)) width height))
(defproc (plot-pict [renderer-tree (treeof (or/c renderer2d? non-renderer?))] (defproc (plot-pict [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:title title (or/c string? #f) (plot-title)] [#:title title (or/c string? #f) (plot-title)]
@ -146,11 +140,9 @@
width height)) width height))
;; Plot to a snip ;; Plot to a snip
(defproc (plot-snip [renderer-tree (treeof (or/c renderer2d? non-renderer?))] (defproc (plot-snip [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:title title (or/c string? #f) (plot-title)] [#:title title (or/c string? #f) (plot-title)]
@ -166,11 +158,9 @@
(make-object image-snip% bm)) (make-object image-snip% bm))
;; Plot to a frame ;; Plot to a frame
(defproc (plot-frame [renderer-tree (treeof (or/c renderer2d? non-renderer?))] (defproc (plot-frame [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:title title (or/c string? #f) (plot-title)] [#: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"))) (make-snip-frame snip width height (if title (format "Plot: ~a" title) "Plot")))
;; Plot to a file ;; 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?)] [output (or/c path-string? output-port?)]
[kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto] [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-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:title title (or/c string? #f) (plot-title)] [#:title title (or/c string? #f) (plot-title)]
@ -231,11 +219,9 @@
(void)) (void))
;; Plot to a frame or a snip, depending on (plot-new-window?) ;; Plot to a frame or a snip, depending on (plot-new-window?)
(defproc (plot [renderer-tree (treeof (or/c renderer2d? non-renderer?))] (defproc (plot [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:title title (or/c string? #f) (plot-title)] [#:title title (or/c string? #f) (plot-title)]
@ -244,8 +230,7 @@
[#:legend-anchor legend-anchor anchor/c (plot-legend-anchor)] [#:legend-anchor legend-anchor anchor/c (plot-legend-anchor)]
[#:out-file out-file (or/c path-string? output-port? #f) #f] [#: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] [#:out-kind out-kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
[#:fgcolor fgcolor plot-color/c #f] [#:fgcolor fgcolor plot-color/c #f] [#:bgcolor bgcolor plot-color/c #f]
[#:bgcolor bgcolor plot-color/c #f]
[#:lncolor lncolor plot-color/c #f] ; unused [#:lncolor lncolor plot-color/c #f] ; unused
) (or/c (is-a?/c snip%) void?) ) (or/c (is-a?/c snip%) void?)
(when fgcolor (when fgcolor

View File

@ -19,10 +19,8 @@
(if label (point-legend-entry label sym color size line-width) empty)) (if label (point-legend-entry label sym color size line-width) empty))
(defproc (points [vs (listof (vector/c real? real?))] (defproc (points [vs (listof (vector/c real? real?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:sym sym point-sym/c (point-sym)] [#:sym sym point-sym/c (point-sym)]
[#:color color plot-color/c (point-color)] [#:color color plot-color/c (point-color)]
[#:size size (>=/c 0) (point-size)] [#:size size (>=/c 0) (point-size)]
@ -30,7 +28,7 @@
[#:alpha alpha (real-in 0 1) (point-alpha)] [#:alpha alpha (real-in 0 1) (point-alpha)]
[#:label label (or/c string? #f) #f] [#:label label (or/c string? #f) #f]
) renderer2d? ) renderer2d?
(let ([vs (filter vregular? vs)]) (let ([vs (filter vrational? vs)])
(cond (cond
[(empty? vs) (renderer2d #f #f #f #f)] [(empty? vs) (renderer2d #f #f #f #f)]
[else (match-define (list (vector xs ys) ...) vs) [else (match-define (list (vector xs ys) ...) vs)
@ -53,7 +51,7 @@
(define-values (xs ys dxs dys angles mags) (define-values (xs ys dxs dys angles mags)
(for*/lists (xs ys dxs dys angles mags) ([x (in-list xs0)] (for*/lists (xs ys dxs dys angles mags) ([x (in-list xs0)]
[y (in-list ys0)] [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) (match-define (vector dx dy) dv)
(values x y dx dy (atan2 dy dx) (sqrt (+ (sqr dx) (sqr dy)))))) (values x y dx dy (atan2 dy dx) (sqrt (+ (sqr dx) (sqr dy))))))
@ -88,10 +86,8 @@
(defproc (vector-field (defproc (vector-field
[f (or/c (real? real? . -> . (vector/c real? real?)) [f (or/c (real? real? . -> . (vector/c real? real?))
((vector/c real? real?) . -> . (vector/c real? real?)))] ((vector/c real? real?) . -> . (vector/c real? real?)))]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f]
[y-max (or/c regular-real? #f) #f]
[#:samples samples exact-positive-integer? (vector-field-samples)] [#:samples samples exact-positive-integer? (vector-field-samples)]
[#:scale scale (or/c real? (one-of/c 'auto 'normalized)) (vector-field-scale)] [#:scale scale (or/c real? (one-of/c 'auto 'normalized)) (vector-field-scale)]
[#:color color plot-color/c (vector-field-color)] [#:color color plot-color/c (vector-field-color)]
@ -126,17 +122,15 @@
(defproc (error-bars (defproc (error-bars
[bars (listof (vector/c real? real? real?))] [bars (listof (vector/c real? real? real?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:color color plot-color/c (error-bar-color)] [#:color color plot-color/c (error-bar-color)]
[#:line-width line-width (>=/c 0) (error-bar-line-width)] [#:line-width line-width (>=/c 0) (error-bar-line-width)]
[#:line-style line-style plot-pen-style/c (error-bar-line-style)] [#:line-style line-style plot-pen-style/c (error-bar-line-style)]
[#:width width (>=/c 0) (error-bar-width)] [#:width width (>=/c 0) (error-bar-width)]
[#:alpha alpha (real-in 0 1) (error-bar-alpha)] [#:alpha alpha (real-in 0 1) (error-bar-alpha)]
) renderer2d? ) renderer2d?
(let ([bars (filter vregular? bars)]) (let ([bars (filter vrational? bars)])
(cond [(empty? bars) (renderer2d #f #f #f #f)] (cond [(empty? bars) (renderer2d #f #f #f #f)]
[else [else
(match-define (list (vector xs ys hs) ...) bars) (match-define (list (vector xs ys hs) ...) bars)

View File

@ -25,8 +25,8 @@
(defproc (rectangles (defproc (rectangles
[rects (listof (vector/c ivl? ivl?))] [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] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:y-max y-max (or/c regular-real? #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)] [#:color color plot-color/c (rectangle-color)]
[#:style style plot-brush-style/c (rectangle-style)] [#:style style plot-brush-style/c (rectangle-style)]
[#:line-color line-color plot-color/c (rectangle-line-color)] [#:line-color line-color plot-color/c (rectangle-line-color)]
@ -36,8 +36,8 @@
[#:label label (or/c string? #f) #f] [#:label label (or/c string? #f) #f]
) renderer2d? ) renderer2d?
(match-define (list (vector (ivl x1s x2s) (ivl y1s y2s)) ...) rects) (match-define (list (vector (ivl x1s x2s) (ivl y1s y2s)) ...) rects)
(define rxs (filter regular-real? (append x1s x2s))) (define rxs (filter rational? (append x1s x2s)))
(define rys (filter regular-real? (append y1s y2s))) (define rys (filter rational? (append y1s y2s)))
(cond (cond
[(or (empty? rxs) (empty? rys)) (renderer2d #f #f #f #f)] [(or (empty? rxs) (empty? rys)) (renderer2d #f #f #f #f)]
[else [else
@ -55,8 +55,8 @@
(defproc (area-histogram (defproc (area-histogram
[f (real? . -> . real?)] [f (real? . -> . real?)]
[bin-bounds (listof 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] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #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)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (rectangle-color)] [#:color color plot-color/c (rectangle-color)]
[#:style style plot-brush-style/c (rectangle-style)] [#:style style plot-brush-style/c (rectangle-style)]
@ -66,7 +66,7 @@
[#:alpha alpha (real-in 0 1) (rectangle-alpha)] [#:alpha alpha (real-in 0 1) (rectangle-alpha)]
[#:label label (or/c string? #f) #f] [#:label label (or/c string? #f) #f]
) renderer2d? ) renderer2d?
(let* ([bin-bounds (filter regular-real? bin-bounds)] (let* ([bin-bounds (filter rational? bin-bounds)]
[bin-bounds (sort bin-bounds <)]) [bin-bounds (sort bin-bounds <)])
(cond (cond
[((length bin-bounds) . < . 2) (renderer2d #f #f #f #f)] [((length bin-bounds) . < . 2) (renderer2d #f #f #f #f)]
@ -106,8 +106,8 @@
(defproc (discrete-histogram (defproc (discrete-histogram
[cat-vals (listof (vector/c any/c (or/c real? ivl? #f)))] [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] [#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #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)] [#:gap gap (real-in 0 1) (discrete-histogram-gap)]
[#:skip skip (>=/c 0) (discrete-histogram-skip)] [#:skip skip (>=/c 0) (discrete-histogram-skip)]
[#:invert? invert? boolean? (discrete-histogram-invert?)] [#:invert? invert? boolean? (discrete-histogram-invert?)]
@ -121,10 +121,10 @@
[#:far-ticks? far-ticks? boolean? #f] [#:far-ticks? far-ticks? boolean? #f]
) renderer2d? ) renderer2d?
(match-define (list (vector cats ys) ...) cat-vals) (match-define (list (vector cats ys) ...) cat-vals)
(define rys (filter regular-real? (append* (for/list ([y (in-list ys)]) (define rys (filter rational? (append* (for/list ([y (in-list ys)])
(match y (match y
[(ivl y1 y2) (list y1 y2)] [(ivl y1 y2) (list y1 y2)]
[_ (list y)]))))) [_ (list y)])))))
(cond (cond
[(empty? rys) (renderer2d #f #f #f #f)] [(empty? rys) (renderer2d #f #f #f #f)]
[else [else
@ -148,8 +148,8 @@
(defproc (stacked-histogram (defproc (stacked-histogram
[cat-vals (listof (vector/c any/c (listof real?)))] [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] [#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #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)] [#:gap gap (real-in 0 1) (discrete-histogram-gap)]
[#:skip skip (>=/c 0) (discrete-histogram-skip)] [#:skip skip (>=/c 0) (discrete-histogram-skip)]
[#:invert? invert? boolean? (discrete-histogram-invert?)] [#:invert? invert? boolean? (discrete-histogram-invert?)]

View File

@ -35,12 +35,9 @@
(defproc (isoline3d (defproc (isoline3d
[f (real? real? . -> . real?)] [z real?] [f (real? real? . -> . real?)] [z real?]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]
@ -92,12 +89,9 @@
(defproc (contours3d (defproc (contours3d
[f (real? real? . -> . real?)] [f (real? real? . -> . real?)]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
[#:levels levels (or/c 'auto pos/c (listof real?)) (contour-levels)] [#:levels levels (or/c 'auto pos/c (listof real?)) (contour-levels)]
[#:colors colors (plot-colors/c (listof real?)) (contour-colors)] [#:colors colors (plot-colors/c (listof real?)) (contour-colors)]
@ -181,12 +175,9 @@
(defproc (contour-intervals3d (defproc (contour-intervals3d
[f (real? real? . -> . real?)] [f (real? real? . -> . real?)]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
[#:levels levels (or/c 'auto pos/c (listof real?)) (contour-levels)] [#:levels levels (or/c 'auto pos/c (listof real?)) (contour-levels)]
[#:colors colors (plot-colors/c (listof ivl?)) (contour-interval-colors)] [#:colors colors (plot-colors/c (listof ivl?)) (contour-interval-colors)]

View File

@ -36,13 +36,10 @@
label color style line-color line-width line-style)] label color style line-color line-width line-style)]
[else empty])) [else empty]))
(defproc (isosurface3d [f (real? real? real? . -> . real?)] [d real?] (defproc (isosurface3d [f (real? real? real? . -> . real?)] [d rational?]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f] [z-min (or/c rational? #f) #f] [z-max (or/c rational? #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]
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
[#:color color plot-color/c (surface-color)] [#:color color plot-color/c (surface-color)]
[#:style style plot-brush-style/c (surface-style)] [#:style style plot-brush-style/c (surface-style)]
@ -112,10 +109,10 @@
(defproc (isosurfaces3d (defproc (isosurfaces3d
[f (real? real? real? . -> . real?)] [f (real? real? real? . -> . real?)]
[x-min (or/c regular-real? #f) #f] [x-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 regular-real? #f) #f] [y-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[z-min (or/c regular-real? #f) #f] [z-max (or/c regular-real? #f) #f] [z-min (or/c rational? #f) #f] [z-max (or/c rational? #f) #f]
[#:d-min d-min (or/c regular-real? #f) #f] [#:d-max d-max (or/c regular-real? #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)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
[#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (isosurface-levels)] [#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (isosurface-levels)]
[#:colors colors (plot-colors/c (listof real?)) (isosurface-colors)] [#:colors colors (plot-colors/c (listof real?)) (isosurface-colors)]
@ -191,9 +188,9 @@
(defproc (polar3d (defproc (polar3d
[f (real? real? . -> . real?)] [f (real? real? . -> . real?)]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-max x-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 regular-real? #f) #f] [#:y-max y-max (or/c regular-real? #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 regular-real? #f) #f] [#:z-max z-max (or/c regular-real? #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)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
[#:color color plot-color/c (surface-color)] [#:color color plot-color/c (surface-color)]
[#:style style plot-brush-style/c (surface-style)] [#: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)))] (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)))]) [ρ (in-list (linear-seq (* -1/2 pi) (* 1/2 pi) (* 2 samples)))])
(3d-polar->3d-cartesian θ ρ (f θ ρ)))) (3d-polar->3d-cartesian θ ρ (f θ ρ))))
(define rvs (filter vregular? vs)) (define rvs (filter vrational? vs))
(cond [(empty? rvs) (renderer3d #f #f #f #f)] (cond [(empty? rvs) (renderer3d #f #f #f #f)]
[else [else
(match-define (list (vector rxs rys rzs) ...) rvs) (match-define (list (vector rxs rys rzs) ...) rvs)

View File

@ -18,7 +18,7 @@
(define (lines3d-renderer (define (lines3d-renderer
vs-thnk x-min x-max y-min y-max z-min z-max color width style alpha label) 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)] (cond [(empty? rvs) (renderer3d #f #f #f #f)]
[else [else
(match-define (list (vector rxs rys rzs) ...) rvs) (match-define (list (vector rxs rys rzs) ...) rvs)
@ -34,12 +34,9 @@
(defproc (lines3d (defproc (lines3d
[vs (listof (vector/c real? real? real?))] [vs (listof (vector/c real? real? real?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]
[#:style style plot-pen-style/c (line-style)] [#:style style plot-pen-style/c (line-style)]
@ -50,13 +47,10 @@
(defproc (parametric3d (defproc (parametric3d
[f (real? . -> . (vector/c real? real? real?))] [f (real? . -> . (vector/c real? real? real?))]
[t-min regular-real?] [t-max regular-real?] [t-min rational?] [t-max rational?]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)]
[#:color color plot-color/c (line-color)] [#:color color plot-color/c (line-color)]
[#:width width (>=/c 0) (line-width)] [#:width width (>=/c 0) (line-width)]

View File

@ -803,7 +803,7 @@
(define/public (put-line v1 v2 [c (v* (v+ v1 v2) 1/2)]) (define/public (put-line v1 v2 [c (v* (v+ v1 v2) 1/2)])
(let/ec return (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? (let-values ([(v1 v2) (if clipping?
(clip-line v1 v2 clip-x-min clip-x-max (clip-line v1 v2 clip-x-min clip-x-max
clip-y-min clip-y-max clip-y-min clip-y-max
@ -820,14 +820,14 @@
pen-color pen-width pen-style)))])))) pen-color pen-width pen-style)))]))))
(define/public (put-lines vs) (define/public (put-lines vs)
(for ([vs (vregular-sublists vs)]) (for ([vs (vrational-sublists vs)])
(when (not (empty? vs)) (when (not (empty? vs))
(for ([v1 (in-list vs)] [v2 (in-list (rest vs))]) (for ([v1 (in-list vs)] [v2 (in-list (rest vs))])
(put-line v1 v2))))) (put-line v1 v2)))))
(define (add-polygon lst vs c) (define (add-polygon lst vs c)
(let/ec return (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)) (return lst))
(define normal (vnormal (map plot->norm vs))) (define normal (vnormal (map plot->norm vs)))
@ -853,7 +853,7 @@
(add-shape! (shapes alpha (plot->norm c) lst)))) (add-shape! (shapes alpha (plot->norm c) lst))))
(define/public (put-rect r [c (rect-center r)]) (define/public (put-rect r [c (rect-center r)])
(when (rect-regular? r) (when (rect-rational? r)
(let ([r (rect-meet r bounds-rect)]) (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-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))] (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)))))) pen-color pen-width pen-style brush-color brush-style))))))
(define/public (put-text str v [anchor 'center] [angle 0]) (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 (add-shape! (text alpha (plot->norm v) anchor angle str
font-size font-family text-foreground)))) font-size font-family text-foreground))))
(define/public (put-glyphs vs symbol size) (define/public (put-glyphs vs symbol size)
(for ([v (in-list vs)]) (for ([v (in-list vs)])
(when (and (vregular? v) (in-bounds? v)) (when (and (vrational? v) (in-bounds? v))
(add-shape! (add-shape!
(glyph alpha (plot->norm v) symbol size (glyph alpha (plot->norm v) symbol size
pen-color pen-width pen-style brush-color brush-style))))) pen-color pen-width pen-style brush-color brush-style)))))
(define/public (put-arrow v1 v2 [c (v* (v+ v1 v2) 1/2)]) (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) (cond [(in-bounds? v2)
(add-shape! (add-shape!
(arrow-glyph alpha (plot->norm c) (plot->norm v1) (plot->norm v2) (arrow-glyph alpha (plot->norm c) (plot->norm v1) (plot->norm v2)
@ -886,7 +886,7 @@
[else (put-line v1 v2)]))) [else (put-line v1 v2)])))
(define/public (put-tick v radius angle) (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 (add-shape! (tick-glyph alpha (plot->norm v) radius angle
pen-color pen-width pen-style)))) pen-color pen-width pen-style))))
)) ; end class )) ; end class

View File

@ -30,14 +30,14 @@
(define (get-renderer-list renderer-tree) (define (get-renderer-list renderer-tree)
(for/list ([r (flatten (list renderer-tree))]) (for/list ([r (flatten (list renderer-tree))])
(match r (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)] (renderer3d bounds-rect bounds-fun ticks-fun #f)]
[_ r]))) [_ r])))
(define (get-bounds-rect renderer-list x-min x-max y-min y-max z-min z-max) (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 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)) (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)) (rect-zero-area? plot-bounds-rect))
(match-define (vector x-ivl y-ivl z-ivl) 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" (error 'plot "could not determine sensible plot bounds; got x ∈ ~a, y ∈ ~a, z ∈ ~a"
@ -84,15 +84,12 @@
(send area end-plot)) (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<%>)] [dc (is-a?/c dc<%>)]
[x real?] [y real?] [width (>=/c 0)] [height (>=/c 0)] [x real?] [y real?] [width (>=/c 0)] [height (>=/c 0)]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:angle angle real? (plot3d-angle)] [#:altitude altitude real? (plot3d-altitude)] [#:angle angle real? (plot3d-angle)] [#:altitude altitude real? (plot3d-altitude)]
[#:title title (or/c string? #f) (plot-title)] [#:title title (or/c string? #f) (plot-title)]
[#:x-label x-label (or/c string? #f) (plot-x-label)] [#:x-label x-label (or/c string? #f) (plot-x-label)]
@ -119,13 +116,10 @@
;; Plot to various other backends ;; Plot to various other backends
;; Plot to a bitmap ;; Plot to a bitmap
(defproc (plot3d-bitmap [renderer-tree (treeof (or/c renderer3d? non-renderer?))] (defproc (plot3d-bitmap [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:angle angle real? (plot3d-angle)] [#:angle angle real? (plot3d-angle)]
@ -144,13 +138,10 @@
#:z-label z-label #:legend-anchor legend-anchor)) #:z-label z-label #:legend-anchor legend-anchor))
width height)) width height))
(defproc (plot3d-pict [renderer-tree (treeof (or/c renderer3d? non-renderer?))] (defproc (plot3d-pict [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:angle angle real? (plot3d-angle)] [#:angle angle real? (plot3d-angle)]
@ -171,13 +162,10 @@
width height)) width height))
;; Plot to a snip ;; Plot to a snip
(defproc (plot3d-snip [renderer-tree (treeof (or/c renderer3d? non-renderer?))] (defproc (plot3d-snip [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:angle angle real? (plot3d-angle)] [#:angle angle real? (plot3d-angle)]
@ -238,13 +226,10 @@
angle altitude saved-plot-parameters))) angle altitude saved-plot-parameters)))
;; Plot to a frame ;; Plot to a frame
(defproc (plot3d-frame [renderer-tree (treeof (or/c renderer3d? non-renderer?))] (defproc (plot3d-frame [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:angle angle real? (plot3d-angle)] [#:angle angle real? (plot3d-angle)]
@ -264,15 +249,12 @@
(make-snip-frame snip width height (if title (format "Plot: ~a" title) "Plot"))) (make-snip-frame snip width height (if title (format "Plot: ~a" title) "Plot")))
;; Plot to any supported kind of file ;; 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?)] [output (or/c path-string? output-port?)]
[kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto] [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-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:angle angle real? (plot3d-angle)] [#:angle angle real? (plot3d-angle)]
@ -316,13 +298,10 @@
(void)) (void))
;; Plot to a frame or a snip, depending on the value of plot-new-window? ;; 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?))] (defproc (plot3d [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:angle angle real? #f] [#:altitude altitude real? #f] [#:angle angle real? #f] [#:altitude altitude real? #f]
@ -334,8 +313,7 @@
[#:legend-anchor legend-anchor anchor/c (plot-legend-anchor)] [#:legend-anchor legend-anchor anchor/c (plot-legend-anchor)]
[#:out-file out-file (or/c path-string? output-port? #f) #f] [#: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] [#:out-kind out-kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
[#:fgcolor fgcolor plot-color/c #f] [#:fgcolor fgcolor plot-color/c #f] [#:bgcolor bgcolor plot-color/c #f]
[#:bgcolor bgcolor plot-color/c #f]
[#:lncolor lncolor plot-color/c #f] ; unused [#:lncolor lncolor plot-color/c #f] ; unused
) (or/c (is-a?/c snip%) void?) ) (or/c (is-a?/c snip%) void?)
(when fgcolor (when fgcolor

View File

@ -18,12 +18,9 @@
(defproc (points3d (defproc (points3d
[vs (listof (vector/c real? real? real?))] [vs (listof (vector/c real? real? real?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:sym sym point-sym/c (point-sym)] [#:sym sym point-sym/c (point-sym)]
[#:color color plot-color/c (point-color)] [#:color color plot-color/c (point-color)]
[#:size size (>=/c 0) (point-size)] [#:size size (>=/c 0) (point-size)]
@ -31,7 +28,7 @@
[#:alpha alpha (real-in 0 1) (point-alpha)] [#:alpha alpha (real-in 0 1) (point-alpha)]
[#:label label (or/c string? #f) #f] [#:label label (or/c string? #f) #f]
) renderer3d? ) renderer3d?
(let ([vs (filter vregular? vs)]) (let ([vs (filter vrational? vs)])
(cond [(empty? vs) (renderer3d #f #f #f #f)] (cond [(empty? vs) (renderer3d #f #f #f #f)]
[else [else
(match-define (list (vector xs ys zs) ...) vs) (match-define (list (vector xs ys zs) ...) vs)
@ -59,7 +56,7 @@
(for*/lists (vs dxs dys dzs norms mags) ([x (in-list xs0)] (for*/lists (vs dxs dys dzs norms mags) ([x (in-list xs0)]
[y (in-list ys0)] [y (in-list ys0)]
[z (in-list zs0)] [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) (match-define (vector dx dy dz) dv)
(values (vector x y z) dx dy dz (vnormalize dv) (vmag dv)))) (values (vector x y z) dx dy dz (vnormalize dv) (vmag dv))))
@ -94,12 +91,9 @@
(defproc (vector-field3d (defproc (vector-field3d
[f (or/c (real? real? real? . -> . (vector/c real? real? real?)) [f (or/c (real? real? real? . -> . (vector/c real? real? real?))
((vector/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-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f] [z-min (or/c rational? #f) #f] [z-max (or/c rational? #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]
[#:samples samples exact-positive-integer? ( vector-field3d-samples)] [#:samples samples exact-positive-integer? ( vector-field3d-samples)]
[#:scale scale (or/c real? (one-of/c 'auto 'normalized)) (vector-field-scale)] [#:scale scale (or/c real? (one-of/c 'auto 'normalized)) (vector-field-scale)]
[#:color color plot-color/c (vector-field-color)] [#:color color plot-color/c (vector-field-color)]

View File

@ -25,9 +25,9 @@
(defproc (rectangles3d (defproc (rectangles3d
[rects (listof (vector/c ivl? ivl? ivl?))] [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] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:y-max y-max (or/c regular-real? #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 regular-real? #f) #f] [#:z-max z-max (or/c regular-real? #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)] [#:color color plot-color/c (rectangle-color)]
[#:style style plot-brush-style/c (rectangle-style)] [#:style style plot-brush-style/c (rectangle-style)]
[#:line-color line-color plot-color/c (rectangle-line-color)] [#:line-color line-color plot-color/c (rectangle-line-color)]
@ -37,9 +37,9 @@
[#:label label (or/c string? #f) #f] [#:label label (or/c string? #f) #f]
) renderer3d? ) renderer3d?
(match-define (list (vector (ivl x1s x2s) (ivl y1s y2s) (ivl z1s z2s)) ...) rects) (match-define (list (vector (ivl x1s x2s) (ivl y1s y2s) (ivl z1s z2s)) ...) rects)
(define rxs (filter regular-real? (append x1s x2s))) (define rxs (filter rational? (append x1s x2s)))
(define rys (filter regular-real? (append y1s y2s))) (define rys (filter rational? (append y1s y2s)))
(define rzs (filter regular-real? (append z1s z2s))) (define rzs (filter rational? (append z1s z2s)))
(cond (cond
[(or (empty? rxs) (empty? rys) (empty? rzs)) (renderer3d #f #f #f #f)] [(or (empty? rxs) (empty? rys) (empty? rzs)) (renderer3d #f #f #f #f)]
[else [else
@ -78,9 +78,9 @@
(defproc (discrete-histogram3d (defproc (discrete-histogram3d
[cat-vals (listof (vector/c any/c any/c (or/c real? ivl? #f)))] [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] [#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #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 regular-real? #f) 0] [#:z-max z-max (or/c regular-real? #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)] [#:gap gap (real-in 0 1) (discrete-histogram-gap)]
[#:color color plot-color/c (rectangle-color)] [#:color color plot-color/c (rectangle-color)]
[#:style style plot-brush-style/c (rectangle-style)] [#:style style plot-brush-style/c (rectangle-style)]
@ -93,10 +93,10 @@
[#:y-far-ticks? y-far-ticks? boolean? #f] [#:y-far-ticks? y-far-ticks? boolean? #f]
) renderer3d? ) renderer3d?
(match-define (list (vector cat1s cat2s zs) ...) cat-vals) (match-define (list (vector cat1s cat2s zs) ...) cat-vals)
(define rzs (filter regular-real? (append* (for/list ([z (in-list zs)]) (define rzs (filter rational? (append* (for/list ([z (in-list zs)])
(match z (match z
[(ivl z1 z2) (list z1 z2)] [(ivl z1 z2) (list z1 z2)]
[_ (list z)]))))) [_ (list z)])))))
(cond (cond
[(empty? rzs) (renderer3d #f #f #f #f)] [(empty? rzs) (renderer3d #f #f #f #f)]
[else [else
@ -137,9 +137,9 @@
(defproc (stacked-histogram3d (defproc (stacked-histogram3d
[cat-vals (listof (vector/c any/c any/c (listof real?)))] [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] [#:x-min x-min (or/c rational? #f) 0] [#:x-max x-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) 0] [#:y-max y-max (or/c regular-real? #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 regular-real? #f) 0] [#:z-max z-max (or/c regular-real? #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)] [#:gap gap (real-in 0 1) (discrete-histogram-gap)]
[#:colors colors (plot-colors/c nat/c) (stacked-histogram-colors)] [#:colors colors (plot-colors/c nat/c) (stacked-histogram-colors)]
[#:styles styles (plot-brush-styles/c nat/c) (stacked-histogram-styles)] [#:styles styles (plot-brush-styles/c nat/c) (stacked-histogram-styles)]

View File

@ -31,12 +31,9 @@
(defproc (surface3d (defproc (surface3d
[f (real? real? . -> . real?)] [f (real? real? . -> . real?)]
[x-min (or/c regular-real? #f) #f] [x-min (or/c rational? #f) #f] [x-max (or/c rational? #f) #f]
[x-max (or/c regular-real? #f) #f] [y-min (or/c rational? #f) #f] [y-max (or/c rational? #f) #f]
[y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)]
[#:color color plot-color/c (surface-color)] [#:color color plot-color/c (surface-color)]
[#:style style plot-brush-style/c (surface-style)] [#:style style plot-brush-style/c (surface-style)]

View File

@ -6,6 +6,8 @@
@declare-exporting[plot/utils] @declare-exporting[plot/utils]
The following API is provided by @racketmodname[plot/utils].
@section{Plot Elements} @section{Plot Elements}
@defstruct[plot-element ([bounds-rect (or/c (vectorof ivl?) #f)] @defstruct[plot-element ([bounds-rect (or/c (vectorof ivl?) #f)]
@ -13,7 +15,7 @@
[ticks-fun (or/c ticks-fun/c #f)])]{ [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] 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)])]{ #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} @section{Legend Entries}
@defstruct[legend-entry ([label string?] @defstruct[legend-entry ([label string?]

View 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]

View File

@ -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["renderer3d.scrbl"]
@include-section["nonrenderer.scrbl"]
@include-section["ticks.scrbl"] @include-section["ticks.scrbl"]
@include-section["utils.scrbl"] @include-section["utils.scrbl"]

View File

@ -7,11 +7,9 @@
@title[#:tag "plot2d"]{2D Plot Procedures} @title[#:tag "plot2d"]{2D Plot Procedures}
@defproc[(plot [renderer-tree (treeof (or/c renderer2d? non-renderer?))] @defproc[(plot [renderer-tree (treeof (or/c renderer2d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f]
[#:y-max y-max (or/c regular-real? #f) #f]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:title title (or/c string? #f) (plot-title)] [#:title title (or/c string? #f) (plot-title)]
@ -52,14 +50,14 @@ The @(racket #:lncolor) keyword argument is also accepted for backward compatibi
} }
@deftogether[ @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?)] [output (or/c path-string? output-port?)]
[kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto] [kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
[#:<plot-keyword> <plot-keyword> <plot-keyword-contract>] ...) void?] [#:<plot-keyword> <plot-keyword> <plot-keyword-contract>] ...) void?]
@defproc[(plot-pict [renderer-tree (treeof (or/c renderer2d? non-renderer?))] ...) pict?] @defproc[(plot-pict [renderer-tree (treeof (or/c renderer2d? nonrenderer?))] ...) pict?]
@defproc[(plot-bitmap [renderer-tree (treeof (or/c renderer2d? non-renderer?))] ...) (is-a?/c bitmap%)] @defproc[(plot-bitmap [renderer-tree (treeof (or/c renderer2d? nonrenderer?))] ...) (is-a?/c bitmap%)]
@defproc[(plot-snip [renderer-tree (treeof (or/c renderer2d? non-renderer?))] ...) (is-a?/c image-snip%)] @defproc[(plot-snip [renderer-tree (treeof (or/c renderer2d? nonrenderer?))] ...) (is-a?/c image-snip%)]
@defproc[(plot-frame [renderer-tree (treeof (or/c renderer2d? non-renderer?))] ...) (is-a?/c frame%)])]{ @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. 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. Use @(racket plot-file) to save a plot to a file.

View 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). 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?))] @defproc[(plot3d [renderer-tree (treeof (or/c renderer3d? nonrenderer?))]
[#:x-min x-min (or/c regular-real? #f) #f] [#:x-min x-min (or/c rational? #f) #f] [#:x-max x-max (or/c rational? #f) #f]
[#:x-max x-max (or/c regular-real? #f) #f] [#:y-min y-min (or/c rational? #f) #f] [#:y-max y-max (or/c rational? #f) #f]
[#:y-min y-min (or/c regular-real? #f) #f] [#:z-min z-min (or/c rational? #f) #f] [#:z-max z-max (or/c rational? #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]
[#:width width exact-positive-integer? (plot-width)] [#:width width exact-positive-integer? (plot-width)]
[#:height height exact-positive-integer? (plot-height)] [#:height height exact-positive-integer? (plot-height)]
[#:angle angle real? (plot3d-angle)] [#:angle angle real? (plot3d-angle)]
@ -43,14 +40,14 @@ The @(racket #:az) and @(racket #:alt) keyword arguments are backward-compatible
} }
@deftogether[ @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?)] [output (or/c path-string? output-port?)]
[kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto] [kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto]
[#:<plot-keyword> <plot-keyword> <plot-keyword-contract>] ...) void?] [#:<plot-keyword> <plot-keyword> <plot-keyword-contract>] ...) void?]
@defproc[(plot3d-pict [renderer-tree (treeof (or/c renderer3d? non-renderer?))] ...) pict?] @defproc[(plot3d-pict [renderer-tree (treeof (or/c renderer3d? nonrenderer?))] ...) pict?]
@defproc[(plot3d-bitmap [renderer-tree (treeof (or/c renderer3d? non-renderer?))] ...) (is-a?/c bitmap%)] @defproc[(plot3d-bitmap [renderer-tree (treeof (or/c renderer3d? nonrenderer?))] ...) (is-a?/c bitmap%)]
@defproc[(plot3d-snip [renderer-tree (treeof (or/c renderer3d? non-renderer?))] ...) (is-a?/c image-snip%)] @defproc[(plot3d-snip [renderer-tree (treeof (or/c renderer3d? nonrenderer?))] ...) (is-a?/c image-snip%)]
@defproc[(plot3d-frame [renderer-tree (treeof (or/c renderer3d? non-renderer?))] ...) (is-a?/c frame%)])]{ @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. 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). These procedures correspond with @(racket plot-file), @(racket plot-pict), @(racket plot-bitmap), @(racket plot-snip) and @(racket plot-frame).

View File

@ -137,9 +137,6 @@ Integer brush styles repeat starting at @(racket 7).
@subsection{Real Numbers} @subsection{Real Numbers}
@doc-apply[regular-real?]{
}
@doc-apply[degrees->radians]{ @doc-apply[degrees->radians]{
Converts degrees to 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.vectors"]{Vectors}
@subsection[#:tag "math.intervals"]{Intervals} @subsection[#:tag "math.intervals"]{Intervals}
@doc-apply[bounds->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} @subsection[#:tag "math.rectangles"]{Rectangles}
@section{Dates and Times} @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} @section{Sampling}
@defstruct[mapped-function ([f (any/c . -> . any/c)] [fmap ((listof any/c) . -> . (listof any/c))])]{ @defstruct[mapped-function ([f (any/c . -> . any/c)] [fmap ((listof any/c) . -> . (listof any/c))])]{

View File

@ -98,8 +98,8 @@
;; =================================================================================================== ;; ===================================================================================================
;; Intervals ;; Intervals
(check-false (ivl-regular? (ivl #f #f))) (check-false (ivl-rational? (ivl #f #f)))
(check-false (ivl-regular? (ivl +nan.0 +nan.0))) (check-false (ivl-rational? (ivl +nan.0 +nan.0)))
(check-true (ivl-empty? (ivl-meet empty-ivl (ivl 0 3)))) (check-true (ivl-empty? (ivl-meet empty-ivl (ivl 0 3))))