diff --git a/collects/plot/tests/isosurface-tests.rkt b/collects/plot/tests/isosurface-tests.rkt new file mode 100644 index 0000000000..e5a4fa234e --- /dev/null +++ b/collects/plot/tests/isosurface-tests.rkt @@ -0,0 +1,50 @@ +#lang racket + +(require plot plot/utils) + +(time + (plot3d (isosurface3d (λ (x y z) (sqrt (+ (sqr x) (sqr y) (sqr z)))) 1 + #:color 2 #:line-color (->brush-color 2) #:line-width 1 + #:label "Sphere") + #:x-min -0.8 #:x-max 0.8 + #:y-min -0.8 #:y-max 0.8 + #:z-min -0.8 #:z-max 0.8 + #:altitude 30 + #:legend-anchor 'center)) + +(time + (define saddle (λ (x y z) (- (sqr x) (* 1/2 (+ (sqr y) (sqr z)))))) + (plot3d (isosurfaces3d saddle #:d-min -1 #:d-max 1 #:label "d") + #:x-min -2 #:x-max 2 + #:y-min -2 #:y-max 2 + #:z-min -2 #:z-max 2 + #:legend-anchor 'top-left)) + +(time + (define saddle (λ (x y z) (- (sqr x) (* 1/2 (+ (sqr y) (sqr z)))))) + (plot3d (isosurfaces3d saddle #:d-min -1 #:d-max 1 + #:colors '(1 2 3) + #:line-colors '(1 2 3) + #:line-styles '(solid) + #:alphas '(3/4) + #:label "d") + #:x-min -2 #:x-max 2 + #:y-min -2 #:y-max 2 + #:z-min -2 #:z-max 2 + #:legend-anchor 'top-left)) + +(time + (define saddle (λ (x y z) (- (sqr x) (* 1/2 (+ (sqr y) (sqr z)))))) + (plot3d (isosurface3d saddle -1/4 #:color 0 #:line-color 0 #:alpha 7/8 + #:label "d = -1/4") + #:x-min -2 #:x-max 2 + #:y-min -2 #:y-max 2 + #:z-min -2 #:z-max 2)) + +(time + (define (f1 θ ρ) (+ 1 (/ θ 2 pi) (* 1/8 (sin (* 8 ρ))))) + (define (f2 θ ρ) (+ 0 (/ θ 2 pi) (* 1/8 (sin (* 8 ρ))))) + + (plot3d (list (polar3d f1 #:samples 41 #:color "navajowhite" #:line-style 'transparent #:alpha 2/3) + (polar3d f2 #:samples 41 #:color "navajowhite" #:line-style 'transparent #:alpha 2/3)) + #:title "A Seashell" #:x-label #f #:y-label #f)) diff --git a/collects/plot/tests/out-file-tests.rkt b/collects/plot/tests/out-file-tests.rkt new file mode 100644 index 0000000000..978b20af10 --- /dev/null +++ b/collects/plot/tests/out-file-tests.rkt @@ -0,0 +1,50 @@ +#lang racket + +(require plot plot/utils) + +(define (norm mx my x y) + (exp (* -1/2 (+ (sqr (- x mx)) (sqr (- y my)))))) + +(define (f x y) + (+ (* 1.1 (norm -1.5 -1.5 x y)) + (* 2 (norm 1 1 x y)) + (* 1.3 (norm 2 -2 x y)))) + +(parameterize ([plot-title "Survival Rate of Torsion Widgets"] + [plot-x-label "Torsion"] + [plot-y-label "Widgetyness"]) + (time + (plot (contour-intervals f #:alphas '(0.5)) + #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 + #:out-file "contour-test.png")) + + (time + (plot (contour-intervals f) + #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 + #:out-file "contour-test.ps")) + + (time + (plot (contour-intervals f #:alphas '(0.5)) + #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 + #:out-file "contour-test.pdf")) + + (time + (plot (contour-intervals f) + #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 + #:out-file "contour-test.svg"))) + +(time + (plot3d (contour-intervals3d f -5 5 -5 5 #:alphas '(1/4 3/4)) + #:out-file "contour3d-test.pdf")) + +(time + (plot3d (contour-intervals3d f -5 5 -5 5 #:alphas '(1/4 3/4)) + #:out-file "contour3d-test.ps")) + +(time + (plot3d (contour-intervals3d f -5 5 -5 5 #:alphas '(1/4 3/4)) + #:out-file "contour3d-test.svg")) + +(time + (plot3d (contour-intervals3d f -5 5 -5 5 #:alphas '(1/4 3/4)) + #:out-file "contour3d-test.png")) diff --git a/collects/plot/tests/plot2d-tests.rkt b/collects/plot/tests/plot2d-tests.rkt index c7165bd497..ee1ad33296 100644 --- a/collects/plot/tests/plot2d-tests.rkt +++ b/collects/plot/tests/plot2d-tests.rkt @@ -285,29 +285,6 @@ (time (plot (contour-intervals f) #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5))) -(parameterize ([plot-title "Survival Rate of Torsion Widgets"] - [plot-x-label "Torsion"] - [plot-y-label "Widgetyness"]) - (time - (plot (contour-intervals f1 #:alphas '(0.5)) - #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 - #:out-file "contour-test.png")) - - (time - (plot (contour-intervals f1) - #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 - #:out-file "contour-test.ps")) - - (time - (plot (contour-intervals f1 #:alphas '(0.5)) - #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 - #:out-file "contour-test.pdf")) - - (time - (plot (contour-intervals f1) - #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5 - #:out-file "contour-test.svg"))) - (time (define (f2 x) (sin (* x pi))) (plot (list (x-tick-lines) diff --git a/collects/plot/tests/plot3d-tests.rkt b/collects/plot/tests/plot3d-tests.rkt index d70a506e05..6adaa7879f 100644 --- a/collects/plot/tests/plot3d-tests.rkt +++ b/collects/plot/tests/plot3d-tests.rkt @@ -1,7 +1,6 @@ #lang racket -(require "../main.rkt" - "../utils.rkt") +(require plot plot/utils) ;(plot-new-window? #t) @@ -14,6 +13,10 @@ [plot-foreground-alpha 1/2]) (plot3d (surface3d (λ (x y) (* (sin x) (sin y))) -2 2 -2 2 #:label "z = trig(x,y)"))) +(time + (plot3d (points3d '(#(0.1 0.6 0.3))) + #:x-min 0 #:x-max 1 #:y-min 0 #:y-max 1 #:z-min 0 #:z-max 1)) + (time (define x-ivls (bounds->intervals (linear-seq 2 8 10))) (define y-ivls (bounds->intervals (linear-seq -5 5 10))) @@ -133,7 +136,6 @@ (points3d (map vector xs ys zs))) #:x-min -1 #:x-max 1 #:y-min -1 #:y-max 1 #:z-min -1 #:z-max 1)) - (define (norm mx my x y) (exp (* -1/2 (+ (sqr (- x mx)) (sqr (- y my)))))) @@ -206,71 +208,4 @@ (contours3d f4 -4 4 -4 4)) #:angle -30)) -(time - (plot3d (contour-intervals3d f5 -5 5 -5 5 #:alphas '(1/4 3/4)) - #:out-file "contour3d-test.pdf")) - -(time - (plot3d (contour-intervals3d f5 -5 5 -5 5 #:alphas '(1/4 3/4)) - #:out-file "contour3d-test.ps")) - -(time - (plot3d (contour-intervals3d f5 -5 5 -5 5 #:alphas '(1/4 3/4)) - #:out-file "contour3d-test.svg")) - -(time - (plot3d (contour-intervals3d f5 -5 5 -5 5 #:alphas '(1/4 3/4)) - #:out-file "contour3d-test.png")) - (time (plot3d (contour-intervals3d f1 -4 4 -4 4))) - -(time - (plot3d (isosurface3d (λ (x y z) (sqrt (+ (sqr x) (sqr y) (sqr z)))) 1 - #:color 2 #:line-color (->brush-color 2) #:line-width 1 - #:label "Sphere") - #:x-min -0.8 #:x-max 0.8 - #:y-min -0.8 #:y-max 0.8 - #:z-min -0.8 #:z-max 0.8 - #:altitude 30 - #:legend-anchor 'center)) - -(time - (define saddle (λ (x y z) (- (sqr x) (* 1/2 (+ (sqr y) (sqr z)))))) - (plot3d (isosurfaces3d saddle #:d-min -1 #:d-max 1 #:label "d") - #:x-min -2 #:x-max 2 - #:y-min -2 #:y-max 2 - #:z-min -2 #:z-max 2 - #:legend-anchor 'top-left)) - -(time - (define saddle (λ (x y z) (- (sqr x) (* 1/2 (+ (sqr y) (sqr z)))))) - (plot3d (isosurfaces3d saddle #:d-min -1 #:d-max 1 - #:colors '(1 2 3) - #:line-colors '(1 2 3) - #:line-styles '(solid) - #:alphas '(3/4) - #:label "d") - #:x-min -2 #:x-max 2 - #:y-min -2 #:y-max 2 - #:z-min -2 #:z-max 2 - #:legend-anchor 'top-left)) - -(time - (define saddle (λ (x y z) (- (sqr x) (* 1/2 (+ (sqr y) (sqr z)))))) - (plot3d (isosurface3d saddle -1/4 #:color 0 #:line-color 0 #:alpha 7/8 - #:label "d = -1/4") - #:x-min -2 #:x-max 2 - #:y-min -2 #:y-max 2 - #:z-min -2 #:z-max 2)) - -(time - (define (f1 θ ρ) (+ 1 (/ θ 2 pi) (* 1/8 (sin (* 8 ρ))))) - (define (f2 θ ρ) (+ 0 (/ θ 2 pi) (* 1/8 (sin (* 8 ρ))))) - - (plot3d (list (polar3d f1 #:samples 41 #:color "navajowhite" #:line-style 'transparent #:alpha 2/3) - (polar3d f2 #:samples 41 #:color "navajowhite" #:line-style 'transparent #:alpha 2/3)) - #:title "A Seashell" #:x-label #f #:y-label #f)) - -(time - (plot3d (points3d '(#(0.1 0.6 0.3))) - #:x-min 0 #:x-max 1 #:y-min 0 #:y-max 1 #:z-min 0 #:z-max 1))