[racket] Controlling the size of plot symbols
Maybe I should've included an example. If points->surface was a function that took a list of points and connected those points into a surface (like in my last email), then this code would draw a sphere at the origin with a radius of 1:
(define (point-on-sphere ctr r theta phi)
(let* ([z (* r (sin phi))]
[√x^2+y^2 (sqrt (- (sqr r) (sqr z)))]
[x (* √x^2+y^2 (cos theta))]
[y (* √x^2+y^2 (sin theta))])
(v+ (vector x y z) ctr)))
(plot3d (points->surface
(for*/list ([phi (in-range -pi/2 pi/2 ∆phi)]
[theta (in-range 0 2pi (∆theta phi))])
(point-on-sphere #(0 0 0) 1 theta phi))))
Notice how here ∆theta can be a function of phi. Here points->surface doesn’t have to worry at all about sampling or anything like that, but the person using it can do that themselves if they feel like it.
Is there anything like that?
On Apr 16, 2014, at 12:30 PM, Alexander D. Knauth <alexander at knauth.org> wrote:
> Is there something that can take a list of points, (or maybe a list of lists of points) and connects those points into a surface, sort of like lines3d takes a list of points and connects them into a curve? And then define parametric-surface3d could be defined in terms of it, like parametric3d is defined in terms of lines3d. If there is, then I would like to be able to use it to define my own parametric-surface3d (even though it won’t have the sampling stuff) to use until there’s a real version with the sampling stuff. And it just seems like a function that just takes a list of points would give people greater control over the sampling stuff anyway, if they wanted to have it.
>
> On Apr 11, 2014, at 5:28 PM, Neil Toronto <neil.toronto at gmail.com> wrote:
>
>> Plot doesn't have parametric 3D surfaces yet because they can contain arbitrarily large, arbitrarily close, or intersecting polygons. Plot's current 3D engine sorts polygons wrongly when they're not in a grid or are too close together, and it never draws intersecting polygons right.
>>
>> The upcoming release's Plot has a 3D engine that can handle anything, but we've just created a release branch, which I can't add features to. I'll add `parametric-surface3d' to the master branch soon, though, so it'll be available in the nightly builds and in the release after next.
>>
>> FWIW, doing parametric surfaces well could be a little trickier than it seems. For example, when rendering a sphere, it might be desirable to sample theta more coarsely when phi is near -pi/2 or pi/2 (i.e. the poles). I'm not sure how to handle this yet, but the first thing that occurs to me is making one variable's range and sampling density a function of the value of the other. I'm open to suggestions.
>>
>> It might be time to take another look at Jens Axel's ideas for adaptive sampling, now that Plot can do it in 3D without b0rking it.
>>
>> Neil ⊥
>>
>> On 04/11/2014 02:17 PM, Alexander D. Knauth wrote:
>>> Is there something for plotting 3D parametric surfaces? (where there are two parameters instead of one)
>>>
>>> If there is, then I would do something like this:
>>> (define (sphere3d ctr-x ctr-y ctr-z r #:color color)
>>> (parametric-surface3D (lambda (theta phi) ; theta and phi are the parameters
>>> (let* ([z (* r (sin phi))]
>>> [√x^2+y^2 (sqrt (- (sqr r) (sqr z)))]
>>> [x (* √x^2+y^2 (cos theta))]
>>> [y (* √x^2+y^2 (sin theta))])
>>> (vector x y z)))
>>> (list (list 0 (* 2 pi)) ; theta goes from 0 to 2pi
>>> (list (- (/ pi 2)) (/ pi 2))) ; phi goes from -pi/2 to pi/2
>>> #:color color))
>>>
>>> I looked at the documentation already and didn’t find it, but is there something that can do that, maybe in a different place?
>>>
>>> I saw parametric3d, but that looks like it only does one parameter, so it can only do lines.
>>>
>>> If there isn’t, is there a way to define something like a parametric-surface3d?
>>> Maybe something like this:
>>> (define (parametric-surface3d f mins-and-maxes #:x-min [x-min #f] …)
>>> (match mins-and-maxes
>>> [(list (list u-min u-max) (list v-min v-max))
>>> (…
>>> (for*/list ([u-value (in-range u-min u-max ∆u)]
>>> [v-value (in-range v-min v-max ∆v)])
>>> (…
>>> (f u-value v-value)
>>> …))
>>> …)]))
>>> Where u and v are the parameters, u-min and u-max are the min and max of u, v-min and v-max are the min and max of v, and the function f is applied to the parameters like this: (f u-value v-value), and returns a (sequence-of real?) just like in parametric3d.
>>>
>>> f: (real? real? . -> . (sequence-of real?)
>>> mins-and-maxes: (listof (list/c real? real?))
>>>
>>> Maybe a more general version could deal with any number of parameters (thats why I wanted to put them in one mins-and-maxes argument instead of having separate arguments for each min and max.
>>>
>>> But I have no idea how to define something like this.
>>>
>>> On Apr 10, 2014, at 11:27 PM, Neil Toronto <neil.toronto at gmail.com> wrote:
>>>> (define (sphere3d x0 y0 z0 r color)
>>>> (isosurface3d (λ (x y z) (sqrt (+ (sqr (- x0 x))
>>>> (sqr (- y0 y))
>>>> (sqr (- z0 z)))))
>>>> r (- x0 r) (+ x0 r) (- y0 r) (+ y0 r) (- z0 r) (+ z0 r)
>>>> #:line-style 'transparent
>>>> #:color color))
>>>
>>
>
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140416/64cd1534/attachment.html>