POV-Ray : Newsgroups : povray.beta-test : Functions more than 65535 Server Time
29 Jul 2024 16:30:11 EDT (-0400)
  Functions more than 65535 (Message 25 to 34 of 34)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Thorsten Froehlich
Subject: Re: Functions more than 65535
Date: 14 May 2002 11:14:30
Message: <3ce129d6@news.povray.org>
In article <3ce10bf7@news.povray.org> , "Michael Goldshteyn" <mik### [at] wwacom>
wrote:

> Why not just call out to Perl and be done.

I won't even try to explain what nonsense such a suggestion is.

    Thorsten


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Functions more than 65535
Date: 14 May 2002 13:57:58
Message: <3CE14F6A.541E31CD@hotmail.com>

> 
> On Tue, 14 May 2002 10:29:54 +0200, "Thorsten Froehlich" <tho### [at] trfde>
> wrote:
> > It would have to return multiple results in some cases, which is not really
> > possible right now...
> 
> But knowing max order of polynomial I know max number of roots so can ask for
> n-th root. Additional function could return number of roots to check if there
> is any.

Funny that you should mention this now.

Since a few months after I started to use POV-Ray,
I have tried to make some macros that would do
matrix and polynomial calculations.

But the "Dangling pointer bug" made this work very
difficult.

But now that it is soon all gone, I have managed to
take these macros some further.

The code below shows how some of the polynomial
macros works as they are now.

If there is enough interest in these macros, then
maybe I'll take the time to make some documentation
or examples on how to use them.


Tor Olav



#declare RR = array[5] { -3, 4, 0, 5, 1/3 }
PrintRoots(RR, "x")
// ((x + 3)*(x - 4)*x*(x - 5)*(x - 0.333333))


// Assemble a polynomial from roots:

// ((x + 3)*(x - 4)*x*(x - 5)*(x - 0.333333))
#declare P0 = P_FromRoots(RR)
Print_P(P0, "x")
// (0 -20*x +62.333333*x^2 -5*x^3 -6.333333*x^4 +x^5)


// Find real roots of a polynomial:

// (0 -20*x +187/3*x^2 -5*x^3 -19/3*x^4 +x^5)
PrintRoots(R_RootsOf_P(array[6] { 0, -20, 187/3, -5, -19/3, 1 }), "x")
// (x*(x - 0.333333)*(x - 5)*(x - 4)*(x + 3))


// Multiply two polynomials:

// (x - 4)*(x - 1/3) 
#declare P1 = P_Mult(P_FromRoot(4), P_FromRoot(1/3))
Print_P(P1, "x")
// (1.333333 -4.333333*x +x^2)


// Divide one polynomial by another:

// (0 -20*x +187/3*x^2 -5*x^3 -19/3*x^4 +x^5)/(4/3 -13/3*x +x^2)
Print_P(P_Div(P0, P1), "x")
// (0 -15*x -2*x^2 + x^3)


// Differentiate a polynomial once:

// (2 -A +3*A^2 +A^3 +A^4)
#declare P2 = array[5] { 2, -1, 3, 1, 1 }
Print_P(P_Diff(P2, 1), "A")
// (-1 +6*A +3*A^2 +4*A^3)


// Integrate a polynomial twice:

// (-1 +6*A +3*A^2 +4*A^3)
#declare P3 = array[4] { -1, 6, 3, 4 }
Print_P(P_Int(P3, 2), "A")
// (0 -0.500000*A^2 +A^3 +0.250000*A^4 +0.200000*A^5)


// Assemble polynomial from a multiple root:

// (t - 2)*(t - 2)*(t - 2)*(t - 2)*(t - 2)
Print_P(P_FromRepeatedRoot(2, 5), "t")
// (-32 +80*t -80*t^2 +40*t^3 -10*t^4 +t^5)


// Make a Bernstein polynomial:

Print_P(P_Bernstein(1, 4), "y")
// ( 0 +4*y -12*y^2 +12*y^3 -4*y^4)


// Make a Fibonacci polynomial:

#declare PF = P_Fibonacci(7)
Print_P(PF, "u")
// (1 + 6*u^2 +5*u^4 +u^6)

#declare Fib7PolyFn = PolyFunction(PF)
#debug str(Fib7PolyFn(1), 0, 0)
// 13 // I.e. the 7th Fibonacci number


// And several other more or less useful polynomial macros
// together with a whole set of matrix calculation macros.


Post a reply to this message

From: Warp
Subject: Re: Functions more than 65535
Date: 14 May 2002 16:46:10
Message: <3ce17791@news.povray.org>
Using this as a math library would be really cool:
http://www.parigp-home.de/

  That library is just incredible.
  Besides supporting arbitrarily long integer, rational and floating point
numbers and almost any mathematical function and operation you could imagine,
it's amazingly fast.
  For example it calculated the factors of the number
1000000000000000000000000000000000000000000000000000000003
(2448952313317 * 113619994412549 * 3593891055967117960201170304091)
in less than 13 seconds in this computer (500MHz UltraSparc).

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Functions more than 65535
Date: 14 May 2002 16:56:40
Message: <3ce17a08@news.povray.org>
In article <3ce17791@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>   Using this as a math library would be really cool:
> http://www.parigp-home.de/

