|
 |
Dan Johnson wrote:
>
> #macro Arrange_3d (A,B,C,N)
> ( (mod(N+A-1,A))*x + (B-mod(div(N+A-1,A)+B-1,B))*y +
(mod(div(N+B*A-1,B*A)+C-1,C))*z -<A-1,B+1,C-1>/2)
> #end // use only natural numbers aka 1,2,3,4,5,6... no fractions 0 or negative
numbers
>...
A little nit-picking from me follows ...
The above macro could be slightly simplified like this:
#macro Arrange_3d(A, B, C, N)
(< mod(N+A-1,A),
-mod(div(N+A-1,A)+B-1,B),
mod(div(N+B*A-1,B*A)+C-1,C)>-
<A-1,-B+1,C-1>/2)
#end // macro Arrange_3d
Or like this:
#macro MM(M,N)
mod(N+M-1,M)
#end // macro MM
#macro DD(M,N)
div(N+M-1,M)
#end // macro DD
#macro Arrange_3d(A,B,C,N)
(<MM(A,N),MM(B,DD(A,N)),MM(C,DD(A*B,N))>-<A-1,B-1,C-1>/2)*(x-y+z)
#end // macro Arrange_3d
> #declare Golden2 = (Golden -1); // the golden ratio is the only ratio where one is
the difference between it and its inverse
I didn't know that. Interesting fact.
It's a lot of math work you have done with this include !
Maybe you could make some more general macros that
handles arrays containing the coordinates for the
different cylinders, spheres, torii and planes and
then "spreads" them around to their positions ?
E.g.
If you declared and array like this:
#declare IcosahedronVertexArray =
array [12] {
< Golden2, 0, Golden3>,
< Golden2, 0, -Golden3>,
< Golden3, Golden2, 0>,
< Golden3, -Golden2, 0>,
< 0, Golden3, Golden2>,
< 0, Golden3, -Golden2>,
< 0, -Golden3, Golden2>,
< 0, -Golden3, -Golden2>,
<-Golden3, Golden2, 0>,
<-Golden3, -Golden2, 0>,
<-Golden2, 0, Golden3>,
<-Golden2, 0, -Golden3>
}
Then you could write things like this:
#include "glass.inc"
#declare SphereCentreArray =
ScaleArray(IcosahedronVertexArray, 3);
#declare SphereRadii = 0.5;
merge {
SphereSpread(SphereCenterArray, SphereRadii)
interior { I_Glass }
texture { T_Glass3 }
}
The ScaleArray macro just multiplies every
vector in the array by a scalar.
And the SphereSpread macro just puts a sphere
in every position given in the array.
I hope this triggers some ideas... :)
Regards,
Tor Olav
--
mailto:tor### [at] hotmail com
http://www.crosswinds.net/~tok/tokrays.html
Post a reply to this message
|
 |