Changed 'points' contract on vecs to (listof (vector/c real? real?))

This commit is contained in:
Neil Toronto 2011-10-05 20:57:24 -06:00
parent 7680adf486
commit cd98c4ac89
8 changed files with 26 additions and 27 deletions

View File

@ -7,9 +7,6 @@
(provide (all-defined-out))
(define (vector-take-2 v) (vector-take v 2))
(define (vector-take-3 v) (vector-take v 3))
(define (vcross v1 v2)
(match-define (vector x1 y1 z1) v1)
(match-define (vector x2 y2 z2) v2)

View File

@ -2,7 +2,7 @@
;; A compatibility module for the old 'plot'.
(require racket/contract racket/class racket/snip racket/draw
(require racket/contract racket/class racket/snip racket/draw racket/vector
;; Plotting
"common/contract.rkt"
"common/contract-doc.rkt"
@ -144,7 +144,8 @@
[#:sym sym (or/c char? string? integer? symbol?) 'square]
[#:color color plot-color? 'black]
) ((is-a?/c 2d-plot-area%) . -> . void?)
(renderer2d->plot-data (new.points vecs #:sym sym #:size 6 #:color color)))
(renderer2d->plot-data (new.points (map (λ (v) (vector-take v 2)) vecs)
#:sym sym #:size 6 #:color color)))
(defproc (vector-field [f ((vector/c real? real?) . -> . (vector/c real? real?))]
[#:samples samples (integer>=/c 2) 20]

View File

@ -2,7 +2,7 @@
;; Renderers for contour lines and contour intervals
(require racket/contract racket/class racket/match racket/list racket/flonum
(require racket/contract racket/class racket/match racket/list racket/flonum racket/vector
"../common/math.rkt"
"../common/draw.rkt"
"../common/marching-squares.rkt"
@ -135,7 +135,8 @@
(exact->inexact z3) (exact->inexact z4)))])
(cond [(equal? poly 'full) (list (vector xa ya) (vector xa yb)
(vector xb yb) (vector xb ya))]
[else (map vector-take-2 (scale-normalized-poly poly xa xb ya yb))])))))
[else (map (λ (v) (vector-take v 2))
(scale-normalized-poly poly xa xb ya yb))])))))
(define (draw-polys)
(for ([poly (in-list polys)])

View File

@ -25,7 +25,7 @@
(if label (point-legend-entry label sym color size line-width) empty))
(defproc (points [vs (listof (vectorof real?))]
(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]
[#:sym sym point-sym/c (point-sym)]
@ -35,7 +35,7 @@
[#:alpha alpha (real-in 0 1) (point-alpha)]
[#:label label (or/c string? #f) #f]
) renderer2d?
(let ([vs (filter vregular? (map vector-take-2 vs))])
(let ([vs (filter vregular? vs)])
(cond
[(empty? vs) null-renderer2d]
[else (match-define (list (vector xs ys) ...) vs)

View File

@ -32,7 +32,7 @@
[#:alpha alpha (real-in 0 1) (point-alpha)]
[#:label label (or/c string? #f) #f]
) renderer3d?
(let ([vs (filter vregular? (map vector-take-3 vs))])
(let ([vs (filter vregular? vs)])
(cond [(empty? vs) null-renderer3d]
[else
(match-define (list (vector xs ys zs) ...) vs)

View File

@ -9,7 +9,7 @@
@defmodule[plot]
@(plot-name) provides an flexible interface for producing nearly any kind of plot.
@(plot-name) provides a flexible interface for producing nearly any kind of plot.
It includes many common kinds already, such as scatter plots, line plots, contour plots, histograms, and 3D surfaces and isosurfaces.
Thanks to Racket's excellent multiple-backend drawing library, @(plot-name) can render plots as manipulatable images in DrRacket, as bitmaps in slideshows, as PNG, PDF, PS and SVG files, or on any device context.

View File

@ -446,7 +446,7 @@
255 255 -1 -1 43 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 1 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 -1 -1 0 747 0 26 3 12 #"#lang racket"
255 255 -1 -1 0 748 0 26 3 12 #"#lang racket"
0 0 4 29 1 #"\n"
0 0 4 29 1 #"\n"
0 0 17 3 81
@ -1245,7 +1245,15 @@
0 0 22 3 1 #"("
0 0 14 3 6 #"points"
0 0 4 3 1 #" "
0 0 14 3 17 #"experimental-data"
0 0 22 3 1 #"("
0 0 14 3 3 #"map"
0 0 4 3 1 #" "
0 0 14 3 6 #"vector"
0 0 4 3 1 #" "
0 0 14 3 5 #"times"
0 0 4 3 1 #" "
0 0 14 3 4 #"vals"
0 0 22 3 1 #")"
0 0 4 3 1 #" "
0 0 22 3 5 #"#:sym"
0 0 4 3 1 #" "
@ -1409,8 +1417,7 @@
0 0 19 3 1 #"\""
0 0 19 3 3 #"The"
0 0 19 3 1 #" "
0 0 19 3 3 #"old"
0 0 19 3 29 #" library produced this plot:\""
0 0 19 3 32 #"old library produced this plot:\""
0 0 22 3 1 #")"
0 0 4 29 1 #"\n"
0 2 83 4 1 #"\0"
@ -2587,8 +2594,7 @@
0 0 17 3 1 #"a"
0 0 17 3 1 #" "
0 0 17 3 4 #"44.5"
0 0 17 3 1 #" "
0 0 17 3 4 #"0.5)"
0 0 17 3 5 #" 0.5)"
0 0 4 29 1 #"\n"
0 0 17 3 2 #";("
0 0 17 3 7 #"check-="
@ -2596,8 +2602,7 @@
0 0 17 3 3 #"tau"
0 0 17 3 1 #" "
0 0 17 3 4 #"57.5"
0 0 17 3 1 #" "
0 0 17 3 4 #"0.5)"
0 0 17 3 5 #" 0.5)"
0 0 4 29 1 #"\n"
0 0 17 3 2 #";("
0 0 17 3 7 #"check-="
@ -2605,8 +2610,7 @@
0 0 17 3 3 #"phi"
0 0 17 3 1 #" "
0 0 17 3 5 #"-0.38"
0 0 17 3 1 #" "
0 0 17 3 5 #"0.05)"
0 0 17 3 6 #" 0.05)"
0 0 4 29 1 #"\n"
0 0 17 3 2 #";("
0 0 17 3 7 #"check-="
@ -2614,16 +2618,13 @@
0 0 17 3 1 #"T"
0 0 17 3 1 #" "
0 0 17 3 4 #"13.1"
0 0 17 3 1 #" "
0 0 17 3 4 #"0.5)"
0 0 17 3 5 #" 0.5)"
0 0 4 29 1 #"\n"
0 0 17 3 2 #";("
0 0 17 3 7 #"check-="
0 0 17 3 1 #" "
0 0 17 3 6 #"theta0"
0 0 17 3 1 #" "
0 0 17 3 3 #"2.5"
0 0 17 3 1 #" "
0 0 17 3 4 #"0.5)"
0 0 17 3 8 #"2.5 0.5)"
0 0 4 29 1 #"\n"
0 0

View File

@ -11,7 +11,6 @@
(plot empty #:x-min -1 #:x-max 1 #:y-min -1 #:y-max 1)
#;
(parameterize ([plot-x-transform (hand-drawn-transform 200)]
[plot-y-transform (hand-drawn-transform 200)])
(plot (function sqr -1 1)))