Unfortunately it has the root of all evil attached to it (even worse it has
the 2.0 version attached) and it is not suitable for development of truly free
programs or any software that matters :-(

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Warp
Subject: Re: Functions more than 65535
Date: 14 May 2002 17:29:18
Message: <3ce181ad@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> Unfortunately it has the root of all evil attached to it (even worse it has
> the 2.0 version attached)

  What? Do you mean it's GPL?

> and it is not suitable for development of truly free
> programs or any software that matters :-(

  How so?

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Functions more than 65535
Date: 14 May 2002 17:37:32
Message: <3ce1839c@news.povray.org>
In article <3ce181ad@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>> Unfortunately it has the root of all evil attached to it (even worse it has
>> the 2.0 version attached)
>
>   What? Do you mean it's GPL?

Yes, and it is the "real" GPL version 2.0, not LGPL :-(

>> and it is not suitable for development of truly free
>> programs or any software that matters :-(
>
>   How so?

All the nice new clauses in the 2.0 version of the GPL that allow the FSF (aka
RMS who forced these changed into version 2.0) to change the license as they
see fit against the original authors intent.  For all you know they could
decide to add a "may not be run on a non-GPL operating system" one day...

You know, RMS already decided to call Linux "GNU/Linux"...

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Warp
Subject: Re: Functions more than 65535
Date: 14 May 2002 18:26:34
Message: <3ce18f1a@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> All the nice new clauses in the 2.0 version of the GPL that allow the FSF (aka
> RMS who forced these changed into version 2.0) to change the license as they
> see fit against the original authors intent.  For all you know they could
> decide to add a "may not be run on a non-GPL operating system" one day...

  Hmm, the pari/gp-library says:

"PARI/GP is free software, covered by the GNU General Public License, and 
comes WITHOUT ANY WARRANTY WHATSOEVER."

  The GPL license on the other hand says:

"If the Program does not specify a version number of this License, you
may choose any version ever published by the Free Software Foundation."

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From:
Subject: Re: Functions more than 65535
Date: 15 May 2002 02:06:20
Message: <aju3eugahn1u89kknijs52f1eh2qvff24e@4ax.com>
On Tue, 14 May 2002 19:54:50 +0200, Tor Olav Kristensen
<tor### [at] hotmailcom> wrote:
> If there is enough interest in these macros, then
> maybe I'll take the time to make some documentation
> or examples on how to use them.

just rewrite it as functions, I need solver as function for iso_csg library

ABX


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Functions more than 65535
Date: 15 May 2002 04:07:40
Message: <3CE2167C.37235931@hotmail.com>

> 
> On Tue, 14 May 2002 19:54:50 +0200, Tor Olav Kristensen
> <tor### [at] hotmailcom> wrote:
> > If there is enough interest in these macros, then
> > maybe I'll take the time to make some documentation
> > or examples on how to use them.
> 
> just rewrite it as functions, I need solver as function for iso_csg library

That would generate a somewhat ugly function !

And it would be limited too, because I think
that it is difficult to make functions that
are able to do polynomial divisions of arbitrary
degree polynomials as it goes along.

But maybe something can be done in the 3D case;

One function uses Newton/Raphson method to find a
root and then returns it. Three other functions
receives this root together with the coefficients
for the 3rd deg polynomial, which they use for
polynomial division and returns a single coefficient
each for the resulting 2dn deg polynomial. Then two
more functions receives these 3 coefficients and
calculates one root each of the 2nd deg polynomial.

#declare PolyFn = function(x) { a + b*x + c*x^2 + d*x^3 }
#declare DifferentiatedPolyFn = function(x) { b + 2*c*x + 3*d*x^2 }

// Uses PolyFn and DifferentiatedPolyFn
#declare Root1Fn = function(a, b, c, d) { ... }

// Uses Root1Fn
#declare D_2D_Fn = function(A, B, C, D, R) { ... }
#declare E_2D_Fn = function(A, B, C, D, R) { ... }
#declare F_2D_Fn = function(A, B, C, D, R) { ... }

// 2nd deg polynomial is now:
//  D_2D_Fn(a,b,c,d,Root1Fn(a,b,c,d))
// +E_2D_Fn(a,b,c,d,Root1Fn(a,b,c,d))*x
// +F_2D_Fn(a,b,c,d,Root1Fn(a,b,c,d))*x^2

// Uses D_2D_Fn, E_2D_Fn and F_2D_Fn
#declare Root2 = function(D, E, F) { ... }
#declare Root3 = function(D, E, F) { ... }


Tor Olav

Btw.: Congratulations !!!
I guess you'll have less time for POV-ing now ;)


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Functions more than 65535
Date: 15 May 2002 05:02:29
Message: <3ce22425@news.povray.org>
Tor Olav Kristensen wrote:

> <snip>
> Btw.: Congratulations !!!
> I guess you'll have less time for POV-ing now ;)

A good excuse for him to stay up all night.  So more time for POV-ing ;-)

Congratulations!

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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