<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>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:</div><div><div><br></div><div><font face="Courier New">(define (point-on-sphere ctr r theta phi)</font></div><div><font face="Courier New"> (let* ([z (* r (sin phi))]</font></div><div><font face="Courier New"> [√x^2+y^2 (sqrt (- (sqr r) (sqr z)))]</font></div><div><font face="Courier New"> [x (* √x^2+y^2 (cos theta))]</font></div><div><font face="Courier New"> [y (* √x^2+y^2 (sin theta))])</font></div><div><font face="Courier New"> (v+ (vector x y z) ctr)))</font></div><div><font face="Courier New"><br></font></div><div><div><font face="Courier New">(plot3d (points->surface</font></div><div><font face="Courier New"> (for*/list ([phi (in-range -pi/2 pi/2 ∆phi)]</font></div><div><font face="Courier New"> [theta (in-range 0 2pi (∆theta phi))])</font></div><div><font face="Courier New"> (point-on-sphere #(0 0 0) 1 theta phi))))</font></div></div></div><div><br></div><div>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. </div><div><br></div><div>Is there anything like that? </div><br><div><div>On Apr 16, 2014, at 12:30 PM, Alexander D. Knauth <<a href="mailto:alexander@knauth.org">alexander@knauth.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">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. <br><br>On Apr 11, 2014, at 5:28 PM, Neil Toronto <<a href="mailto:neil.toronto@gmail.com">neil.toronto@gmail.com</a>> wrote:<br><br><blockquote type="cite">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.<br><br>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.<br><br>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.<br><br>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.<br><br>Neil ⊥<br><br>On 04/11/2014 02:17 PM, Alexander D. Knauth wrote:<br><blockquote type="cite">Is there something for plotting 3D parametric surfaces? (where there are two parameters instead of one)<br><br>If there is, then I would do something like this:<br>(define (sphere3d ctr-x ctr-y ctr-z r #:color color)<br> (parametric-surface3D (lambda (theta phi) ; theta and phi are the parameters<br> (let* ([z (* r (sin phi))]<br> [√x^2+y^2 (sqrt (- (sqr r) (sqr z)))]<br> [x (* √x^2+y^2 (cos theta))]<br> [y (* √x^2+y^2 (sin theta))])<br> (vector x y z)))<br> (list (list 0 (* 2 pi)) ; theta goes from 0 to 2pi<br> (list (- (/ pi 2)) (/ pi 2))) ; phi goes from -pi/2 to pi/2<br> #:color color))<br><br>I looked at the documentation already and didn’t find it, but is there something that can do that, maybe in a different place?<br><br>I saw parametric3d, but that looks like it only does one parameter, so it can only do lines.<br><br>If there isn’t, is there a way to define something like a parametric-surface3d?<br>Maybe something like this:<br>(define (parametric-surface3d f mins-and-maxes #:x-min [x-min #f] …)<br> (match mins-and-maxes<br> [(list (list u-min u-max) (list v-min v-max))<br> (…<br> (for*/list ([u-value (in-range u-min u-max ∆u)]<br> [v-value (in-range v-min v-max ∆v)])<br> (…<br> (f u-value v-value)<br> …))<br> …)]))<br>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.<br><br>f: (real? real? . -> . (sequence-of real?)<br>mins-and-maxes: (listof (list/c real? real?))<br><br>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.<br><br>But I have no idea how to define something like this.<br><br>On Apr 10, 2014, at 11:27 PM, Neil Toronto <<a href="mailto:neil.toronto@gmail.com">neil.toronto@gmail.com</a>> wrote:<br><blockquote type="cite">(define (sphere3d x0 y0 z0 r color)<br> (isosurface3d (λ (x y z) (sqrt (+ (sqr (- x0 x))<br> (sqr (- y0 y))<br> (sqr (- z0 z)))))<br> r (- x0 r) (+ x0 r) (- y0 r) (+ y0 r) (- z0 r) (+ z0 r)<br> #:line-style 'transparent<br> #:color color))<br></blockquote><br></blockquote><br></blockquote><br><br>____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>