POV-Ray : Newsgroups : povray.windows : Surface Coefficients??? Server Time
24 Nov 2024 23:22:09 EST (-0500)
  Surface Coefficients??? (Message 1 to 6 of 6)  
From: Stephen Horn
Subject: Surface Coefficients???
Date: 25 Jan 1998 03:23:46
Message: <34caf672.308033992@news.povray.org>
POV-Ray v3.02 can render up to 7th-degree polynomial surfaces.

The documentation does not say what the coefficents are in the order
that they need to be in a poly{} statement.  They have great examples
for quartics of degree 4, but for 5th, 6th, and 7th there is nothing
in any of the help files or the documentation!

What are the surface coefficents in order???
Thank you for your help!


SteveH


Post a reply to this message

From: Tristan Wibberley
Subject: Re: Surface Coefficients???
Date: 11 Feb 1970 10:12:17
Message: <01bd36f6$c022c200$181657a8@W_tristan.gb.tandem.com>
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.

4th and 5th		inserted for 5th only
			(delete three tabs before each)
x^	y	z^	x^	y^	z^
			5	0	0
			4	1	0
			4	0	0
4	0	0
			3	2	0
			3	1	1
3	1	0
			3	0	2
3	0	1
3	0	0
			2	3	0
			2	2	1
2	2	0
			2	1	2
2	1	1
2	1	0
			2	0	3
2	0	2
2	0	1
2	0	0
			1	4	0
			1	3	1
1	3	0
			1	2	2
1	2	1
1	2	0
			1	1	3
1	1	2
1	1	1
1	1	0
			1	0	4
1	0	3
1	0	2
1	0	1
1	0	0
			0	5	0
			0	4	1
0	4	0
			0	3	2
0	3	1
0	3	0
			0	2	3
0	2	2
0	2	1
0	2	0
			0	1	4
0	1	3
0	1	2
0	1	1
0	1	0
			0	0	5
0	0	4
0	0	3
0	0	2
0	0	1
0	0	0

-- 
Tristan Wibberley

(Remove the '.NO_LUNCHEON_MEAT' from my
email address to reply.)

Stephen Horn <hor### [at] osuedu> wrote in article
<34caf672.308033992@news.povray.org>...
| POV-Ray v3.02 can render up to 7th-degree polynomial surfaces.
| 
| The documentation does not say what the coefficents are in the order
| that they need to be in a poly{} statement.  They have great examples
| for quartics of degree 4, but for 5th, 6th, and 7th there is nothing
| in any of the help files or the documentation!
| 
| What are the surface coefficents in order???
| Thank you for your help!
| 
| 
| SteveH
|


Post a reply to this message

From: Ronald L  Parker
Subject: Re: Surface Coefficients???
Date: 11 Feb 1998 10:51:34
Message: <34e2bb13.6909575@10.0.2.33>
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

From: Ken Cecka
Subject: Re: Surface Coefficients???
Date: 11 Feb 1998 14:38:52
Message: <34e20b29.0@news.povray.org>
I can't claim authorship of this, but here's a perl script which will take a
fairly standard infix notation equation (as opposed to postfix/referse
polish or prefix), and spit out the pov code for you.  Someone posted it on
CGRR way back when and I've kept a copy handy.

An example session is as follows:

bash-2.01$ echo "x^2*y^2*z^2+x^2*z^2+x*y*z=0"|poveq
poly {
    6, <0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>
}

I know it's kind of finicky about spaces and such, but usually if you play
arround with it, you can get what you want.  The source file is listed
below.

Ken

----cut here---
#!/usr/bin/perl

while(<>)
{
    chop;
    $eq .= $_;
}

foreach $comp (split('\s*\+\s*',$eq))
{
    $comp =~ s/\s+//;
    $x=0; $y=0; $z=0; $coef=1;
    foreach $factor (split('\*',$comp))
    {
        if ($factor =~ /^[xyz]/)


            ($var,$exp) = ($factor =~ /^([xyz])\^?(\d+)?/);
            $exp = 1 if ($exp =~ /^$/);
            eval "\$$var = $exp";
        } else {
            $coef = $factor;
        }
    }
    $equation{$x,$y,$z} = $coef;
    $power = $x+$y+$z if ($x+$y+$z > $power);
}

print "poly {\n    $power, <";

$first = 1;
for($x=$power;$x>=0;$x--)
{
    for($y=$power-$x;$y>=0;$y--)
    {
        for($z=$power-$x-$y;$z>=0;$z--)
        {
            #print "\n$x,$y,$z\n";
            print ", " if (!$first);
            $first = 0;
            if ($equation{$x,$y,$z})
            {
                print "$equation{$x,$y,$z}";
            } else {
                print "0";
            }
        }
    }
}
print ">\n}\n";

------cut here-------



Ronald L. Parker wrote in message <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

From: Ronald L  Parker
Subject: Re: Surface Coefficients???
Date: 11 Feb 1998 16:07:27
Message: <34e20bd7.27585015@10.0.2.33>
On Wed, 11 Feb 1998 11:38:52 -0800, "Ken Cecka" <cec### [at] televarcom>
wrote:

>I can't claim authorship of this, but here's a perl script which will take a
>fairly standard infix notation equation (as opposed to postfix/referse
>polish or prefix), and spit out the pov code for you.  Someone posted it on
>CGRR way back when and I've kept a copy handy.
>
>An example session is as follows:
>
>bash-2.01$ echo "x^2*y^2*z^2+x^2*z^2+x*y*z=0"|poveq

Note that "x^2-y^2=5" has to be represented as "x^2+-1*y^2+-5".  The
constant term after the '=' in your example is ignored.  

Here's a version that works with the more intuitive  "x^2-y^2=5".  It
also fixes a syntax error in the original code, plus an error that
would occur if the input didn't end with a newline.

=====8<---- cut here ---------
#!/usr/bin/perl

while(<>) {
    chomp;
    $eq .= $_;
}

$coef=1;

$equation{0,0,0}=0-$1 if ( $eq =~ s/=(.*)$// );

foreach $comp (split('\s*([+-])\s*',$eq)) {
    $comp =~ s/\s+//;
    $x=0; $y=0; $z=0; 
    $coef = -1, next if ( $comp eq '-' ); 
    $coef = 1, next if ( $comp eq '+' );
    foreach $factor (split('\*',$comp)) {
        if ($factor =~ /^[xyz]/) {
            ($var,$exp) = ($factor =~ /^([xyz])\^?(\d+)?/);
            $exp = 1 if ($exp =~ /^$/);
            eval "\$$var = $exp";
        } else {
            $coef *= $factor;
        }
    }
    $equation{$x,$y,$z} = $coef;
    $power = $x+$y+$z if ($x+$y+$z > $power);
}

print "poly {\n    $power, <";

$first = 1;
for($x=$power;$x>=0;$x--) {
    for($y=$power-$x;$y>=0;$y--) {
        for($z=$power-$x-$y;$z>=0;$z--) {
            #print "\n$x,$y,$z\n";
            print ", " if (!$first);
            $first = 0;
            if ($equation{$x,$y,$z}) {
                print "$equation{$x,$y,$z}";
            } else {
                print "0";
            }
        }
    }
}
print ">\n}\n";
=====8<---- cut here ---------


Post a reply to this message

From: Tristan Wibberley
Subject: Re: Surface Coefficients???
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.