|
|
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> - I've been working on some some macros that create functions for calculating
> with complex numbers.
Very nice.
I was consulting the stuff that Paul Nylander wrote. I'm assuming yours are
similar.
(He's using loops and macros to make triangles...)
//Complex Functions
#macro Square(X) X*X #end
#macro Complex(X,Y) <X,Y> #end
#declare I=Complex(0,1);
#macro Re(Z) Z.x #end
#macro Im(Z) Z.y #end
#macro Abs(Z) vlength(Z) #end // sqrt(square(Re(Z))+square(Im(Z)))
#macro Arg(Z)
#if(Abs(Z)=0)
#local theta=0;
#else
#local theta=atan2(Im(Z),Re(Z));
#end
theta
#end
#macro Sqr(Z) Complex(square(Re(Z))-square(Im(Z)),2*Re(Z)*Im(Z)) #end
#macro Pow(Z,n)
#local r=Abs(Z);
#if(r=0)
#local z2=Complex(0,0);
#else
#local theta=n*Arg(Z);
#local z2=pow(r,n)*Complex(cos(theta),sin(theta));
#end
z2
#end
#macro Mult(z1,z2)
Complex(Re(z1)*Re(z2)-Im(z1)*Im(z2),Im(z1)*Re(z2)+Re(z1)*Im(z2)) #end
#macro Exp(Z) exp(Re(Z))*Complex(cos(Im(Z)),sin(Im(Z))) #end
#macro Sinh(Z) Complex(cos(Im(Z))*sinh(Re(Z)),sin(Im(Z))*cosh(Re(Z))) #end
#macro Cosh(Z) Complex(cos(Im(Z))*cosh(Re(Z)),sin(Im(Z))*sinh(Re(Z))) #end
I made these two to just keep track
#macro Argument (Re, Im)
atan2 (Re, Im)
#end
#macro Modulus (Re, Im)
sqrt (pow (Re, 2) + pow (Im, 2))
#end
> And yesterday I made some functions that can be used for HSV-coloring of
> pigments.
I worked those out from the macros in colors.inc. A little challenging at first
to turn that whole thing into a function. ;)
This is looking great! I'm sure there are a lot of other interesting complex
surfaces to be explored. I'm also wondering how hard it would be to use mod()
to have an infinite array of those "black hole vortices" on a plane - in either
a rectangular or an alternating/hexagonal arrangement...
Post a reply to this message
|
|