POV-Ray : Newsgroups : povray.windows : Surface Coefficients??? : Re: Surface Coefficients??? Server Time
28 Jul 2024 18:13:17 EDT (-0400)
  Re: Surface Coefficients???  
From: Tristan Wibberley
Date: 13 Feb 1970 09:34:22
Message: <01bd3883$d2042480$181657a8@W_tristan.gb.tandem.com>
Doh yeah...

Ronald L. Parker <ron### [at] farmworkscom> wrote in article
<34e### [at] 100233>...
| On 11 Feb 98 15:12:17 GMT, "Tristan Wibberley"
| <tri### [at] compaqcom> wrote:
| 
| >Look at how the 4th order goes
| >extend to 5th
| >
| >The numbers give which power of each of x, y and z are in each term.
| >To extend further, count down in base n (eg 6th order use base 6) from
n00
| >to get each term.
| 
| Not quite.  For example, there is no 440 term.  Only terms 
| of order 6 or less are included.  Also, of course, you must 
| include 600, 060, and 006, which are not legal numbers in 
| base 6.  So the real answer is: count down (base 10) from 
| 777, and only include numbers where the sum of the digits 
| is equal to or less than the order of the polynomial you're 
| generating.  Of course, there are easier and more efficient
| ways to do it.
| 
| Here's a perl program that will generate the terms in 
| the correct order, suitable for including in a POV file.
| to use it on Unix, just call it "coeffs", make it mode 700,
| and type "coeffs 6 >coeffs.out" to create a file called 
| "coeffs.out" containing the definition for a poly of order 
| 6.  Under Windows, you'll have to type 
| "perl coeffs 6 >coeffs.out" and make sure perl.exe is in
| your path somewhere.  To find a recent port of Perl for
| your machine, see http://cpan.perl.org/ports/
| 
| Programmers in other languages, feel free to borrow this 
| and rewrite it for the Perl-deprived.  Windows and Mac
| users, hop over to povray.binaries.utilities and grab
| the template file I'll post over there shortly.
| 
| ----------- cut here ------>8==========
| #!/usr/bin/perl -w
| 
| use strict;
|  
| my $order = $ARGV[0];
| print "poly { $order, <\n";
| for ( my $x=$order; $x >= 0; $x-- ) {
|   for ( my $y=$order-$x; $y >= 0; $y-- ) {
|     for ( my $z=$order-$y-$x; $z >= 0; $z-- ) {
|       print '  0';
|       if ($x+$y+$z) {
|         print ', /* ';
|         print 'x' if ($x);
|         print $x if ($x>1);
|         print 'y' if ($y);
|         print $y if ($y>1);
|         print 'z' if ($z);
|         print $z if ($z>1);
|         print ' */';
|       }
|     print "\n";
|     }
|   }
| }
| 
| print "> }\n";
| ----------- cut here ------>8==========
| 
| Here's a sample of the output, for order 3:
| 
| poly { 3, <
|   0, /* x3 */
|   0, /* x2y */
|   0, /* x2z */
|   0, /* x2 */
|   0, /* xy2 */
|   0, /* xyz */
|   0, /* xy */
|   0, /* xz2 */
|   0, /* xz */
|   0, /* x */
|   0, /* y3 */
|   0, /* y2z */
|   0, /* y2 */
|   0, /* yz2 */
|   0, /* yz */
|   0, /* y */
|   0, /* z3 */
|   0, /* z2 */
|   0, /* z */
|   0
| > }
| 
|


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.