racket/collects/plot/tests/extreme-bounds-tests.rkt

67 lines
2.3 KiB
Racket
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#lang racket
(require plot plot/utils unstable/flonum)
(plot (points '(#(0 0)))
#:x-min +min.0 #:x-max (flstep +min.0 1000)
#:y-min 0 #:y-max 1)
(plot3d (points3d '(#(0 0 0)))
#:x-min +min.0 #:x-max (flstep +min.0 1000)
#:y-min 0 #:y-max 1 #:z-min 0 #:z-max 1)
(plot-x-label #f)
(plot-y-label #f)
(define stops (list (* 2 (inexact->exact -max.0))
-max.0 -min.0 0.0 +min.0 +max.0
(* 2 (inexact->exact +max.0))))
(define (extreme-real->string x)
(real->plot-label x (digits-for-range 0 (abs x))))
(define num-2d 0)
(time
(for ([x-min (in-list stops)]
[x-max (in-list (rest stops))]
#:when #t
[y-min (in-list stops)]
[y-max (in-list (rest stops))])
(displayln
(list (format "[~a,~a] × [~a,~a]"
(extreme-real->string x-min) (extreme-real->string x-max)
(extreme-real->string y-min) (extreme-real->string y-max))
(time (plot (lines (list (vector (inexact->exact x-min) (inexact->exact y-min))
(vector (inexact->exact x-max) (inexact->exact y-max))))))))
(set! num-2d (+ 1 num-2d))))
(printf "Total 2D plots: ~a~n" num-2d)
(printf "-----------------------------------------~n")
(define num-3d 0)
(time
(for ([x-min (in-list stops)]
[x-max (in-list (rest stops))]
#:when #t
[y-min (in-list stops)]
[y-max (in-list (rest stops))]
#:when #t
[z-min (in-list stops)]
[z-max (in-list (rest stops))])
(displayln
(list (format "[~a,~a] × [~a,~a] × [~a,~a]"
(extreme-real->string x-min) (extreme-real->string x-max)
(extreme-real->string y-min) (extreme-real->string y-max)
(extreme-real->string z-min) (extreme-real->string z-max))
(time (plot3d (lines3d (list (vector (inexact->exact x-min)
(inexact->exact y-min)
(inexact->exact z-min))
(vector (inexact->exact x-max)
(inexact->exact y-max)
(inexact->exact z-max))))))))
(set! num-3d (+ 1 num-3d))))
(printf "Total plots: ~a~n" num-3d)
(printf "-----------------------------------------~n")