diff --git a/collects/plot/common/contract.rkt b/collects/plot/common/contract.rkt index e88210ad09..be93e9a1e7 100644 --- a/collects/plot/common/contract.rkt +++ b/collects/plot/common/contract.rkt @@ -75,13 +75,3 @@ (defcontract alphas/c (or/c (listof (real-in 0 1)) ((listof real?) . -> . (listof (real-in 0 1))))) - -(defcontract bounding-box-corner/c - (or/c (vector/c (or/c real? #f) (or/c real? #f)) - (vector/c (or/c real? #f) (or/c real? #f) (or/c real? #f)))) - -(defcontract bounds-function/c - (bounding-box-corner/c - bounding-box-corner/c - . -> . (values bounding-box-corner/c - bounding-box-corner/c))) diff --git a/collects/plot/common/math.rkt b/collects/plot/common/math.rkt index 41887f2a51..c30bb174b4 100644 --- a/collects/plot/common/math.rkt +++ b/collects/plot/common/math.rkt @@ -14,7 +14,7 @@ (defproc (infinite? [x any/c]) boolean? (and (flonum? x) (or (unsafe-fl= x +inf.0) (unsafe-fl= x -inf.0)))) -(defproc (special? [x any/c]) boolean? +(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? @@ -57,8 +57,8 @@ ;; =================================================================================================== ;; Reals -(defproc (regular? [x any/c]) boolean? - (and (real? x) (not (special? x)))) +(defproc (regular-real? [x any/c]) boolean? + (and (real? x) (not (special-real? x)))) (define equal?* (case-lambda @@ -197,6 +197,38 @@ ;; =================================================================================================== ;; Vectors +(define vector-andmap + (case-lambda + [(f v) (let/ec break + (for ([e (in-vector v)]) + (unless (f e) (break #f))) + #t)] + [(f v . vs) (define ns (cons (vector-length v) (map vector-length vs))) + (unless (apply equal?* ns) + (error 'vector-andmap "all vectors must have same size; arguments were ~e ~e ~e" + f v (string-join (map (λ (v) (format "~e" v)) vs) " "))) + (let/ec break + (define ess (apply map list (map vector->list vs))) + (for ([e (in-vector v)] [es (in-list ess)]) + (when (not (apply f e es)) (break #f))) + #t)])) + +(define vector-ormap + (case-lambda + [(f v) (let/ec break + (for ([e (in-vector v)]) + (when (f e) (break #t))) + #f)] + [(f v . vs) (define ns (cons (vector-length v) (map vector-length vs))) + (unless (apply equal?* ns) + (error 'vector-andmap "all vectors must have same size; arguments were ~e ~e ~e" + f v (string-join (map (λ (v) (format "~e" v)) vs) " "))) + (let/ec break + (define ess (apply map list (map vector->list vs))) + (for ([e (in-vector v)] [es (in-list ess)]) + (when (apply f e es) (break #t))) + #f)])) + (defproc (vcross [v1 (vector/c real? real? real?)] [v2 (vector/c real? real? real?)] ) (vector/c real? real? real?) (match v1 @@ -206,25 +238,25 @@ (vector (- (* y1 z2) (* z1 y2)) (- (* z1 x2) (* x1 z2)) (- (* x1 y2) (* y1 x2)))] - [_ (raise-type-error 'vcross "vector of 3 reals" 1 v1 v2)])] - [_ (raise-type-error 'vcross "vector of 3 reals" 0 v1 v2)])) + [_ (raise-type-error 'vcross "vector of 3 real numbers" 1 v1 v2)])] + [_ (raise-type-error 'vcross "vector of 3 real numbers" 0 v1 v2)])) (defproc (vcross2 [v1 (vector/c real? real?)] [v2 (vector/c real? real?)]) real? (match v1 [(vector (? real? x1) (? real? y1)) (match v2 [(vector (? real? x2) (? real? y2)) (- (* x1 y2) (* y1 x2))] - [_ (raise-type-error 'vcross "vector of 2 reals" 1 v1 v2)])] - [_ (raise-type-error 'vcross "vector of 2 reals" 0 v1 v2)])) + [_ (raise-type-error 'vcross "vector of 2 real numbers" 1 v1 v2)])] + [_ (raise-type-error 'vcross "vector of 2 real numbers" 0 v1 v2)])) (define-syntax-rule (vmap name f v) (let () (unless (vector? v) - (raise-type-error name "vector of reals" v)) + (raise-type-error name "vector of real numbers" v)) (define n (vector-length v)) (for/vector #:length n ([x (in-vector v)]) (cond [(real? x) (f x)] - [else (raise-type-error name "vector of real" v)])))) + [else (raise-type-error name "vector of real numbers" v)])))) (define-syntax-rule (unrolled-vmap name f v) (let () @@ -236,29 +268,29 @@ (define-syntax-rule (vmap2 name f v1 v2) (let () (unless (vector? v1) - (raise-type-error name "vector of reals" 0 v1 v2)) + (raise-type-error name "vector of real numbers" 0 v1 v2)) (unless (vector? v2) - (raise-type-error name "vector of reals" 1 v1 v2)) + (raise-type-error name "vector of real numbers" 1 v1 v2)) (define n (vector-length v1)) (unless (= n (vector-length v2)) - (raise-type-error name (format "vector of ~a reals" n) 1 v1 v2)) + (raise-type-error name (format "vector of ~a real numbers" n) 1 v1 v2)) (for/vector #:length n ([x (in-vector v1)] [y (in-vector v2)]) (if (real? x) (if (real? y) (f x y) - (raise-type-error name "vector of real" 1 v1 v2)) - (raise-type-error name "vector of real" 0 v1 v2))))) + (raise-type-error name "vector of real numbers" 1 v1 v2)) + (raise-type-error name "vector of real numbers" 0 v1 v2))))) (define-syntax-rule (unrolled-vmap2 name f v1 v2) (match v1 [(vector (? real? x1) (? real? y1)) (match v2 [(vector (? real? x2) (? real? y2)) (vector (f x1 x2) (f y1 y2))] - [_ (raise-type-error name "vector of 2 reals" 1 v1 v2)])] + [_ (raise-type-error name "vector of 2 real numbers" 1 v1 v2)])] [(vector (? real? x1) (? real? y1) (? real? z1)) (match v2 [(vector (? real? x2) (? real? y2) (? real? z2)) (vector (f x1 x2) (f y1 y2) (f z1 z2))] - [_ (raise-type-error name "vector of 3 reals" 1 v1 v2)])] + [_ (raise-type-error name "vector of 3 real numbers" 1 v1 v2)])] [_ (vmap2 name f v1 v2)])) (defproc (v+ [v1 (vectorof real?)] [v2 (vectorof real?)]) (vectorof real?) @@ -285,10 +317,10 @@ [(vector (? real? x) (? real? y)) (+ (* x x) (* y y))] [(vector (? real? x) (? real? y) (? real? z)) (+ (* x x) (* y y) (* z z))] [_ (unless (vector? v) - (raise-type-error 'vmag^2 "vector of reals" v)) + (raise-type-error 'vmag^2 "vector of real numbers" v)) (for/fold ([mag 0]) ([x (in-vector v)]) (+ mag (cond [(real? x) (* x x)] - [else (raise-type-error 'vmag^2 "vector of reals" v)])))])) + [else (raise-type-error 'vmag^2 "vector of real numbers" v)])))])) (defproc (vmag [v (vectorof real?)]) real? (sqrt (vmag^2 v))) @@ -307,19 +339,19 @@ [(vector (? real? x1) (? real? y1)) (match v2 [(vector (? real? x2) (? real? y2)) (+ (* x1 x2) (* y1 y2))] - [_ (raise-type-error 'vdot "vector of 2 reals" 1 v1 v2)])] + [_ (raise-type-error 'vdot "vector of 2 real numbers" 1 v1 v2)])] [(vector (? real? x1) (? real? y1) (? real? z1)) (match v2 [(vector (? real? x2) (? real? y2) (? real? z2)) (+ (* x1 x2) (* y1 y2) (* z1 z2))] - [_ (raise-type-error 'vdot "vector of 3 reals" 1 v1 v2)])] + [_ (raise-type-error 'vdot "vector of 3 real numbers" 1 v1 v2)])] [_ (unless (= (vector-length v1) (vector-length v2)) - (raise-type-error 'vdot (format "vector of ~a reals" (vector-length v1)) 1 v1 v2)) + (raise-type-error 'vdot (format "vector of ~a real numbers" (vector-length v1)) 1 v1 v2)) (for/fold ([dot 0]) ([x1 (in-vector v1)] [x2 (in-vector v2)]) (if (real? x1) (if (real? x2) (+ dot (* x1 x2)) - (raise-type-error 'vdot "vector of real" 1 v1 v2)) - (raise-type-error 'vdot "vector of real" 0 v1 v2)))])) + (raise-type-error 'vdot "vector of real numbers" 1 v1 v2)) + (raise-type-error 'vdot "vector of real numbers" 0 v1 v2)))])) (defproc (vcos-angle [v1 (vectorof real?)] [v2 (vectorof real?)]) real? (define d (vdot v1 v2)) @@ -343,31 +375,32 @@ [(flonum? y) (unsafe-flregular? y)] [(flonum? z) (unsafe-flregular? z)] [else #t])] - [_ (let/ec break - (for ([x (in-vector v)]) - (when (and (flonum? x) (unsafe-flspecial? x)) - (break #f))) - #t)])) + [_ (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? (match v1 [(vector (? real? x1) (? real? y1)) (match v2 [(vector (? real? x2) (? real? y2)) (and (= x1 x2) (= y1 y2))] - [_ (raise-type-error 'v= "vector of 2 reals" 1 v1 v2)])] + [_ (raise-type-error 'v= "vector of 2 real numbers" 1 v1 v2)])] [(vector (? real? x1) (? real? y1) (? real? z1)) (match v2 [(vector (? real? x2) (? real? y2) (? real? z2)) (and (= x1 x2) (= y1 y2) (= z1 z2))] - [_ (raise-type-error 'v= "vector of 3 reals" 1 v1 v2)])] + [_ (raise-type-error 'v= "vector of 3 real numbers" 1 v1 v2)])] [_ (unless (= (vector-length v1) (vector-length v2)) - (raise-type-error 'v= (format "vector of ~a reals" (vector-length v1)) 1 v1 v2)) + (raise-type-error 'v= (format "vector of ~a real numbers" (vector-length v1)) 1 v1 v2)) (let/ec break (for ([x1 (in-vector v1)] [x2 (in-vector v2)]) (if (real? x1) (if (real? x2) (unless (= x1 x2) (break #f)) - (raise-type-error 'v= "vector of real" 1 v1 v2)) - (raise-type-error 'v= "vector of real" 0 v1 v2))) + (raise-type-error 'v= "vector of real numbers" 1 v1 v2)) + (raise-type-error 'v= "vector of real numbers" 0 v1 v2))) #t)])) (defproc (vcenter [vs (listof (vectorof real?))]) (vectorof real?) @@ -455,7 +488,10 @@ (defproc (ivl-regular? [i ivl?]) boolean? (match-define (ivl a b) i) - (and (regular? a) (regular? b))) + (and (regular-real? a) (regular-real? b))) + +(defproc (regular-ivl? [i any/c]) boolean? + (and (ivl? i) (ivl-regular? i))) (defproc (ivl-singular? [i ivl?]) boolean? (match-define (ivl a b) i) @@ -515,38 +551,6 @@ ;; =================================================================================================== ;; Rectangles -(define vector-andmap - (case-lambda - [(f v) (let/ec break - (for ([e (in-vector v)]) - (unless (f e) (break #f))) - #t)] - [(f v . vs) (define ns (cons (vector-length v) (map vector-length vs))) - (unless (apply equal?* ns) - (error 'vector-andmap "all vectors must have same size; arguments were ~e ~e ~e" - f v (string-join (map (λ (v) (format "~e" v)) vs) " "))) - (let/ec break - (define ess (apply map list (map vector->list vs))) - (for ([e (in-vector v)] [es (in-list ess)]) - (when (not (apply f e es)) (break #f))) - #t)])) - -(define vector-ormap - (case-lambda - [(f v) (let/ec break - (for ([e (in-vector v)]) - (when (f e) (break #t))) - #f)] - [(f v . vs) (define ns (cons (vector-length v) (map vector-length vs))) - (unless (apply equal?* ns) - (error 'vector-andmap "all vectors must have same size; arguments were ~e ~e ~e" - f v (string-join (map (λ (v) (format "~e" v)) vs) " "))) - (let/ec break - (define ess (apply map list (map vector->list vs))) - (for ([e (in-vector v)] [es (in-list ess)]) - (when (apply f e es) (break #t))) - #f)])) - (defproc (empty-rect [n exact-nonnegative-integer?]) (vectorof ivl?) (make-vector n empty-ivl)) diff --git a/collects/plot/common/non-renderer.rkt b/collects/plot/common/non-renderer.rkt index 32396a032a..0d4d2e2376 100644 --- a/collects/plot/common/non-renderer.rkt +++ b/collects/plot/common/non-renderer.rkt @@ -35,11 +35,13 @@ (defproc (z-ticks [ts (listof tick?)] [#:far? far? boolean? #f]) non-renderer? (non-renderer #f #f (z-ticks-fun ts far?))) -(defproc (invisible-box [x-min (or/c real? #f)] [x-max (or/c real? #f)] - [y-min (or/c real? #f)] [y-max (or/c real? #f)]) non-renderer? +(defproc (invisible-box [x-min (or/c regular-real? #f)] [x-max (or/c regular-real? #f)] + [y-min (or/c regular-real? #f)] [y-max (or/c regular-real? #f)] + ) non-renderer? (non-renderer (vector (ivl x-min x-max) (ivl y-min y-max)) #f #f)) -(defproc (invisible-box3d [x-min (or/c real? #f)] [x-max (or/c real? #f)] - [y-min (or/c real? #f)] [y-max (or/c real? #f)] - [z-min (or/c real? #f)] [z-max (or/c real? #f)]) non-renderer? +(defproc (invisible-box3d [x-min (or/c regular-real? #f)] [x-max (or/c regular-real? #f)] + [y-min (or/c regular-real? #f)] [y-max (or/c regular-real? #f)] + [z-min (or/c regular-real? #f)] [z-max (or/c regular-real? #f)] + ) non-renderer? (non-renderer (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) #f #f)) diff --git a/collects/plot/common/sample.rkt b/collects/plot/common/sample.rkt index 74dc285c29..6f9dda8892 100644 --- a/collects/plot/common/sample.rkt +++ b/collects/plot/common/sample.rkt @@ -9,7 +9,8 @@ (provide (all-defined-out)) -(defproc (build-linear-seq [start real?] [step real?] [num exact-nonnegative-integer?]) (listof real?) +(defproc (build-linear-seq [start real?] [step real?] + [num exact-nonnegative-integer?]) (listof real?) (for/list ([n (in-range num)]) (+ start (* n step)))) @@ -96,7 +97,7 @@ (λ () (define xs (nonlinear-seq x-min x-max x-samples tx)) (define ys (map* f xs)) - (define rys (filter regular? ys)) + (define rys (filter regular-real? ys)) (define-values (y-min y-max) (cond [(empty? rys) (values #f #f)] [else (values (apply min* rys) (apply max* rys))])) @@ -119,7 +120,7 @@ (define zss (for/vector #:length y-samples ([y (in-list ys)]) (for/vector #:length x-samples ([x (in-list xs)]) (let ([z (f x y)]) - (when (regular? z) + (when (regular-real? z) (unless (and z-min (z . >= . z-min)) (set! z-min z)) (unless (and z-max (z . <= . z-max)) (set! z-max z))) z)))) @@ -148,7 +149,7 @@ (for/vector #:length y-samples ([y (in-list ys)]) (for/vector #:length x-samples ([x (in-list xs)]) (let ([d (f x y z)]) - (when (regular? d) + (when (regular-real? d) (unless (and d-min (d . >= . d-min)) (set! d-min d)) (unless (and d-max (d . <= . d-max)) (set! d-max d))) d))))) diff --git a/collects/plot/contracted/math.rkt b/collects/plot/contracted/math.rkt index 1715977c2d..40e104d18f 100644 --- a/collects/plot/contracted/math.rkt +++ b/collects/plot/contracted/math.rkt @@ -5,10 +5,10 @@ (require "../common/math.rkt") (provide equal?* ;; Flonums - nan? infinite? special? + nan? infinite? special-real? flblend flatan2 flsum flmodulo fldistance ;; Reals - regular? + regular-real? min* max* degrees->radians radians->degrees blend atan2 sum real-modulo distance floor-log/base ceiling-log/base polar->cartesian 3d-polar->3d-cartesian @@ -19,7 +19,7 @@ (provide (contract-out (struct ivl ([min (or/c real? #f)] [max (or/c real? #f)])) [ivl-meet (->* () () #:rest (listof ivl?) ivl?)] [ivl-join (->* () () #:rest (listof ivl?) ivl?)]) - empty-ivl unknown-ivl + empty-ivl unknown-ivl regular-ivl? (activate-contract-out ivl-empty? ivl-known? ivl-regular? ivl-singular? ivl-length ivl-center ivl-zero-length? ivl-inexact->exact ivl-contains? bounds->intervals)) diff --git a/collects/plot/contracted/sample.rkt b/collects/plot/contracted/sample.rkt index 02da226644..c48b9cd9cb 100644 --- a/collects/plot/contracted/sample.rkt +++ b/collects/plot/contracted/sample.rkt @@ -2,22 +2,23 @@ (require racket/contract unstable/latent-contract) -(require "../common/sample.rkt") +(require "../common/sample.rkt" + "../common/math.rkt") (provide (contract-out (struct sample ([xs (listof real?)] [ys (listof real?)] - [y-min (or/c real? #f)] - [y-max (or/c real? #f)])) + [y-min (or/c regular-real? #f)] + [y-max (or/c regular-real? #f)])) (struct 2d-sample ([xs (listof real?)] [ys (listof real?)] [zss (vectorof (vectorof real?))] - [z-min (or/c real? #f)] - [z-max (or/c real? #f)])) + [z-min (or/c regular-real? #f)] + [z-max (or/c regular-real? #f)])) (struct 3d-sample ([xs (listof real?)] [ys (listof real?)] [zs (listof real?)] [dsss (vectorof (vectorof (vectorof real?)))] - [d-min (or/c real? #f)] - [d-max (or/c real? #f)]))) + [d-min (or/c regular-real? #f)] + [d-max (or/c regular-real? #f)]))) (activate-contract-out build-linear-seq linear-seq linear-seq* nonlinear-seq sampler/c 2d-sampler/c 3d-sampler/c make-function->sampler diff --git a/collects/plot/plot2d/contour.rkt b/collects/plot/plot2d/contour.rkt index 50a4479447..7ff7c8db6c 100644 --- a/collects/plot/plot2d/contour.rkt +++ b/collects/plot/plot2d/contour.rkt @@ -40,8 +40,10 @@ (defproc (isoline [f (real? real? . -> . real?)] [z real?] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)] [#:color color plot-color/c (line-color)] [#:width width (>=/c 0) (line-width)] @@ -96,8 +98,10 @@ (defproc (contours [f (real? real? . -> . real?)] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] [#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)] [#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)] [#:colors colors plot-colors/c (contour-colors)] @@ -180,8 +184,10 @@ (defproc (contour-intervals [f (real? real? . -> . real?)] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] [#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)] [#:samples samples (and/c exact-integer? (>=/c 2)) (contour-samples)] [#:colors colors plot-colors/c (contour-interval-colors)] diff --git a/collects/plot/plot2d/interval.rkt b/collects/plot/plot2d/interval.rkt index ddf249ba1e..81ca37ce0f 100644 --- a/collects/plot/plot2d/interval.rkt +++ b/collects/plot/plot2d/interval.rkt @@ -35,8 +35,10 @@ (defproc (lines-interval [v1s (listof (vector/c real? real?))] [v2s (listof (vector/c real? real?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:style style plot-brush-style/c (interval-style)] [#:line1-color line1-color plot-color/c (interval-line1-color)] @@ -67,8 +69,10 @@ [f1 (real? . -> . (vector/c real? real?))] [f2 (real? . -> . (vector/c real? real?))] [t-min real?] [t-max real?] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:color color plot-color/c (interval-color)] [#:style style plot-brush-style/c (interval-style)] @@ -93,8 +97,10 @@ (defproc (polar-interval [f1 (real? . -> . real?)] [f2 (real? . -> . real?)] [θ-min real? 0] [θ-max real? (* 2 pi)] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:color color plot-color/c (interval-color)] [#:style style plot-brush-style/c (interval-style)] @@ -139,8 +145,10 @@ (defproc (function-interval [f1 (real? . -> . real?)] [f2 (real? . -> . real?)] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:color color plot-color/c (interval-color)] [#:style style plot-brush-style/c (interval-style)] @@ -185,8 +193,10 @@ (defproc (inverse-interval [f1 (real? . -> . real?)] [f2 (real? . -> . real?)] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:color color plot-color/c (interval-color)] [#:style style plot-brush-style/c (interval-style)] diff --git a/collects/plot/plot2d/kde.rkt b/collects/plot/plot2d/kde.rkt index 3495221d38..2e9c828e94 100644 --- a/collects/plot/plot2d/kde.rkt +++ b/collects/plot/plot2d/kde.rkt @@ -82,8 +82,8 @@ (define series-terms 9) (defproc (kde [xs (listof real?)] [h real?]) (values mapped-function? - (or/c real? #f) - (or/c real? #f)) + (or/c regular-real? #f) + (or/c regular-real? #f)) (if (empty? xs) (values (mapped-function (λ (y) 0) (λ (ys) (map (λ _ 0.0) ys))) #f #f) (let* ([xs (list->vector (sort (map exact->inexact xs) fl<))] @@ -132,8 +132,10 @@ (values (mapped-function (λ (x) (first (fmap (list x)))) fmap) x-min x-max)))) (defproc (density [xs (listof real?)] [bw-adjust real? 1] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:color color plot-color/c (line-color)] [#:width width (>=/c 0) (line-width)] diff --git a/collects/plot/plot2d/line.rkt b/collects/plot/plot2d/line.rkt index ff4560ce58..37bd3138b9 100644 --- a/collects/plot/plot2d/line.rkt +++ b/collects/plot/plot2d/line.rkt @@ -20,8 +20,10 @@ [else empty])) (defproc (lines [vs (listof (vector/c real? real?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:width width (>=/c 0) (line-width)] [#:style style plot-pen-style/c (line-style)] @@ -40,9 +42,11 @@ (lines-render-proc vs color width style alpha label)))])) (defproc (parametric [f (real? . -> . (vector/c real? real?))] - [t-min real?] [t-max real?] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [t-min regular-real?] [t-max regular-real?] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:color color plot-color/c (line-color)] [#:width width (>=/c 0) (line-width)] @@ -57,8 +61,10 @@ (defproc (polar [f (real? . -> . real?)] [θ-min real? 0] [θ-max real? (* 2 pi)] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:color color plot-color/c (line-color)] [#:width width (>=/c 0) (line-width)] @@ -87,8 +93,10 @@ [else empty])) (defproc (function [f (real? . -> . real?)] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:color color plot-color/c (line-color)] [#:width width (>=/c 0) (line-width)] @@ -117,8 +125,10 @@ [else empty])) (defproc (inverse [f (real? . -> . real?)] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:color color plot-color/c (line-color)] [#:width width (>=/c 0) (line-width)] diff --git a/collects/plot/plot2d/plot.rkt b/collects/plot/plot2d/plot.rkt index 8eab65d4a2..fc9f1aa400 100644 --- a/collects/plot/plot2d/plot.rkt +++ b/collects/plot/plot2d/plot.rkt @@ -27,10 +27,10 @@ (defproc (plot/dc [renderer-tree (treeof (or/c renderer2d? non-renderer?))] [dc (is-a?/c dc<%>)] [x real?] [y real?] [width (>=/c 0)] [height (>=/c 0)] - [#:x-min x-min (or/c real? #f) #f] - [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] - [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:x-label x-label (or/c string? #f) (plot-x-label)] [#:y-label y-label (or/c string? #f) (plot-y-label)] @@ -89,8 +89,10 @@ ;; Plot to a bitmap (defproc (plot-bitmap [renderer-tree (treeof (or/c renderer2d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:height height exact-positive-integer? (plot-height)] [#:title title (or/c string? #f) (plot-title)] @@ -106,8 +108,10 @@ bm) (defproc (plot-pict [renderer-tree (treeof (or/c renderer2d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:height height exact-positive-integer? (plot-height)] [#:title title (or/c string? #f) (plot-title)] @@ -126,8 +130,10 @@ ;; Plot to a snip (defproc (plot-snip [renderer-tree (treeof (or/c renderer2d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:height height exact-positive-integer? (plot-height)] [#:title title (or/c string? #f) (plot-title)] @@ -144,8 +150,10 @@ ;; Plot to a frame (defproc (plot-frame [renderer-tree (treeof (or/c renderer2d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:height height exact-positive-integer? (plot-height)] [#:title title (or/c string? #f) (plot-title)] @@ -164,8 +172,10 @@ (defproc (plot-file [renderer-tree (treeof (or/c renderer2d? non-renderer?))] [output (or/c path-string? output-port?)] [kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:height height exact-positive-integer? (plot-height)] [#:title title (or/c string? #f) (plot-title)] @@ -205,8 +215,10 @@ ;; Plot to a frame or a snip, depending on (plot-new-window?) (defproc (plot [renderer-tree (treeof (or/c renderer2d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:height height exact-positive-integer? (plot-height)] [#:title title (or/c string? #f) (plot-title)] diff --git a/collects/plot/plot2d/point.rkt b/collects/plot/plot2d/point.rkt index 6623dfa81c..dac7624ed0 100644 --- a/collects/plot/plot2d/point.rkt +++ b/collects/plot/plot2d/point.rkt @@ -19,8 +19,10 @@ (if label (point-legend-entry label sym color size line-width) empty)) (defproc (points [vs (listof (vector/c real? real?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:color color plot-color/c (point-color)] [#:size size (>=/c 0) (point-size)] @@ -86,8 +88,10 @@ (defproc (vector-field [f (or/c (real? real? . -> . (vector/c real? real?)) ((vector/c real? real?) . -> . (vector/c real? real?)))] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] [#:samples samples exact-positive-integer? (vector-field-samples)] [#:scale scale (or/c real? (one-of/c 'auto 'normalized)) (vector-field-scale)] [#:color color plot-color/c (vector-field-color)] @@ -122,8 +126,10 @@ (defproc (error-bars [bars (listof (vector/c real? real? real?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:line-width line-width (>=/c 0) (error-bar-line-width)] [#:line-style line-style plot-pen-style/c (error-bar-line-style)] diff --git a/collects/plot/plot2d/rectangle.rkt b/collects/plot/plot2d/rectangle.rkt index f8e3db03a3..4f8566b84f 100644 --- a/collects/plot/plot2d/rectangle.rkt +++ b/collects/plot/plot2d/rectangle.rkt @@ -25,8 +25,10 @@ (defproc (rectangles [rects (listof (vector/c ivl? ivl?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] [#:color color plot-color/c (rectangle-color)] [#:style style plot-brush-style/c (rectangle-style)] [#:line-color line-color plot-color/c (rectangle-line-color)] @@ -36,8 +38,8 @@ [#:label label (or/c string? #f) #f] ) renderer2d? (match-define (list (vector (ivl x1s x2s) (ivl y1s y2s)) ...) rects) - (define rxs (filter regular? (append x1s x2s))) - (define rys (filter regular? (append y1s y2s))) + (define rxs (filter regular-real? (append x1s x2s))) + (define rys (filter regular-real? (append y1s y2s))) (cond [(or (empty? rxs) (empty? rys)) (renderer2d #f #f #f #f)] [else @@ -55,8 +57,10 @@ (defproc (area-histogram [f (real? . -> . real?)] [bin-bounds (listof real?)] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) 0] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) 0] + [#:y-max y-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:color color plot-color/c (rectangle-color)] [#:style style plot-brush-style/c (rectangle-style)] @@ -66,7 +70,7 @@ [#:alpha alpha (real-in 0 1) (rectangle-alpha)] [#:label label (or/c string? #f) #f] ) renderer2d? - (let* ([bin-bounds (filter regular? bin-bounds)] + (let* ([bin-bounds (filter regular-real? bin-bounds)] [bin-bounds (sort bin-bounds <)]) (cond [((length bin-bounds) . < . 2) (renderer2d #f #f #f #f)] @@ -100,8 +104,10 @@ (defproc (discrete-histogram [cat-vals (listof (vector/c any/c real?))] - [#:x-min x-min (or/c real? #f) 0] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) 0] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) 0] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) 0] + [#:y-max y-max (or/c regular-real? #f) #f] [#:gap gap (real-in 0 1) (discrete-histogram-gap)] [#:color color plot-color/c (rectangle-color)] [#:style style plot-brush-style/c (rectangle-style)] @@ -113,7 +119,7 @@ [#:far-ticks? far-ticks? boolean? #f] ) renderer2d? (match-define (list (vector cats ys) ...) cat-vals) - (define rys (filter regular? ys)) + (define rys (filter regular-real? ys)) (cond [(empty? rys) (renderer2d #f #f #f #f)] [else diff --git a/collects/plot/plot3d/contour.rkt b/collects/plot/plot3d/contour.rkt index 2adb0f8e3a..fd59b2227b 100644 --- a/collects/plot/plot3d/contour.rkt +++ b/collects/plot/plot3d/contour.rkt @@ -43,9 +43,12 @@ (defproc (contour3d [f (real? real? . -> . real?)] [z real?] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:color color plot-color/c (line-color)] [#:width width (>=/c 0) (line-width)] @@ -105,9 +108,12 @@ (defproc (contours3d [f (real? real? . -> . real?)] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:colors colors plot-colors/c (contour-colors)] @@ -179,9 +185,12 @@ (defproc (contour-intervals3d [f (real? real? . -> . real?)] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (contour-levels)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:colors colors plot-colors/c (contour-interval-colors)] diff --git a/collects/plot/plot3d/isosurface.rkt b/collects/plot/plot3d/isosurface.rkt index be65ac5059..640602d8cd 100644 --- a/collects/plot/plot3d/isosurface.rkt +++ b/collects/plot/plot3d/isosurface.rkt @@ -64,9 +64,12 @@ [else empty])) (defproc (isosurface3d [f (real? real? real? . -> . real?)] [d real?] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] - [z-min (or/c real? #f) #f] [z-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] + [z-min (or/c regular-real? #f) #f] + [z-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:color color plot-color/c (surface-color)] [#:line-color line-color plot-color/c (surface-line-color)] @@ -150,10 +153,14 @@ [else empty])])) (defproc (isosurfaces3d [f (real? real? real? . -> . real?)] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] - [z-min (or/c real? #f) #f] [z-max (or/c real? #f) #f] - [#:d-min d-min (or/c real? #f) #f] [#:d-max d-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] + [z-min (or/c regular-real? #f) #f] + [z-max (or/c regular-real? #f) #f] + [#:d-min d-min (or/c regular-real? #f) #f] + [#:d-max d-max (or/c regular-real? #f) #f] [#:levels levels (or/c 'auto exact-positive-integer? (listof real?)) (isosurface-levels)] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] @@ -248,9 +255,12 @@ (fl- (exact->inexact (f θ ρ)) (distance x y z)))) (defproc (polar3d [f (real? real? . -> . real?)] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:color color plot-color/c (surface-color)] [#:line-color line-color plot-color/c (surface-line-color)] diff --git a/collects/plot/plot3d/line.rkt b/collects/plot/plot3d/line.rkt index 2df546d1fa..657b561cb8 100644 --- a/collects/plot/plot3d/line.rkt +++ b/collects/plot/plot3d/line.rkt @@ -34,9 +34,12 @@ (defproc (lines3d [vs (listof (vector/c real? real? real?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:color color plot-color/c (line-color)] [#:width width (>=/c 0) (line-width)] [#:style style plot-pen-style/c (line-style)] @@ -47,10 +50,13 @@ (defproc (parametric3d [f (real? . -> . (vector/c real? real? real?))] - [t-min real?] [t-max real?] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [t-min regular-real?] [t-max regular-real?] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (line-samples)] [#:color color plot-color/c (line-color)] [#:width width (>=/c 0) (line-width)] diff --git a/collects/plot/plot3d/plot.rkt b/collects/plot/plot3d/plot.rkt index 870ca26315..9960c0ccb6 100644 --- a/collects/plot/plot3d/plot.rkt +++ b/collects/plot/plot3d/plot.rkt @@ -28,9 +28,12 @@ (defproc (plot3d/dc [renderer-tree (treeof (or/c renderer3d? non-renderer?))] [dc (is-a?/c dc<%>)] [x real?] [y real?] [width (>=/c 0)] [height (>=/c 0)] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:angle angle real? (plot3d-angle)] [#:altitude altitude real? (plot3d-altitude)] [#:title title (or/c string? #f) (plot-title)] [#:x-label x-label (or/c string? #f) (plot-x-label)] @@ -108,9 +111,12 @@ ;; Plot to a bitmap (defproc (plot3d-bitmap [renderer-tree (treeof (or/c renderer3d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:width width exact-positive-integer? (plot-width)] [#:height height exact-positive-integer? (plot-height)] [#:angle angle real? (plot3d-angle)] @@ -130,9 +136,12 @@ bm) (defproc (plot3d-pict [renderer-tree (treeof (or/c renderer3d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:width width exact-positive-integer? (plot-width)] [#:height height exact-positive-integer? (plot-height)] [#:angle angle real? (plot3d-angle)] @@ -155,9 +164,12 @@ ;; Plot to a snip (defproc (plot3d-snip [renderer-tree (treeof (or/c renderer3d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:width width exact-positive-integer? (plot-width)] [#:height height exact-positive-integer? (plot-height)] [#:angle angle real? (plot3d-angle)] @@ -180,9 +192,12 @@ ;; Plot to a frame (defproc (plot3d-frame [renderer-tree (treeof (or/c renderer3d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:width width exact-positive-integer? (plot-width)] [#:height height exact-positive-integer? (plot-height)] [#:angle angle real? (plot3d-angle)] @@ -205,9 +220,12 @@ (defproc (plot3d-file [renderer-tree (treeof (or/c renderer3d? non-renderer?))] [output (or/c path-string? output-port?)] [kind (one-of/c 'auto 'png 'jpeg 'xmb 'xpm 'bmp 'ps 'pdf 'svg) 'auto] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:width width exact-positive-integer? (plot-width)] [#:height height exact-positive-integer? (plot-height)] [#:angle angle real? (plot3d-angle)] @@ -252,9 +270,12 @@ ;; Plot to a frame or a snip, depending on the value of plot-new-window? (defproc (plot3d [renderer-tree (treeof (or/c renderer3d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:width width exact-positive-integer? (plot-width)] [#:height height exact-positive-integer? (plot-height)] [#:angle angle real? #f] [#:altitude altitude real? #f] diff --git a/collects/plot/plot3d/point.rkt b/collects/plot/plot3d/point.rkt index a2c9912872..6976c168c2 100644 --- a/collects/plot/plot3d/point.rkt +++ b/collects/plot/plot3d/point.rkt @@ -18,9 +18,12 @@ (defproc (points3d [vs (listof (vector/c real? real? real?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:sym sym point-sym/c (point-sym)] [#:color color plot-color/c (point-color)] [#:size size (>=/c 0) (point-size)] diff --git a/collects/plot/plot3d/rectangle.rkt b/collects/plot/plot3d/rectangle.rkt index 3a88495ead..1ba0c8129b 100644 --- a/collects/plot/plot3d/rectangle.rkt +++ b/collects/plot/plot3d/rectangle.rkt @@ -24,9 +24,12 @@ (defproc (rectangles3d [rects (listof (vector/c ivl? ivl? ivl?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:color color plot-color/c (rectangle-color)] [#:style style plot-brush-style/c (rectangle-style)] [#:line-color line-color plot-color/c (rectangle-line-color)] @@ -36,9 +39,9 @@ [#:label label (or/c string? #f) #f] ) renderer3d? (match-define (list (vector (ivl x1s x2s) (ivl y1s y2s) (ivl z1s z2s)) ...) rects) - (define rxs (filter regular? (append x1s x2s))) - (define rys (filter regular? (append y1s y2s))) - (define rzs (filter regular? (append z1s z2s))) + (define rxs (filter regular-real? (append x1s x2s))) + (define rys (filter regular-real? (append y1s y2s))) + (define rzs (filter regular-real? (append z1s z2s))) (cond [(or (empty? rxs) (empty? rys) (empty? rzs)) (renderer3d #f #f #f #f)] [else @@ -77,9 +80,12 @@ (defproc (discrete-histogram3d [cat-vals (listof (vector/c any/c any/c real?))] - [#:x-min x-min (or/c real? #f) 0] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) 0] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) 0] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) 0] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) 0] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) 0] + [#:z-max z-max (or/c regular-real? #f) #f] [#:gap gap (real-in 0 1) (discrete-histogram-gap)] [#:color color plot-color/c (rectangle-color)] [#:style style plot-brush-style/c (rectangle-style)] @@ -92,7 +98,7 @@ [#:y-far-ticks? y-far-ticks? boolean? #f] ) renderer3d? (match-define (list (vector cat1s cat2s zs) ...) cat-vals) - (define rzs (filter regular? zs)) + (define rzs (filter regular-real? zs)) (cond [(empty? rzs) (renderer3d #f #f #f #f)] [else diff --git a/collects/plot/plot3d/surface.rkt b/collects/plot/plot3d/surface.rkt index 5ff83e1ea4..42c6f0fa4a 100644 --- a/collects/plot/plot3d/surface.rkt +++ b/collects/plot/plot3d/surface.rkt @@ -37,9 +37,12 @@ (defproc (surface3d [f (real? real? . -> . real?)] - [x-min (or/c real? #f) #f] [x-max (or/c real? #f) #f] - [y-min (or/c real? #f) #f] [y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [x-min (or/c regular-real? #f) #f] + [x-max (or/c regular-real? #f) #f] + [y-min (or/c regular-real? #f) #f] + [y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:samples samples (and/c exact-integer? (>=/c 2)) (plot3d-samples)] [#:color color plot-color/c (surface-color)] [#:style style plot-brush-style/c (surface-style)] diff --git a/collects/plot/scribblings/plot2d.scrbl b/collects/plot/scribblings/plot2d.scrbl index d67f0a7220..18f58207b5 100644 --- a/collects/plot/scribblings/plot2d.scrbl +++ b/collects/plot/scribblings/plot2d.scrbl @@ -8,8 +8,10 @@ @title[#:tag "plot2d"]{2D Plot Procedures} @defproc[(plot [renderer-tree (treeof (or/c renderer2d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min 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)] [#:height height exact-positive-integer? (plot-height)] [#:title title (or/c string? #f) (plot-title)] diff --git a/collects/plot/scribblings/plot3d.scrbl b/collects/plot/scribblings/plot3d.scrbl index 5201d541f5..6e786a6c55 100644 --- a/collects/plot/scribblings/plot3d.scrbl +++ b/collects/plot/scribblings/plot3d.scrbl @@ -9,9 +9,12 @@ Each 3D plot procedure corresponds with a @(secref "plot2d") procedure. Each behaves the same way as its corresponding 2D procedure, but takes the additional keyword arguments @(racket #:z-min), @(racket #:z-max), @(racket #:angle), @(racket #:altitude) and @(racket #:z-label). @defproc[(plot3d [renderer-tree (treeof (or/c renderer3d? non-renderer?))] - [#:x-min x-min (or/c real? #f) #f] [#:x-max x-max (or/c real? #f) #f] - [#:y-min y-min (or/c real? #f) #f] [#:y-max y-max (or/c real? #f) #f] - [#:z-min z-min (or/c real? #f) #f] [#:z-max z-max (or/c real? #f) #f] + [#:x-min x-min (or/c regular-real? #f) #f] + [#:x-max x-max (or/c regular-real? #f) #f] + [#:y-min y-min (or/c regular-real? #f) #f] + [#:y-max y-max (or/c regular-real? #f) #f] + [#:z-min z-min (or/c regular-real? #f) #f] + [#:z-max z-max (or/c regular-real? #f) #f] [#:width width exact-positive-integer? (plot-width)] [#:height height exact-positive-integer? (plot-height)] [#:angle angle real? (plot3d-angle)]