home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / graphics / rtnews / rtnv2n7 < prev    next >
Encoding:
Internet Message Format  |  1995-05-19  |  54.1 KB

  1. From:    IN%"eye!erich@wrath.cs.cornell.EDU"  "Eric Haines" 13-OCT-1989 13:11:55.44
  2. To:    cornell!vax5!cnsy@wrath.cs.cornell.EDU
  3. CC:    
  4. Subj:    Next News
  5.  
  6. Return-path: eye!erich@wrath.cs.cornell.EDU
  7. Received: from wrath.cs.cornell.edu by vax5.cit.cornell.edu; Fri, 13 Oct 89
  8.  13:11 EDT
  9. Received: by wrath.cs.cornell.edu (5.61+2/I-1.91g) id AA22036; Fri, 13 Oct 89
  10.  13:10:59 -0400
  11. Received: by wrath.cs.cornell.edu (5.61+2/I-1.91g) id AA21406; Fri, 13 Oct 89
  12.  12:41:41 -0400
  13. Received: from juniper (juniper) by eye (14.5/15.4) id AA13656; Fri, 13 Oct 89
  14.  11:43:12 edt
  15. Received: by juniper (14.5/15.4) id AA11686; Fri, 13 Oct 89 11:43:05 edt
  16. Date: Fri, 13 Oct 89 11:43:05 edt
  17. From: Eric Haines <eye!erich@wrath.cs.cornell.EDU>
  18. Subject: Next News
  19. To: cornell!vax5!cnsy@wrath.cs.cornell.EDU
  20. Message-Id: <8910131543.AA11686@juniper>
  21.  
  22. John,
  23.  
  24.     Here you go!  Please pass on to comp.graphics.
  25.  
  26.  _ __                 ______                         _ __
  27. ' )  )                  /                           ' )  )
  28.  /--' __.  __  ,     --/ __  __.  _. o ____  _,      /  / _  , , , _
  29. /  \_(_/|_/ (_/_    (_/ / (_(_/|_(__<_/ / <_(_)_    /  (_</_(_(_/_/_)_
  30.              /                               /|
  31.             '                               |/
  32.  
  33.             "Light Makes Right"
  34.  
  35.             October 13, 1989
  36.                 Volume 2, Number 7
  37.  
  38. Compiled by Eric Haines, 3D/Eye Inc, 2359 Triphammer Rd, Ithaca, NY 14850
  39.     NOTE ADDRESS CHANGE: wrath.cs.cornell.edu!eye!erich
  40.     [distributed by Michael Cohen <m-cohen@cs.utah.edu>, but send
  41.     contributions and subscriptions requests to Eric Haines]
  42. All contents are US copyright (c) 1989 by the individual authors
  43. Archive locations: anonymous FTP at cs.uoregon.edu (128.223.4.1) and at
  44.            freedom.graphics.cornell.edu (128.84.247.85), /pub/RTNews
  45.  
  46. Contents:
  47.     Introduction
  48.     New People and Address Changes
  49.     Solid Surface Modeler Information, by Eric Haines
  50.     Minimum Bounding Sphere Program, by Marshall Levine
  51.     Parallelism & Modeler Info Request, by Brian Corrie
  52.     ======== USENET cullings follow ========
  53.     Ray Tracer Available, by Craig Kolb
  54.     Source from Roy Hall's Book, by Tim O'Connor
  55.     More on Texture Mapping by Spatial Position, by Paul Lalonde
  56.     Procedural Bump-mapping Query, by Prem Subrahmanyam
  57.     Ray Tracer Performance on Machines,
  58.     by Gavin A. Bell, Phil Dykstra, Steve Lamont
  59.     Projective Mapping Explanation, by Ken "Turk" Turkowski
  60.     Intersection Calculation Problem Request, Jari Toivanen
  61.     Mathematical Elements for Computer Graphics - Call for Errata,
  62.     by David Rogers
  63.     Raytracing on NCUBE Request, by Ping Kang Hsiung
  64.     Intersection Between a Line and a Polygon (UNDECIDABLE??),
  65.     by Dave Baraff, Tom Duff
  66.  
  67. -------------------------------------------------------------------------------
  68.  
  69. Introduction
  70.  
  71.     It's October, the time when the air turns chilly, the leaves turn red, and
  72. people's minds turn towards releasing a public domain version of their ray
  73. tracer.  Holy smokes there's a lot of them coming out lately!  This month
  74. Craig Kolb's ray tracer has become available, along with the first PD ray
  75. tracer from Australia, by David Hook.  Paul Lalonde mentions that his will be
  76. coming out soon, and will include spline surfaces.  Also, David Kirk and Jim
  77. Arvo have created a ray tracer which they used in their workshop in Australia,
  78. and which may be released to the general public soon.  Other code that has
  79. been made available is that printed in Roy Hall's _Illumination and Color in
  80. Computer Generated Imagery_ book.
  81.  
  82.     Next month I hope to collect various timing information from all sorts of
  83. ray tracers on all sorts of machines.  I hope to do a "trace-off" sometime
  84. soon, comparing MTV's, Craig's, DBW, QRT, ART, mine, and any others I can get
  85. up and running.  If anyone else has any timings or observations on performance 
  86. of ray tracers and various machines, please send them to me.
  87.  
  88. -------------------------------------------------------------------------------
  89.  
  90. New People and Address Changes
  91.  
  92.  
  93. David Hook
  94. dgh@munnari.OZ.AU
  95.  
  96. Dept. Of Engineering Computer Resources
  97. University Of Melbourne
  98. Parkville, Vic, 3052
  99. Australia
  100.  
  101. G'day.
  102.  
  103. Our major area of interest in ray tracing is CSG modeling and we have a
  104. locally developed ray tracer which is a step towards this, as a department we
  105. are also involved with the Faculty of Architecture at this University, so we
  106. are starting to look at special effects somewhat more seriously than before.
  107. This has also led to a greater interest in acceleration techniques.
  108.  
  109. Personally, I am currently doing a masters degree in the area of CSG and ways
  110. of introducing patches into the model.  The rendering technique being used is
  111. ray tracing.
  112.  
  113.  
  114. [And a further note from David Hook:]
  115.  
  116. The mailing list has been set up on munnari, so if you send it to
  117. rtnews@munnari.OZ.AU, it will (should) travel around Oz to the people who want
  118. it.  I am asking people who subscribe if they wish to be on the contact list,
  119. etc...
  120.  
  121. As a bit of additional info, I have written a ray-tracer which does CSG and
  122. renders algebraic surfaces, (ala Pat Hanrahan), although in this case it's
  123. built around Sturm Sequences and we occasionally use CSG to take
  124. cross-sections of the surfaces.  The interest in algebraic surfaces began
  125. because a friend of mine was struggling with a 6th order surface known as the
  126. Hunt Surface, getting a good feel for the cusps on it was turning out to be
  127. awful using polygonal subdivision.  In any case there is a public domain
  128. version of all this sitting in pub on munnari.OZ.AU (128.250.1.21) which can
  129. be got by anonymous ftp.  The file is vort.tar.Z.  Knowing a bit more about
  130. the whole business now, it's a bit of an embarrassment!  Still it may be of
  131. interest to someone and constructive criticism is always welcome.
  132.  
  133.  
  134. [From a README file in his ray tracing distribution:]
  135.  
  136. By the by, for people who are interested, there are an excellent series of
  137. papers on ray tracing and computer graphics in general published in the NATO
  138. ASI Series of books.  The volume in question is in Vol.  40, series F, and is
  139. titled "Theoretical Foundations of Computer Graphics and CAD".  It was
  140. published in 1988 Springer-Verlag.  Roman Kuchkuda's paper in it "An
  141. Introduction To Ray Tracing", would be the best introductory paper we have
  142. seen to date.  Apart from that it was the first paper we found that actually
  143. said what a superquadric was!
  144.  
  145. --------
  146.  
  147. NAME:   Hench, Stephen D.              SNAIL MAIL: 2621-C Stewart Drive
  148. E MAIL: hench@csclea.ncsu.edu                      Raleigh, NC  27603
  149.  
  150. BRIEF: Undergrad in Mathematics and Computer Science at NCSU.
  151.        Interested in ray tracing (would I want to subscribe 
  152.        if I wasn't?), radiosity, and rendering in general.
  153.  
  154. --------
  155.  
  156. Marshall Levine
  157. 136 1937 Hall  Wilson College
  158. Princeton University
  159. Princeton, NJ 08544
  160. (609) 734-6061
  161.  
  162. Home:
  163. Marshall Levine
  164. 5212 Louise Avenue
  165. Encino, California 91316
  166. (818) 995-6528
  167. (818) 906-7068
  168.  
  169. E-mail:
  170. (1)  mplevine@phoenix.princeton.edu  or:
  171. (2)  mplevine@gauguin.princeton.edu   or:
  172. (3)  mplevine@bogey.princeton.edu
  173.  
  174. My main interests are helicopters and computer graphics.  Within graphics, I
  175. am interested in animation and motion control.  While I think it is great to
  176. see a ray-traced magnifying glass sitting on top of a cicuit board, I would
  177. rather see the magnifying glass fly smoothly over a spinning board while the
  178. camera flies smoothly through the scene.  I am currently designing a flexible
  179. graphics language with a friend of mine, Chris Williams (Princeton U. '92).
  180. If anyone is interested, I can say more about that later.
  181.  
  182. --------
  183.  
  184. Cornell Program of Computer Graphics
  185.  
  186. A ray tracing mailing list has been set up by Tim O'Connor:
  187.  
  188.     ray-tracing-news@wisdom.graphics.cornell.edu
  189.  
  190.     Program of Computer Graphics
  191.     120 Rand Hall
  192.     Cornell University
  193.     Ithaca, NY 14853
  194.  
  195. People on this list who've already been intro'ed here include: Roy Hall,
  196. Mark Reichert, Ben Trumbore, and Tim O'Connor.
  197.  
  198. New people and brief bio sketches:
  199.  
  200. Wash Wawrzynek - paw@squid.graphics.cornell.edu
  201.  
  202. Current interest are user interfaces and visualization for computational
  203. mechanics.
  204.  
  205. --------
  206.  
  207. Len Wanger - lrw@freedom.graphics.cornell.edu
  208.  
  209. My sketch is on a piece of paper, but my interests are:  I am a graduate
  210. student in the department of computer graphics at Cornell University.  I am
  211. interested in modeling and visual perception.
  212.  
  213. --------
  214.  
  215. Filippo Tampieri - fxt@freedom.graphics.cornell.edu
  216.  
  217. Areas of interest:  parallel/distributed ray tracing, fast algorithms for ray
  218. tracing.
  219.  
  220. --------
  221.  
  222. Ricardo Pomeranz - rxp@venus.graphics.cornell.edu
  223.  
  224. Interests: constructive solid geometry and rendering
  225.  
  226. --------
  227.  
  228. Paul Wanuga - phw@neptune.graphics.cornell.edu
  229.  
  230. Masters student at Cornell's Computer Graphics Lab.  Interests - rendering
  231. realistic complex environments in realistic times.
  232.  
  233. --------
  234.  
  235. Kathy Kershaw - kershaw@hope.graphics.cornell.edu
  236.  
  237. I'm Kathy Kershaw.  I did the ray tracing thing once.  Maybe it'll have
  238. something to do w/ my master's thesis; maybe not.
  239.  
  240. --------
  241.  
  242. Colin Summers - colin@scarpa.graphics.cornell.edu
  243.  
  244. Just recently interested in computer graphics and heading into the abyss from
  245. the architecture side, I have a background in personal computers and spent a
  246. year out of the design studio to computer consult in Manhattan.  Glad to be
  247. back in the world of academia.  As soon as someone comes across with a
  248. Macintosh like text processor for xWindows, let me know.
  249.  
  250. --------
  251.  
  252. Ted Himlan - thh@squid.Graphics.Cornell.EDU
  253.  
  254. Color science, radiometric measurement, array camera.
  255. interest:  detailed measurements on an environment 
  256.      for comparison to simulation.
  257.  
  258. --------
  259.  
  260. Julie O'Brien Dorsey - job@hope.graphics.cornell.edu
  261.  
  262. Computer aided design applications, radiosity, lighting design
  263.  
  264. --------
  265.  
  266. Francois Sillion - fxs@bruno.graphics.cornell.edu
  267.  
  268. I am currently on a Post-Doc position at Cornell, after having completed my
  269. PhD at the 'Ecole Normale Superieure' in Paris, France, where my work included
  270. the development of a two-pass method for lighting calculations, combining ray
  271. tracing and radiosity.
  272.  
  273. My interests are illumination models (local and global), animation and
  274. interactivity.
  275.  
  276. -------------------------------------------------------------------------------
  277.  
  278. Solid Surface Modeler Information, by Eric Haines
  279.  
  280. The Solid Surface Modeler from NASA finally came out.  The disappointing news
  281. is that even though it's "a non-profit unit of the University of Georgia," the
  282. thing is priced at $1250 for a cartridge tape and documentation (which is $43
  283. separately).  The reason I mention it is this newsletter is that it was used
  284. for some rather elaborate databases that were both modeled and ray traced on
  285. the AT&T Pixel Machine.  Unfortunately, it's unclear whether the Pixel Machine
  286. driver program is included in the distribution.  The modeler itself sounds
  287. reasonable, source code comes on the tape, and there seems to be no
  288. restrictions on the use of the software.  It's a pity that it's pricey when
  289. compared to, say, FSF stuff, but I guess someone has to pay for those glossy
  290. advertisement folders.
  291.  
  292. From their literature:  "SSM was written in standard C with Silicon Graphic's
  293. Iris Graphics Library calls and AT&T PicLib calls....  The program is
  294. available for the Silicon Graphics IRIS workstation running version 3.1 of
  295. IRIX, and a Sun Workstation with AT&T PXM964 running 4.2 BSD."
  296.  
  297. For more information contact:
  298. COSMIC
  299. The University of Georgia
  300. 382 East Broad Street
  301. Athens, GA  30602
  302. (404)-542-3265
  303.  
  304. -------------------------------------------------------------------------------
  305.  
  306. Minimum Bounding Sphere Program, by Marshall Levine
  307.  
  308. I think you will be interested in the following program.  It is a
  309. minimum-bounding-sphere program.  As the explained in the header comments, the
  310. main algorithm seems to solve the problem in linear time.  Please let me know
  311. what you think.
  312.  
  313. { clusters.p
  314.  
  315. Written by Marshall Levine  (Princeton University '92)
  316. e-mail:  mplevine@phoenix.princeton.edu
  317. Algorithm designed by Marshall Levine and Chris Williams (Princeton U. '92)
  318.  
  319. This program searches through a 3-dimensional space of randomly distributed
  320. points for a cluster of 10 stars within the smallest radius possible.
  321.  
  322. I first implemented a "pri" list.  This is a linked list of real numbers
  323. (representing distances).  The list is kept in order.  However, when a number
  324. that would go farther into the list than the number of points per sphere
  325. (NUMINSPHERE) tries to go into the list, the insert procedure stops it.  This
  326. is done because the distance is useless.  For example, if NUMINSPHERE is 5 and
  327. a number would be inserted into the 7th slot in the list, it is not inserted.
  328. The minimum radius of a sphere with 5 points would be determined by the 5th
  329. element of the list (not including the header), so any number inserted after
  330. the 5th element is useless and is therefore not inserted.  If there are not
  331. NUMINSPHERE elements in the pri, then there are not enough points to fill the
  332. sphere.
  333.  
  334. The brute-force algorithm loops through every point in space.  For each point,
  335. the algorithm finds the distance between that point and every other point and
  336. puts that distance into the pri.  When all points have been compared against
  337. this point, the NUMINSPHERE'th element is taken to be the minimum radius of a
  338. sphere centered at this point containing NUMINSPHERE points.  However, points
  339. are not compared against themselves, so the exact number of comparisons is
  340. N^2-N, making this an N^2 algorithm.
  341.  
  342. The efficient algorithm designed by Chris Williams and me divides the space
  343. into a 3-dimensional grid.  If the grid is divided into NUMPOINTS/NUMINSPHERE
  344. sectors, then at least one of the sectors must have at least NUMINSPHERE
  345. points.  Now, make spheres with the same volume as the sectors.  At least one
  346. sphere surrounding one point will have at least NUMINSPHERE points.  It turns
  347. out that the tradeoff between fewer computations and more overhead is
  348. minimized by choosing the grid to have enough sectors such that each sector is
  349. r/2 on each side (where r is the radius of the aforementioned sphere).  Our
  350. algorithm starts with a sphere radius equal to the distance from one corner of
  351. the unit cube to another (3^.5).  Given the first point in the list, we
  352. compare that point against every other point in sectors touching the sphere
  353. (In this case, every other point in space!)  By storing the distances and then
  354. taking the NUMINSPHERE'th number from the pri list, as in the brute algorithm,
  355. we frequently reduce the size of the sphere.  Then, we check the next point
  356. with the new, smaller sphere size and continue in this way until we have
  357. tested every point.  As we go along, the minimum sphere size keeps shrinking
  358. until for any given point, we only check a few neighboring sectors, if any.
  359. In practice, this radius shrinks so quickly that the algorithm displays LINEAR
  360. BEHAVIOR!
  361.  
  362. NOTE:  This program was written for clarity, not for efficiency.  If it is to
  363. be used in any real applications, there are many ways to speed it up.
  364.  
  365.  
  366.                   Bruteforce:                     Our algorithm:
  367.                                                (Average of 3 runs)
  368. Points:   #Comparisons:  comps/points:     #Comparisons:  comps/points:
  369.      50            2450         49.000               958         19.160
  370.      75            5550         74.000              1241         16.547
  371.     100            9900         99.000              2111         21.110
  372.     150           22350        149.000              2785         18.567
  373.     200                                             3689         18.445
  374.     250                                             5120         20.480
  375.     300                                             6010         20.033
  376.     350                                             7149         20.426
  377.     400                                             7658         19.145
  378.     600                                            11404         19.007
  379.     800                                            16781         20.976
  380.    1000                                            20438         20.438
  381.  
  382.  
  383.  
  384. Testing 50 points.
  385. Brute-force:
  386.    Best sphere:    0.3067962678
  387.    Number of comparisons:     2450
  388. Efficient Algorithm:
  389.    Best sphere:    0.3067962678
  390.    Number of comparisons:      946
  391.  
  392.  %time  cumsecs  #call  ms/call  name
  393.   31.6     0.10      1   100.01  _brutecluster      <====
  394.   10.5     0.18      1    33.34  _elegantcluster    <====
  395.    5.3     0.25    101     0.17  _clearprilist
  396.    5.3     0.27    581     0.03  _insertprilist
  397.    5.3     0.28      1    16.67  _makespace
  398.  
  399. Testing 300 points.
  400. Brute-force:
  401.    Best sphere:    0.1569231423
  402.    Number of comparisons:    89700
  403. Efficient Algorithm:
  404.    Best sphere:    0.1569231423
  405.    Number of comparisons:     5617
  406.  
  407.  %time  cumsecs  #call  ms/call  name
  408.   44.2     3.27      1  3267.00  _brutecluster      <====
  409.    2.9     6.82      1   216.69  _elegantcluster    <====
  410.    1.1     7.00   2358     0.04  _insertprilist
  411.    0.2     7.33    601     0.03  _clearprilist
  412.    0.0     7.38      1     0.00  _makespace
  413. }
  414.  
  415. {==========================================================================}
  416.  
  417. program clusters(input,output);
  418.  
  419. const
  420.   MAXNUMPOINTS = 501;    { The maximum # of points we can handle  }
  421.   NUMINSPHERE = 10;      { # stars to find inside sphere          }
  422.   INFINITY = 999999.9;   { Larger than largest distance possible  }
  423.   MAXUSESPACE = 20;      { Maximum length per edge of space-grid  }
  424.   PI = 3.1415926535;
  425.  
  426. type
  427.   datatype = real;
  428.   point = record         { The type of a point }
  429.             x : real;
  430.             y : real;
  431.             z : real;
  432.             data : datatype;
  433.           end;
  434.   ptr = ^node;
  435.   node = record          { Linked list for a distances list called "pri" }
  436.            data : real;
  437.            next : ptr;
  438.          end;
  439.   sptr = ^spacenode;     { Linked list for each sector in the space-grid }
  440.   spacenode = record
  441.                 index : integer; { Stores index of that point in points[] }
  442.                 next : sptr;
  443.               end;
  444.  
  445.  
  446. var
  447.   rndnm : integer;       { Needed for the random number generator }
  448.   points : array [1..MAXNUMPOINTS] of point;   { All points in space }
  449.   listhead : ptr;        { List head for distances list called "pri" }
  450.   space : array[0..MAXUSESPACE, 0..MAXUSESPACE, 0..MAXUSESPACE] of sptr;
  451.                          { The space-grid (hereafter called 'grid') }
  452.   spacesize, usespace : integer;  { Size per edge of grid }
  453.   NUMPOINTS : integer;   { The number of points we have in space }
  454.  
  455.  
  456. { **************** Support routines for random generators ************** }
  457.  
  458. procedure seed;        { Seed the random number generator }
  459. begin
  460.   writeln('seed:');
  461.   readln(rndnm);
  462. end;
  463.  
  464. function rndom(scale : integer) : real; { Make random real from 0 to scale }
  465. begin
  466.   rndnm := abs(abs((rndnm*921+1)) mod 32749);
  467.   rndom := (rndnm*scale/32749)
  468. end;
  469.  
  470. procedure randompoint(var pt : point);  { Generate a random point within }
  471. begin                                   {   a unit cube.                 }
  472.   pt.x := rndom(1);
  473.   pt.y := rndom(1);
  474.   pt.z := rndom(1)
  475. end;
  476.  
  477. procedure generatepoints;           { Generate NUMPOINTS points in space }
  478. var x : integer;
  479. begin
  480.   for x := 1 to NUMPOINTS do
  481.     randompoint(points[x])
  482. end;
  483.  
  484.  
  485. { *************** Support routines for the "pri" list ******************** }
  486.  
  487. procedure initprilist;    { Initialize the pri list }
  488. begin
  489.   new(listhead);
  490.   listhead^.data := 0.0;
  491.   new(listhead^.next);
  492.   listhead^.next^.data := INFINITY;
  493.   listhead^.next^.next := nil
  494. end;
  495.  
  496. procedure clearprilist;   { Clear the pri list }
  497. var p,oldp : ptr;
  498. begin
  499.   p := listhead;
  500.   while p <> nil do
  501.   begin
  502.     oldp := p;
  503.     p := p^.next;
  504.     dispose(oldp)
  505.   end;
  506.   new(listhead);
  507.   listhead^.data := 0.0;
  508.   new(listhead^.next);
  509.   listhead^.next^.data := INFINITY;
  510.   listhead^.next^.next := nil
  511. end;
  512.  
  513.  
  514. procedure insertprilist(r : real);  { Insert a distance into pri list    }
  515. var p,oldp,temp : ptr;       { "pri" is just a linked list of distances  }
  516.     x : integer;             { kept in low -> high order. The catch is   }
  517. begin                        { that if a number should be inserted after }
  518.   x := 1;                    { the NUMINSPHERE'th node, we don't bother  }
  519.   p := listhead^.next;       { inserting it, because it isn't in the     }
  520.   oldp := listhead;          { smallest sphere with NUMINSPHERE points.  }
  521.   while (r > p^.data) and (x <= NUMINSPHERE) do
  522.   begin
  523.     oldp := p;
  524.     p := p^.next;
  525.     x := x + 1
  526.   end;
  527.   if x <= NUMINSPHERE then
  528.   begin
  529.     new(temp);
  530.     temp^.data := r;
  531.     temp^.next := p;
  532.     oldp^.next := temp
  533.   end
  534. end;
  535.  
  536. function getbiggestinsphere : real;  { Returns value of the NUMINSPHERE'th }
  537. var x : integer;                     { element in pri list, or INFINITY    }
  538.     p : ptr;                         { if the list isn't that long.        }
  539. begin
  540.   x := 1;
  541.   p := listhead^.next;
  542.   while (x < NUMINSPHERE) and (p <> nil) do
  543.   begin
  544.     x := x + 1;
  545.     p := p^.next
  546.   end;
  547.   if (x < NUMINSPHERE) or (p = nil) then getbiggestinsphere := INFINITY
  548.   else getbiggestinsphere := p^.data
  549. end;
  550.  
  551. procedure printprilist;              { Print the pri list, for debugging }
  552. var p : ptr;
  553. begin
  554.   p := listhead;  { DO print the head }
  555.   while p <> nil do
  556.   begin
  557.     writeln(p^.data:15:10);
  558.     p := p^.next
  559.   end;
  560.   writeln('nil')
  561. end;
  562.  
  563.  
  564. { ******************* Miscellaneous support routines ******************** }
  565.  
  566. procedure printpoint(pt : point);   { Print out a point }
  567. begin
  568.   writeln('(',pt.x:8:5,',',pt.y:8:5,',',pt.z:8:5,')')
  569. end;
  570.  
  571.  
  572. function cube(x : real) : real;     { Return cube root of a number }
  573. begin
  574.   cube := exp((1/3)*ln(x))
  575. end;
  576.  
  577.  
  578. { *********************** Brute Force algorithm ************************* }
  579.  
  580. procedure brutecluster;    { Find minimum sphere containing NUMINSPHERE }
  581.                            {   points by testing the distance between   }
  582.                            {   every point.                             }
  583. var distx,disty,distz,dist : real;      { Find distance between two points }
  584.     bestsphere,trysphere : real;        { Find minimum sphere              }
  585.     numcomps : integer;                 { # comparisons                    }
  586.     thispoint,againstpoint : integer;   { Counters                         }
  587. begin
  588.   clearprilist;                           { Kill the priority list          }
  589.   bestsphere := INFINITY;
  590.   numcomps := 0;
  591.   for thispoint := 1 to NUMPOINTS do      { Test every point...             }
  592.   begin
  593.     clearprilist;
  594.     for againstpoint := 1 to NUMPOINTS do { ...against every other point    }
  595.       if thispoint <> againstpoint then   { Don't compare point against self}
  596.       begin
  597.         distx := points[thispoint].x - points[againstpoint].x;
  598.         disty := points[thispoint].y - points[againstpoint].y;
  599.         distz := points[thispoint].z - points[againstpoint].z;
  600.         dist := sqrt(distx*distx + disty*disty + distz*distz);
  601.         numcomps := numcomps + 1;
  602.         if dist < bestsphere then       { If dist less than smallest sphere,}
  603.           insertprilist(dist)           {   insert distance into pri list   }
  604.       end;
  605.     trysphere := getbiggestinsphere;   { Get 'NUMINSPHERE'th item from list }
  606.     if trysphere < bestsphere then     { If this radius is the smallest yet,}
  607.       bestsphere := trysphere;         {   then remember it.                }
  608.   end;
  609.   writeln('Brute-force:');
  610.   writeln('   Best sphere: ',bestsphere:15:10);
  611.   writeln('   Number of comparisons: ',numcomps:8)
  612. end;
  613.  
  614.  
  615. { **************************** My algorithm *********************** }
  616.  
  617. procedure makespace;        { Build the space-grid.  See documentation at }
  618. var x,y,z : integer;        { beginning of program for details.           }
  619.     temp : sptr;
  620.     thispoint : integer;
  621. begin
  622.   spacesize := trunc(cube(8*PI*NUMPOINTS/NUMINSPHERE));
  623.   usespace := spacesize-1;
  624.   if usespace > MAXUSESPACE then writeln('****** NOT ENOUGH MEMORY FOR GRID');
  625.   for x := 0 to usespace do
  626.     for y := 0 to usespace do
  627.       for z := 0 to usespace do
  628.         space[x,y,z] := nil;     { Clear the grid }
  629.   for thispoint := 1 to NUMPOINTS do     { Go through every point... }
  630.   begin
  631.     new(temp);
  632.     temp^.index := thispoint;
  633.     x := trunc(points[thispoint].x * spacesize);
  634.     y := trunc(points[thispoint].y * spacesize);
  635.     z := trunc(points[thispoint].z * spacesize);
  636.     temp^.next := space[x,y,z];          { Put this point into proper }
  637.     space[x,y,z] := temp;                {   sector in grid.          }
  638.   end
  639. end;
  640.  
  641.  
  642. procedure elegantcluster;    { Find smallest sphere containing NUMINSPHERE }
  643.                              {   points by looping through every point,    }
  644.                              {   checking ROUGHLY only the points within   }
  645.                              {   a radius less than or equal to the        }
  646.                              {   minimum radius found so far.              }
  647. var bestsphere,trysphere : real;
  648.     xmin,xmax,ymin,ymax,zmin,zmax : integer; { Dimensions of box to check }
  649.     thispoint : integer;              { The current point to test against }
  650.     x,y,z : integer;                  { The current grid we are testing   }
  651.     distx,disty,distz,dist : real;    { For computing distances           }
  652.     numcomps : integer;               { # comparisons                     }
  653.     cpindex : sptr;          { Pointer into point list for a grid sector  }
  654. begin
  655.   makespace;
  656.   bestsphere := 1.732050808;    { Start with radius of distance from one }
  657.   numcomps := 0;                {   corner of unit cube to other: 3^.5   }
  658.   for thispoint := 1 to NUMPOINTS do    { Loop for every point }
  659.   begin
  660.     clearprilist;
  661.     xmin := trunc((points[thispoint].x - bestsphere) * spacesize);
  662.     xmax := trunc((points[thispoint].x + bestsphere) * spacesize);
  663.     ymin := trunc((points[thispoint].y - bestsphere) * spacesize);
  664.     ymax := trunc((points[thispoint].y + bestsphere) * spacesize);
  665.     zmin := trunc((points[thispoint].z - bestsphere) * spacesize);
  666.     zmax := trunc((points[thispoint].z + bestsphere) * spacesize);
  667.     if xmin < 0 then xmin := 0;
  668.     if ymin < 0 then ymin := 0;               { Get dimensions of box      }
  669.     if zmin < 0 then zmin := 0;               { containing every sector in }
  670.     if xmax > usespace then xmax := usespace; { grid that we want to check }
  671.     if ymax > usespace then ymax := usespace; { against the current point  }
  672.     if zmax > usespace then zmax := usespace;
  673.     for x := xmin to xmax do
  674.       for y := ymin to ymax do
  675.         for z := ymin to ymax do   { Loop through every sector in this box }
  676.         begin
  677.           cpindex := space[x,y,z];
  678.           while cpindex <> nil do  { Test against every point in this sector}
  679.           begin
  680.             if thispoint <> cpindex^.index then  { Don't test point against }
  681.             begin                                {   itself.                }
  682.               distx := points[thispoint].x - points[cpindex^.index].x;
  683.               disty := points[thispoint].y - points[cpindex^.index].y;
  684.               distz := points[thispoint].z - points[cpindex^.index].z;
  685.               dist := sqrt(distx*distx + disty*disty + distz*distz);
  686.               numcomps := numcomps + 1;
  687.               if dist < bestsphere then  { If dist less than smallest sphere}
  688.                 insertprilist(dist)      {   insert distance into pri list  }
  689.             end;
  690.             cpindex := cpindex^.next     { Get next point in this sector }
  691.           end
  692.         end;
  693.     trysphere := getbiggestinsphere;
  694.     if trysphere < bestsphere then
  695.       bestsphere := trysphere
  696.   end;
  697.   writeln('Efficient Algorithm:');
  698.   writeln('   Best sphere: ',bestsphere:15:10);
  699.   writeln('   Number of comparisons: ',numcomps:8)
  700. end;
  701.  
  702.  
  703. begin
  704.   seed;
  705.   writeln('How many points?');
  706.   readln(NUMPOINTS);
  707.   if NUMPOINTS < NUMINSPHERE then
  708.     writeln('***** Must have at least ',NUMINSPHERE:1,' points.')
  709.   else
  710.   begin
  711.     writeln('Testing ',NUMPOINTS:1,' points.');
  712.     initprilist;
  713.     generatepoints;
  714.     brutecluster;
  715.     elegantcluster
  716.   end
  717. end.
  718.  
  719. -------------------------------------------------------------------------------
  720.  
  721. Parallelism & Modeler Info Request, by Brian Corrie
  722.      ...!uw-beaver!uvicctr!bcorrie   bcorrie@uvicctr.UVic.ca
  723.  
  724. [soon to be a posting on USENET, but it hadn't reached my node yet.]
  725.  
  726.  
  727. Howdy folks....
  728.  
  729.     It's survey time again, and I would appreciate your participation in this
  730. version of twenty questions.
  731.  
  732. I am interested in parallel algorithms for ray tracing, and I am curious about
  733. a couple of things.  Please note that I have most of the "standard references"
  734. that get cited in the literature, but I am interested in some of the OTHER
  735. stuff that is out there.
  736.  
  737. The papers that I have:
  738.  
  739. Cleary et al.  "Multiprocessor Ray Tracing", Internal Report, 83/128/17,
  740. Department of Computer Science, University of Calgary, Calgary, Alberta,
  741. Canada.
  742.  
  743. Dippe et al "An Adaptive Subdivision Algorithm and Parallel Architecture for
  744. Realistic Image Synthesis", Computer Graphics, Volume 18, Number 3.
  745.  
  746. Gaudet et al "Multiprocessor Experiments for High Speed Ray Tracing", ACM
  747. TOG, Volume 7, Number 3.
  748.  
  749. etc.....
  750.  
  751. What I am interested in are references to some of the goodies that are out
  752. there in the real world.  Are there any papers on the hardware Pixar uses.
  753. How about the AT&T pixel machine, the Connection Machine (there is a piece on
  754. it in Scientific American, Volume 256, Number 6 that I already have), and
  755. other bizarre architectures.  Dave Jevans from the University of Calgary (Hi
  756. Dave, remember me?  I met you at SIGGRAPH this year) mentioned at one point he
  757. implemented some stuff on a BBN Butterfly (I think).  Any more info on that
  758. Dave?  Did you write it up?  Anybody else doing anything similar?
  759.  
  760. Here is the info I want....
  761.  
  762. 1) What architecture do you run on?
  763. 2) Parallel, vectorized etc?
  764.  
  765. For parallel systems:
  766.  
  767. 3) How many processors do you use?
  768. 4) How tightly coupled are they?
  769. 5) Do you perform any load balancing, and if so how?
  770. 6) Architectural requirements (memory/node, communications etc)?
  771. 7) Anything else you can think of that might be useful.
  772.  
  773. Thanks in advance for any help you can give me.  Replies by email are of
  774. course the best route to take, but I read comp.graphics every morning, so a
  775. reply here will be seen.  I will post a summary to the net if I get enough
  776. information.
  777.  
  778. ========
  779.  
  780. Question number two....
  781.  
  782. This should be quick and easy.  I would like to know what kind of modelling
  783. software people use out there in the real world.
  784.  
  785. We have all seen the pretty pictures, but how do they get created?  I would
  786. appreciate a quick or not so quick review of what kind of software is used at
  787. your site to model 3D scenes.
  788.  
  789. For those of you in the RT News mailing list and don't read the net like I do,
  790. I will send a copy of both this and the summary to Eric.
  791.  
  792.     Thanks,
  793.  
  794.     Brian
  795.  
  796. ======== USENET cullings follow ===============================================
  797.  
  798. Ray Tracer Available, by Craig Kolb
  799.     From: craig@weedeater.math.yale.edu
  800.     Newsgroups: comp.graphics
  801.     Organization: Math Department, Yale University
  802.  
  803. All of this talk of solid texturing and the like has convinced me to pull
  804. together my raytracer for public consumption.  Although I'm calling this a
  805. beta release, relatives of this version of rayshade have been making pretty
  806. pictures for about a year now.  For examples, see slides 32 and 57 from the
  807. SIGGRAPH '89 technical slide set and slides 67/68 from the stereo slide set.
  808.  
  809. If there's enough interest, I'll post rayshade to comp.sources.unix once the
  810. bugfixes stop rolling in.
  811.  
  812. [I would like to add that Craig's ray tracer is fairly nice, and most of the
  813. portability problems and minor bugs have been fixed since its release.  Its
  814. input language is much more full featured than NFF (which, I'll say again, was
  815. made only for testing ray tracers, not photorealism) and looks more mainstream
  816. than some of the other public domain ray tracers I've seen.  If you're looking
  817. for a reasonable input language, check his out.  His latest and greatest
  818. version (i.e. newer that 2.21) might be available via ftp by now. - EAH]
  819.  
  820. --
  821.  
  822. Rayshade, a raytracing program, is available for "Beta" testing.  Rayshade
  823. reads a multi-line ASCII file describing a scene to be rendered and produces a
  824. Utah Raster RLE format file of the raytraced image.
  825.  
  826. Features:
  827.  
  828.         Primitives:
  829.                 boxes
  830.                 cones
  831.                 cylinders
  832.                 height fields
  833.                 planes
  834.                 polygons
  835.                 spheres
  836.                 triangles       (flat- or Phong-shaded)
  837.         [he forgot to mention there are also superquadrics! - EAH]
  838.  
  839.         Composite objects
  840.  
  841.         Point, directional, and extended (area) light sources
  842.  
  843.         Solid texturing and bump mapping of primitives, objects, and
  844.                 individual instances of objects
  845.  
  846.         Antialiasing through adaptive supersampling or "jittered" sampling
  847.  
  848.         Arbitrary linear transformations of primitives,
  849.                 instances of objects, and texture/bump maps
  850.  
  851.         Use of uniform spatial subdivision and/or hierarchy of
  852.                 bounding volumes to speed rendering
  853.  
  854.         Options to facilitate rendering of stereo pairs
  855.  
  856.         Support for the Linda parallel programming language
  857.  
  858. An awk script is provided to translate NFF format scripts to rayshade format.
  859.  
  860. Rayshade is written in C with parsing support provided through lex and yacc.
  861. The C, lex and yacc files comprise approximately eight thousand lines of
  862. code.  Sites without lex and yacc can make use of the C source files produced
  863. by lex and yacc which are included in this distribution.
  864.  
  865. Rayshade has been tested on a number of UNIX-based machines, including
  866. Vaxes, Sun Workstations, Iris 4D Workstations, Encore Multimax, AT&T 3B2/310,
  867. Cray XMP, and IBM RTs.  In addition, support is provided for the Amiga using
  868. the Aztec C compiler.
  869.  
  870. Rayshade makes use of the Utah Raster toolkit, a package consisting of a
  871. large number of useful image manipulation programs, test images, and a
  872. library to read and write images written using the toolkit's RLE format.  The
  873. toolkit is available via anonymous FTP from cs.utah.edu or from
  874. weedeater.math.yale.edu.
  875.  
  876. Those sites that cannot or do not want to use the Utah Raster toolkit can
  877. make use of a compile-time option to produce images written using a generic
  878. file format identical to that used in Mark VandeWettering's "MTV" raytracer.
  879.  
  880. This version of rayshade is a "beta" release.  The first "real" release will
  881. include an updated manual page and additional documentation as well as
  882. any bugfixes or extensions born out of this release.
  883.  
  884. Rayshade is copyrighted in a "Gnu-like" manner.
  885.  
  886. Rayshade is available via anonymous ftp from weedeater.math.yale.edu
  887. (192.26.88.42) in pub/Rayshade.2.21.tar.Z.  The Utah Raster toolkit
  888. is available in pub/UtahToolkit.tar.Z.
  889.  
  890. -------------------------------------------------------------------------------
  891.  
  892. Source from Roy Hall's Book, by Tim O'Connor
  893.     From: toc@batcomputer.tn.cornell.edu
  894.     Newsgroups: comp.graphics
  895.  
  896. Straight from the dragon's mouth (so to speak) comes the source from
  897. "Illumination and Color in Computer Generated Imagery" by Roy Hall.  It's now
  898. available via anonymous ftp from:
  899.  
  900.     freedom.graphics.cornell.edu (128.84.247.85)
  901.  
  902. It's under pub/Hall and comes in two files:  1) README (of course) which also
  903. contains some code necessary to convert 2) code.tar.Z.a which contains the
  904. actual code.  So, as always, read README first.
  905.  
  906. Those of you who do not have ftp access may wish to drop me a short line (a
  907. Subject:  of "gimme roy's source" is adequate).  If there's enough interest
  908. I'll post to this group, if not I'll (shudder!)  attempt to mail it right to
  909. you.
  910.  
  911. Also of interest on freedom are the Ray Tracing News archives (under
  912. pub/RTNews) and the Xcu Widget Set.  (Sorry, this code available only in
  913. stores, no mailing.)
  914.  
  915.     fishing in McElligot's Pool,
  916.         to'c
  917.  
  918. -------------------------------------------------------------------------------
  919.  
  920. More on Texture Mapping by Spatial Position, by Paul Lalonde
  921.     From: lalonde@ug.cs.dal.ca
  922.     Newsgroups: comp.graphics
  923.     Organization: Math, Stats & CS, Dalhousie University, Halifax,NS, Canada
  924.  
  925. [This is a continuation of last issue's discussion.  The idea here I would
  926. consider the most popular solution to the problem.  I published most all of
  927. the discussion because some of the answers were more interesting for the ideas
  928. they generated than for practicality. - EAH]
  929.  
  930. In article [...] ranjit@grad1.cis.upenn.edu.UUCP (Ranjit Bhatnagar) writes:
  931.  
  932. >  [Talk about 3-d texture maps deleted for brevity]
  933.  
  934. >I haven't seen discussed before: as generally proposed, it's highly
  935. >unsuited to _animation._  The problem is that you generally define one
  936. >texture function throughout all of space.  If an object happens to move,
  937. >its texture changes accordingly.  It's a neat effect - try it - but it's
  938. >not what one usually wants to see.
  939.  
  940. >The obvious solution to this is to define a separate 3-d texture for
  941. >each object, and, further, _cause the texture to be rotated, translated,
  942. >and scaled with the object._  DBW does not allow this, so if you want
  943. >to do animations of any real complexity with DBW, you can't use the nice
  944. >wood or marble textures.
  945.  
  946. I get around this be keeping not only the general texture stored with the
  947. object, but also an (x,y,z) triple pointing to where the texture is to
  948. be evaluated.  I also keep some orientation information with the object.
  949. The texturing routine then only has to translate the scene coordinate of the
  950. point being textured into texture coordinates.  It comes down to keeping
  951. the textures in object coordinates.  This allows you to carve more than
  952. one object out of the same chunk of marble, which can be quite pleasing.
  953. It also requires very little extra manipulation of the texture.  For shape 
  954. changes you just keep track of your deformation function and apply it to 
  955. the point whose texture you are evaluating.
  956.  
  957. [Another congruent way of describing this is to use modeling matrices to
  958. describe the location (and even deformation) of animated objects.  Since the
  959. object itself without the modeling matrix does not move, the texturing of its
  960. surface does not change. - EAH]
  961.  
  962.         -Paul
  963.  
  964. (Ps. My raytracer implementing this (and other goodies) should be available 
  965. as soon as I finish up my spline surfaces...Real Soon Now)
  966.  
  967. Paul A. Lalonde         UUCP: ...{uunet|watmath}!dalcs!dalcsug!lalonde
  968. Phone: (902)423-4748    BITNET: 05LALOND@AC.DAL.CA
  969.  
  970. -------------------------------------------------------------------------------
  971.  
  972. Procedural Bump-mapping Query, by Prem Subrahmanyam
  973.     From: prem@geomag.fsu.edu
  974.     Newsgroups: comp.graphics
  975.     Organization: Florida State University Computing Center
  976.  
  977. I am going to attempt to employ a few procedural bump-map textures to
  978. DBW_Render (I have no idea how they will turn out).  I would like to start
  979. with some basics, like maybe a "golf-balling" algorithm that will give the
  980. surface small, spherical pits.  Also, a "cross- hatching" one would be nice as
  981. well, one that would produce furrows in a surface.  These should work for both
  982. planar surfaces as well as spherical ones.  So, here's the basic
  983. request....given a point, the normal to the surface at that point as well, how
  984. can I perturb the normal, position of the point, etc.  to create reasonable
  985. bump-maps.
  986.  
  987. One that I'd particularly like to reproduce is found in an old issue of IEEE
  988. Computer Graphics & Applications....the one with the Martian Magnolia in it.
  989. Well, there's this cross-hatching on the spheres on the previous page.  These
  990. would be very nice to try to implement in DBW_Render.  Can anyone point me to
  991. real code (or at least pseudocode) that will tell me how to generate these
  992. types of textures?  Eventually, with all these textures, bump-mapping, etc.
  993. in tow, DBW will be the most kick-butt ray-tracer available to the general
  994. public.
  995.  
  996. -------------------------------------------------------------------------------
  997.  
  998. Ray Tracer Performance on Machines, by Gavin A. Bell, Steve Lamont
  999.  
  1000. [Note: Didier Badouel's timings will appear next issue, as I will be focussing
  1001. on metrics then]
  1002.  
  1003.     From: gavin@krypton.sgi.com (Gavin A. Bell)
  1004.     Newsgroups: comp.graphics
  1005.  
  1006. In article [...], pkh@vap.vi.ri.cmu.edu (Ping Kang Hsiung) writes:
  1007. > Does anyone have a collection of performance (timing) data based 
  1008. > on running a raytracer (preferably a publicly available raytracer, 
  1009. > e.g. mtv or qrt) on various machines? 
  1010.  
  1011. I believe that the BRL-CAD ray-tracer is sometimes used as a standard
  1012. benchmark (with specific input files).  A number is generated which they call
  1013. the 'Ray-tracing figure of merit'; the higher the number, the better.  The
  1014. whole BRL-CAD package is public domain [it's not - see below], but big,
  1015. crufty, and pretty ancient as ray-tracing packages go.
  1016.  
  1017. I know all this because I'm in the Demo/Benchmarks group here at Silicon
  1018. Graphics, and this ray-tracing benchmark is one of the few in which our 4D/280
  1019. outperformed a Cray (ray-tracing being an easily multi-processed, but not
  1020. vectorizable, application).
  1021.  
  1022. If people are interested, I could send them the results.
  1023.  
  1024. --------
  1025.  
  1026. From: phil@sem.BRL.MIL (Phil Dykstra)
  1027.  
  1028. The BRL-CAD package is *not* public domain.  It is Copyright by the U.S.Army
  1029. in order to control commercialization of it.  We do distribute the source code
  1030. at no charge however as long as the recipient agrees, in writing, to the
  1031. conditions.
  1032.  
  1033. > but big, crufty, and pretty ancient as ray-tracing packages go.
  1034.  
  1035. Being one of the authors, I had to put in at least two cents worth of defense.
  1036. Big - yes.  Crufty - parts of it.  Pretty ancient - some of it.  But I
  1037. wouldn't call things like CSG NURBs, arbitrary bounding planes, non-uniform
  1038. space partitioning, parallel *and* network distributed capability very
  1039. ancient.
  1040.  
  1041. --------
  1042.  
  1043.     From: spl@mcnc.org (Steve Lamont)
  1044.     Subject: Re: Raytracer performance on machines?
  1045.     Organization: Foo Bar Brewers Cooperative
  1046.  
  1047. In article <6224@pt.cs.cmu.edu> pkh@vap.vi.ri.cmu.edu (Ping Kang Hsiung) writes:
  1048. >For example, my experience indicates that mtv runs on a
  1049. >Cray Y-MP (-hintrinsic,o_level3) ~2.6x than on a PMAX, is this
  1050. >(Cray time) the fastest turn-around one can expect?
  1051. >Will a Connection Machine do better than this? What about an Intel iPSC?
  1052. >The Meiko transputer array? Silicon Graphics's Power series?
  1053.  
  1054. Well, it depends on what other things you feel prepared to do.  I have both an
  1055. IRIS 4D/120 and a Y-MP here (we just installed a Stardent Titan yesterday,
  1056. also) and see the same sort of numbers.  I'll run a couple of experiments
  1057. today and get back to you with actual bench marks, if you'd like.
  1058.  
  1059. I am currently working on a parallelized version of MTV and should be able to
  1060. give you some results from that in a couple of days, barring getting blown
  1061. away by Hurricane Hugo, that is :-).
  1062.  
  1063. In any case, in order to take advantage of any parallelism on an MPP like a
  1064. CM, you'll probably have to do a lot of recoding.  The CM is a SIMD machine
  1065. which does not really lend itself *directly* to ray tracing.  I understand
  1066. that TMC has done some interesting algorithmic development to actually *do*
  1067. ray tracing, but the code certainly would not look anything like MTV as it
  1068. stands right now.  Barry, are you out there lurking?  Any comments?
  1069.  
  1070. The iPSC and Meiko systems would probably be more straightforward.
  1071.  
  1072. If you're interested in results, contact me by private email and I'll be glad
  1073. to share my thoughts with you.
  1074.  
  1075. -------------------------------------------------------------------------------
  1076.  
  1077. Projective Mapping Explanation, by Ken "Turk" Turkowski
  1078.     From: turk@Apple.COM
  1079.     Newsgroups: comp.graphics
  1080.     Organization: Advanced Technology Graphics, Apple Computer, Cupertino, CA
  1081.  
  1082. In article [...] ccoprrm@pyr.gatech.edu (ROBERT E. MINSK) writes:
  1083. > I am currently trying to add texture mapping to my ray tracer. The problem
  1084. > I am having is texture mapping and normal interpolation to convex
  1085. > quadrilaterals and triangles.  The situation is as follows:
  1086. >  Given 4 points forming a convex planer quadrilateral,the texture vertices
  1087. > associated with each point, and the intersection point on the quadrilateral,
  1088. > find the associated (u,v) mapping coordinates for the intersection point.
  1089. > For example:
  1090. >  4 points       the associated texture vertices
  1091. >  p1=(-5, 1, 2)  t1=(.2,.4)
  1092. >  p2=(-2,-3, 6)  t2=(.4,.2)
  1093. >  p3=( 2,-1, 4)  t3=(.8,.3)
  1094. >  p4=( 1, 4,-1)  t4=(.7,.5)
  1095. > intersection point = (-2,-1, 4)
  1096. > find the (u,v) mapping coordinates
  1097. >
  1098. > I assume a triangle will be the same mapping with two vertices sharing the
  1099. > same points and mapping coordinates.
  1100.  
  1101. For suitably well-behaved texture mappings (i.e.  no bowtie quadrilaterals),
  1102. there is a projective mapping, that maps quadrilaterals to quadrilaterals.
  1103. This is represented by a 3x3 matrix, unique up to a scale factor.
  1104.  
  1105.         [x y z] = [uw vw w] [M]                                         (1)
  1106.  
  1107. where w is a homogeneous coordinate, and [M] is the 3x3 matrix.  Since the 4
  1108. points must obey (1), we have the nonlinear system of equations:
  1109.  
  1110.         |x0 y0 z0|   |u0*w0 v0*w0 w0|
  1111.         |x1 y1 z1|   |u1*w1 v1*w1 w1|
  1112.         |x2 y2 z2| = |u2*w2 v2*w2 w2| [M]                               (2)
  1113.         |x3 y3 z3|   |u3*w3 v3*w3 w3|
  1114.  
  1115. This represents 12 equations in 13 unknowns, but one of the w's may be
  1116. arbitrarily chosen as 1.
  1117.  
  1118. System (2) can be solved for the matrix [M] by any nonlinear system equation
  1119. solver, such as those available in the Collected Algorithms of the ACM.
  1120.  
  1121. When this matrix is inverted, it gives the mapping you desire:
  1122.  
  1123.                                -1
  1124.         [uw vw w] = [x y z] [M]                                         (3)
  1125.  
  1126. You just plug the desired [x y z] into (3), and divide by w.
  1127.  
  1128. For triangles, the mapping (1) is affine:
  1129.  
  1130.         [x y z] = [u v 1] [M]                                           (4)
  1131.  
  1132. and the resulting system is linear:
  1133.  
  1134.         |x0 y0 z0|   |u0 v0 1|
  1135.         |x1 y1 z1| = |u1 v1 1| [M]                                      (5)
  1136.         |x2 y2 z2|   |u2 v2 1|
  1137.  
  1138. This linear equation (9 equations in 9 unknowns) can easily be solved by LU
  1139. decomposition.
  1140.  
  1141. Note that this matrix computed in (2) and (5) depends only on the
  1142. parametrization, so its only needs to be computed once, offline, at the time
  1143. the texture is assigned.
  1144.  
  1145. Take note that the texture parameters are not interpolated linearly (or
  1146. bilinearly), but projectively.  Also note that, unlike standard bilinear
  1147. interpolation (such as that used for Gouraud interpolation) this method of
  1148. interpolation is rotation invariant.
  1149.  
  1150. For more information on projective mappings, see the the book "Projective
  1151. Geometry and Applications to Computer Graphics" by Penna and Patterson.  (I
  1152. hope this reference is correct -- I'm doing it from memory).
  1153.  
  1154. For more detail on this approach to texture-mapping, including texture-mapping
  1155. by scan-conversion, request a copy of the following paper:
  1156.  
  1157. Turkowski, Ken
  1158. The Differential geometry of Texture Mapping
  1159. Apple Technical Report No. 10
  1160. May 10, 1988
  1161.  
  1162. from
  1163.  
  1164. Apple Corporate Library
  1165. Apple Computer, Inc.
  1166. 20525 Mariani Avenue
  1167. Mailstop 8-C
  1168. Cupertino, CA 95014
  1169.  
  1170. The e-mail address for the library is: corp.lib1@applelink.apple.com,
  1171. but the gateway is one-way, so don't expect an electronic reply.
  1172.  
  1173. -------------------------------------------------------------------------------
  1174.  
  1175. Intersection Calculation Problem Request, Jari Toivanen
  1176.     From: toivanen@tukki.jyu.fi
  1177.     Newsgroups: comp.graphics
  1178.     Organization: University of Jyvaskyla, Finland
  1179.  
  1180.  
  1181. I would like to know is there any simple and effective solution to following
  1182. problem:
  1183.  
  1184. I have curve c:[0,1] -> R*R. Curve c is cubic and it's following form
  1185.  
  1186.              3       2                   3       2
  1187. c(t) = (a * t + b * t + c * t + d , a * t + b * t + c * t + d )
  1188.          x       x       x       x   y       y       y       y
  1189.  
  1190. Now I rotate curve c around vector v so that I get surface (or what ever I
  1191. should call it).  Let vector v be
  1192.  
  1193. v = (x  , y  , z  )
  1194.       up   up   up
  1195.  
  1196. Now I should calculate intersection of this surface and given line l.  Let
  1197. line l be
  1198.  
  1199. l = (k * u + x , k * u + y , k * u + z ),  u >= 0
  1200.       x       0   y       0   z       0
  1201.  
  1202. This should be done as fast as possible, because it would be part of ray
  1203. tracer.  I also need surface's normal in the intersection point.
  1204.  
  1205. I've been calculating this, but the solution seems to be quite complicated.
  1206. Is there any other easier way to do something like this?
  1207.  
  1208. Could anyone tell me good books which would help me deal with this kind of
  1209. problems and bicubic surfaces and stuff like that?
  1210.  
  1211. -------------------------------------------------------------------------------
  1212.  
  1213. Mathematical Elements for Computer Graphics - Call for Errata, by David Rogers
  1214.     From: dfr@usna.MIL
  1215.     Newsgroups: comp.graphics
  1216.     Organization: U.S. Naval Academy, Annapolis, MD
  1217.  
  1218. MATHEMATICAL ELEMENTS FOR COMPUTER GRAPHICS 2nd edition
  1219. David F. Rogers & J. Alan Adams
  1220. McGraw-Hill Book Co. 1990
  1221.  
  1222. hardcover -- ISBN 0-07-053529-9
  1223.  
  1224. My own interest is in asking those of you who use the book for some
  1225. assistance.  No matter how careful the authors and proofreaders are all books
  1226. have typos.  If you use the book and find a typo (or something that you think
  1227. is wrong) please [send a bug report and] tell me about it.  I will have a
  1228. chance to correct these typos in about June 1990.  In a few months, I'll
  1229. summarize those that I have received and publish an errata list to the net.
  1230.  
  1231. Thanks in advance.
  1232.  
  1233. Dave Rogers
  1234.  
  1235. -------------------------------------------------------------------------------
  1236.  
  1237. Raytracing on NCUBE Request, by Ping Kang Hsiung
  1238.     From: pkh@vap.vi.ri.cmu.edu
  1239.     Newsgroups: comp.graphics
  1240.     Organization: Carnegie-Mellon University, CS/RI
  1241.  
  1242. Has anyone had ported/run raytracing on NCUBE?  I would like to learn about
  1243. your experience; including raytracer name, NCUBE node number (NCUBE 2 or 1?),
  1244. port time, performance, features/tricks, etc.
  1245.  
  1246. -------------------------------------------------------------------------------
  1247.  
  1248. Intersection Between a Line and a Polygon (UNDECIDABLE??),
  1249.     by Dave Baraff, Tom Duff
  1250.  
  1251.     From: deb@charisma.graphics.cornell.edu
  1252.     Newsgroups: comp.graphics
  1253.     Keywords: P, NP, Jordan curve separation, Ursyhon Metrization Theorem
  1254.     Organization: Program of Computer Graphics
  1255.  
  1256. In article [...] ncsmith@ndsuvax.UUCP (Timothy Lyle Smith) writes:
  1257. >
  1258. >  I need to find a formula/algorithm to determine if a line intersects
  1259. >  a polygon.  I would prefer a method that would do this in as little
  1260. >  time as possible.  I need this for use in a forward raytracing
  1261. >  program.
  1262.  
  1263. I think that this is a very difficult problem.  To start with, lines and
  1264. polygons are semi-algebraic sets which both contain uncountable number of
  1265. points.  Here are a few off-the-cuff ideas.
  1266.  
  1267. First, we need to check if the line and the polygon are separated.  Now, the
  1268. Jordan curve separation theorem says that the polygon divides the plane into
  1269. exactly two open (and thus non-compact) regions.  Thus, the line lies
  1270. completely inside the polygon, the line lies completely outside the polygon,
  1271. or possibly (but this will rarely happen) the line intersects the polyon.
  1272.  
  1273. Now, the phrasing of this question says "if a line intersects a polygon", so
  1274. this is a decision problem.  One possibility (the decision model approach) is
  1275. to reduce the question to some other (well known) problem Q, and then try to
  1276. solve Q.  An answer to Q gives an answer to the original decision problem.
  1277.  
  1278. In recent years, many geometric problems have been successfully modeled in a
  1279. new language called PostScript.  (See "PostScript Language", by Adobe Systems
  1280. Incorporated, ISBN # 0-201-10179-3, co. 1985).
  1281.  
  1282. So, given a line L and a polygon P, we can write a PostScript program that
  1283. draws the line L and the polygon P, and then "outputs" the answer.  By
  1284. "output", we mean the program executes a command called "showpage", which
  1285. actually prints a page of paper containing the line and the polygon.  A quick
  1286. examination of the paper provides an answer to the reduced problem Q, and thus
  1287. the original problem.
  1288.  
  1289. There are two small problems with this approach. 
  1290.  
  1291.     (1) There is an infinite number of ways to encode L and P into the
  1292.     reduced problem Q.  So, we will be forced to invoke the Axiom of
  1293.     Choice (or equivalently, Zorn's Lemma).  But the use of the Axiom of
  1294.     Choice is not regarded in a very serious light these days.
  1295.  
  1296.     (2) More importantly, the question arises as to whether or not the
  1297.     PostScript program Q will actually output a piece of paper; or in
  1298.     other words, will it halt?
  1299.  
  1300.     Now, PostScript is expressive enough to encode everything that a
  1301.     Turing Machine might do; thus the halting problem (for PostScript) is
  1302.     undecidable.  It is quite possible that the original problem will turn
  1303.     out to be undecidable.
  1304.  
  1305.  
  1306. I won't even begin to go into other difficulties, such as aliasing, finite
  1307. precision and running out of ink, paper or both.
  1308.  
  1309. A couple of references might be:
  1310.  
  1311. 1. Principia Mathematica.  Newton, I.  Cambridge University Press, Cambridge,
  1312.    England.  (Sorry, I don't have an ISBN# for this).
  1313.  
  1314. 2. An Introduction to Automata Theory, Languages, and Computation.  Hopcroft, J
  1315.    and Ulman, J.
  1316.  
  1317. 3. The C Programming Language. Kernighan, B and Ritchie, D.
  1318.  
  1319. 4. A Tale of Two Cities. Dickens, C.
  1320.  
  1321. --------
  1322.  
  1323. From: td@alice.UUCP (Tom Duff)
  1324. Summary: Overkill.
  1325. Organization: AT&T Bell Laboratories, Murray Hill NJ
  1326.  
  1327. The situation is not nearly as bleak as Baraff suggests (he should know
  1328. better, he's hung around The Labs for long enough).  By the well known
  1329. Dobbin-Dullman reduction (see J. Dullman & D. Dobbin, J. Comp. Obfusc.
  1330. 37,ii:  pp. 33-947, lemma 17(a)) line-polygon intersection can be reduced to
  1331. Hamiltonian Circuit, without(!) the use of Grobner bases, so LPI (to coin an
  1332. acronym) is probably only NP-complete.  Besides, Turing-completeness will no
  1333. longer be a problem once our Cray-3 is delivered, since it will be able to
  1334. complete an infinite loop in 4 milliseconds (with scatter-gather.)
  1335.  
  1336. --------
  1337.  
  1338. From: deb@svax.cs.cornell.edu (David Baraff)
  1339.  
  1340. Well, sure its no worse than NP-complete, but that's ONLY if you restrict
  1341. yourself to the case where the line satisfies a Lipschitz condition on its
  1342. second derivative.  (I think there's an '89 SIGGRAPH paper from Caltech that
  1343. deals with this).
  1344.  
  1345. -------------------------------------------------------------------------------
  1346. END OF RTNEWS
  1347.