Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!cornell!vax5!cnsy From: cnsy@vax5.CIT.CORNELL.EDU Newsgroups: comp.graphics Subject: Ray Tracing News archive 7 of 7 (whew!) Summary: echoes of echoes... Message-ID: <18718@vax5.CIT.CORNELL.EDU> Date: 1 Jun 89 14:57:57 GMT Sender: news@vax5.CIT.CORNELL.EDU Reply-To: cnsy@vax5.cit.cornell.edu (Eric Haines) Organization: 3D/Eye Inc, Ithaca, NY Lines: 632 References: Well, now you're up to date. Please forgive all the repeats of USENET postings--they should be of interest to newcomers to comp.graphics, at least. If you're interested in contributing and subscribing to the RT News, drop me a line (notes to this Cornell account risk being ignored--please write to the email address listed below). I'll continue to post issues here, so if you are not interested in contributing, please don't ask to subscribe! Enjoy, Eric Haines _ __ ______ _ __ ' ) ) / ' ) ) /--' __. __ , --/ __ __. _. o ____ _, / / _ , , , _ / \_(_/|_/ (_/_ (_/ / (_(_/|_(__<_/ / <_(_)_ / (_, ritter@versatc.UUCP (Jack Ritter) writes: >Given a cluster of points in 3 space, is there >a good method for finding the minimum radius >sphere which encloses all the points? If not >minimum, at least "small"? Certainly it should >be tighter than the sphere which encloses the >minimum bounding box. > >I have a feeling the solution is iterative. If >so, I could provide a good initial guess for the >center & radius. The solution is not iterative. A simple solution is available in a two step process, and is characterized by whether three, or only two of the points are on the surface of the optimal sphere. Given the points, A, B, and C. Searching for the center of the optimal sphere, P, with the smallest radius, R. Checking the midpoints. set P = point halfway between A and B set R = 1/2 of length from A to B If length from C to P is less than or equal to R ---> done Repeat with line A-C, and B-C if needed. Extending the midpoints at right angles. build the line which intersects A-B at a right angle through the midpoint of A-B, call the line D. build the line which intersects A-C at a right angle through the midpoint of A-C, call it E. P is the point where D and E intersect. (Solve the simultaneous equations; R is the length A-P) ----------------------------------------------------------------------------- From: bullerj@handel.colostate.edu (Jon Buller) Subject: Re: Pixar's noise function Organization: Colorado State University, Ft. Collins CO 80523 In article <3599@pixar.UUCP> aaa@pixar.UUCP (Tony Apodaca) writes: >In article <2553@ssc-vax.UUCP> coy@ssc-vax.UUCP (Stephen B Coy) writes: >> ...My question: Does anyone out there know what this >>noise function really is? > > Three-dimensional simulated natural textures using pseudorandom >functions were simultaneously and independently developed by Darwyn >Peachey and Ken Perlin in 1984-5. Both have papers in the 1985 >Siggraph Proceedings describing their systems. Perlin, in particular, >describes in detail how noise() is implemented and can be used creatively [A description of the properties of the noise function goes here...] > If you have ever been interested in realistic computer graphics, do >whatever it takes to get a look at Perlin's paper. In 1985, his pictures >were absolutely astounding. In 1989, they are STILL astounding. No kidding, some of those pictures are INCREDIBLE. Here is my code for a look-alike to the Pixar Noise function, and while I can't say anything about exactly what Pixar's looks like, I think this is probably close. After reading the 1985 SIGGRAPH papers on 3d texturing, (and seeing my prof's code to do a similar thing) I wrote this. It uses a quadratic B-Spline instead of the cubic Hermite interpolant implied in the paper. Also note that DNoise is just the x, y, and z derivatives of Noise (which are also B-Splines). The hashing functions are from Knuth's Art of Computer Programming (I don't remember which volume though). I know the code is Pascal, and all of you will hate it, but I believe I write better Pascal than C... One final note, this was Lightspeed Pascal 2.0 for the Macintosh, but things have been reformatted slightly to get it on the net. I hope this is what you all wanted. -------- More: One other thing you might notice, Noise is C1 continuous, DNoise is only C0. This means that DNoise will have creases in it (along the planes of the random grid. To see this, crank out a square: 0x); xa = floor(P1 * (xi * phi - floor(xi * phi))); xb = floor(P1 * ((xi + 1) * phi - floor((xi + 1) * phi))); xc = floor(P1 * ((xi + 2) * phi - floor((xi + 2) * phi))); yi = floor(p->y); ya = floor(P2 * (yi * phi - floor(yi * phi))); yb = floor(P2 * ((yi + 1) * phi - floor((yi + 1) * phi))); yc = floor(P2 * ((yi + 2) * phi - floor((yi + 2) * phi))); zi = floor(p->z); za = floor(P3 * (zi * phi - floor(zi * phi))); zb = floor(P3 * ((zi + 1) * phi - floor((zi + 1) * phi))); zc = floor(P3 * ((zi + 2) * phi - floor((zi + 2) * phi))); p000 = pts[xa + ya + za & NUMPTS - 1]; p100 = pts[xb + ya + za & NUMPTS - 1]; p200 = pts[xc + ya + za & NUMPTS - 1]; p010 = pts[xa + yb + za & NUMPTS - 1]; p110 = pts[xb + yb + za & NUMPTS - 1]; p210 = pts[xc + yb + za & NUMPTS - 1]; p020 = pts[xa + yc + za & NUMPTS - 1]; p120 = pts[xb + yc + za & NUMPTS - 1]; p220 = pts[xc + yc + za & NUMPTS - 1]; p001 = pts[xa + ya + zb & NUMPTS - 1]; p101 = pts[xb + ya + zb & NUMPTS - 1]; p201 = pts[xc + ya + zb & NUMPTS - 1]; p011 = pts[xa + yb + zb & NUMPTS - 1]; p111 = pts[xb + yb + zb & NUMPTS - 1]; p211 = pts[xc + yb + zb & NUMPTS - 1]; p021 = pts[xa + yc + zb & NUMPTS - 1]; p121 = pts[xb + yc + zb & NUMPTS - 1]; p221 = pts[xc + yc + zb & NUMPTS - 1]; p002 = pts[xa + ya + zc & NUMPTS - 1]; p102 = pts[xb + ya + zc & NUMPTS - 1]; p202 = pts[xc + ya + zc & NUMPTS - 1]; p012 = pts[xa + yb + zc & NUMPTS - 1]; p112 = pts[xb + yb + zc & NUMPTS - 1]; p212 = pts[xc + yb + zc & NUMPTS - 1]; p022 = pts[xa + yc + zc & NUMPTS - 1]; p122 = pts[xb + yc + zc & NUMPTS - 1]; p222 = pts[xc + yc + zc & NUMPTS - 1]; xf = p->x - xi; x1 = xf * xf; x2 = 0.5 * x1; x1 = 0.5 + xf - x1; x0 = 0.5 - xf + x2; yf = p->y - yi; y1 = yf * yf; y2 = 0.5 * y1; y1 = 0.5 + yf - y1; y0 = 0.5 - yf + y2; zf = p->z - zi; z1 = zf * zf; z2 = 0.5 * z1; z1 = 0.5 + zf - z1; z0 = 0.5 - zf + z2; return z0 * (y0 * (x0 * p000 + x1 * p100 + x2 * p200) + y1 * (x0 * p010 + x1 * p110 + x2 * p210) + y2 * (x0 * p020 + x1 * p120 + x2 * p220)) + z1 * (y0 * (x0 * p001 + x1 * p101 + x2 * p201) + y1 * (x0 * p011 + x1 * p111 + x2 * p211) + y2 * (x0 * p021 + x1 * p121 + x2 * p221)) + z2 * (y0 * (x0 * p002 + x1 * p102 + x2 * p202) + y1 * (x0 * p012 + x1 * p112 + x2 * p212) + y2 * (x0 * p022 + x1 * p122 + x2 * p222)); } Vector Dnoise(p) Vector *p; { Vector v; int xi, yi, zi; int xa, xb, xc, ya, yb, yc, za, zb, zc; double xf, yf, zf; double x2, x1, x0, y2, y1, y0, z2, z1, z0; double xd2, xd1, xd0, yd2, yd1, yd0, zd2, zd1, zd0; double p000, p100, p200, p010, p110, p210, p020, p120, p220; double p001, p101, p201, p011, p111, p211, p021, p121, p221; double p002, p102, p202, p012, p112, p212, p022, p122, p222; xi = floor(p->x); xa = floor(P1 * (xi * phi - floor(xi * phi))); xb = floor(P1 * ((xi + 1) * phi - floor((xi + 1) * phi))); xc = floor(P1 * ((xi + 2) * phi - floor((xi + 2) * phi))); yi = floor(p->y); ya = floor(P2 * (yi * phi - floor(yi * phi))); yb = floor(P2 * ((yi + 1) * phi - floor((yi + 1) * phi))); yc = floor(P2 * ((yi + 2) * phi - floor((yi + 2) * phi))); zi = floor(p->z); za = floor(P3 * (zi * phi - floor(zi * phi))); zb = floor(P3 * ((zi + 1) * phi - floor((zi + 1) * phi))); zc = floor(P3 * ((zi + 2) * phi - floor((zi + 2) * phi))); p000 = pts[xa + ya + za & NUMPTS - 1]; p100 = pts[xb + ya + za & NUMPTS - 1]; p200 = pts[xc + ya + za & NUMPTS - 1]; p010 = pts[xa + yb + za & NUMPTS - 1]; p110 = pts[xb + yb + za & NUMPTS - 1]; p210 = pts[xc + yb + za & NUMPTS - 1]; p020 = pts[xa + yc + za & NUMPTS - 1]; p120 = pts[xb + yc + za & NUMPTS - 1]; p220 = pts[xc + yc + za & NUMPTS - 1]; p001 = pts[xa + ya + zb & NUMPTS - 1]; p101 = pts[xb + ya + zb & NUMPTS - 1]; p201 = pts[xc + ya + zb & NUMPTS - 1]; p011 = pts[xa + yb + zb & NUMPTS - 1]; p111 = pts[xb + yb + zb & NUMPTS - 1]; p211 = pts[xc + yb + zb & NUMPTS - 1]; p021 = pts[xa + yc + zb & NUMPTS - 1]; p121 = pts[xb + yc + zb & NUMPTS - 1]; p221 = pts[xc + yc + zb & NUMPTS - 1]; p002 = pts[xa + ya + zc & NUMPTS - 1]; p102 = pts[xb + ya + zc & NUMPTS - 1]; p202 = pts[xc + ya + zc & NUMPTS - 1]; p012 = pts[xa + yb + zc & NUMPTS - 1]; p112 = pts[xb + yb + zc & NUMPTS - 1]; p212 = pts[xc + yb + zc & NUMPTS - 1]; p022 = pts[xa + yc + zc & NUMPTS - 1]; p122 = pts[xb + yc + zc & NUMPTS - 1]; p222 = pts[xc + yc + zc & NUMPTS - 1]; xf = p->x - xi; x1 = xf * xf; x2 = 0.5 * x1; x1 = 0.5 + xf - x1; x0 = 0.5 - xf + x2; xd2 = xf; xd1 = 1.0 - xf - xf; xd0 = xf - 1.0; yf = p->y - yi; y1 = yf * yf; y2 = 0.5 * y1; y1 = 0.5 + yf - y1; y0 = 0.5 - yf + y2; yd2 = yf; yd1 = 1.0 - yf - yf; yd0 = yf - 1.0; zf = p->z - zi; z1 = zf * zf; z2 = 0.5 * z1; z1 = 0.5 + zf - z1; z0 = 0.5 - zf + z2; zd2 = zf; zd1 = 1.0 - zf - zf; zd0 = zf - 1.0; v.x = z0 * (y0 * (xd0 * p000 + xd1 * p100 + xd2 * p200) + y1 * (xd0 * p010 + xd1 * p110 + xd2 * p210) + y2 * (xd0 * p020 + xd1 * p120 + xd2 * p220)) + z1 * (y0 * (xd0 * p001 + xd1 * p101 + xd2 * p201) + y1 * (xd0 * p011 + xd1 * p111 + xd2 * p211) + y2 * (xd0 * p021 + xd1 * p121 + xd2 * p221)) + z2 * (y0 * (xd0 * p002 + xd1 * p102 + xd2 * p202) + y1 * (xd0 * p012 + xd1 * p112 + xd2 * p212) + y2 * (xd0 * p022 + xd1 * p122 + xd2 * p222)); v.y = z0 * (yd0 * (x0 * p000 + x1 * p100 + x2 * p200) + yd1 * (x0 * p010 + x1 * p110 + x2 * p210) + yd2 * (x0 * p020 + x1 * p120 + x2 * p220)) + z1 * (yd0 * (x0 * p001 + x1 * p101 + x2 * p201) + yd1 * (x0 * p011 + x1 * p111 + x2 * p211) + yd2 * (x0 * p021 + x1 * p121 + x2 * p221)) + z2 * (yd0 * (x0 * p002 + x1 * p102 + x2 * p202) + yd1 * (x0 * p012 + x1 * p112 + x2 * p212) + yd2 * (x0 * p022 + x1 * p122 + x2 * p222)); v.z = zd0 * (y0 * (x0 * p000 + x1 * p100 + x2 * p200) + y1 * (x0 * p010 + x1 * p110 + x2 * p210) + y2 * (x0 * p020 + x1 * p120 + x2 * p220)) + zd1 * (y0 * (x0 * p001 + x1 * p101 + x2 * p201) + y1 * (x0 * p011 + x1 * p111 + x2 * p211) + y2 * (x0 * p021 + x1 * p121 + x2 * p221)) + zd2 * (y0 * (x0 * p002 + x1 * p102 + x2 * p202) + y1 * (x0 * p012 + x1 * p112 + x2 * p212) + y2 * (x0 * p022 + x1 * p122 + x2 * p222)); return v; } ----------------------------------------------------------------------------- END OF RTNEWS