![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Include file with many shapes, and a scene file that uses all of them.
Post a reply to this message
Attachments:
Download 'polyhedra_demo.pov.txt' (8 KB)
Download 'us-ascii' (25 KB)
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Revised demo for my include file. Text is easier to read in rendered image.
Dan Johnson
Post a reply to this message
Attachments:
Download 'polyhedra_demo.pov.txt' (8 KB)
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Tor Olav Kristensen wrote:
> 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
>
I think it took me three days to figure out how to make that macro work. After that I
didn't want to look at it anymore. Do you
understand what it does, and how?
This function started when I made my fist cube out of cylinders, and I looked at the
resulting points.
<0,0,0>
<0,0,1>
<0,1,0>
<0,1,1>
<1,0,0>
<1,0,1>
<1,1,0>
<1,1,1>
Hmm binary. So I made a little macro based on base10 to binary conversion.
//macro Cube_points returns a vector for a corner of a cube given an integer 1-8
periodic after 8
#macro Cube_points (N)
(mod(N,2)*2*z + mod(div(N+1,2),2)*2*y + mod(div(N+3,4),2)*2*x -1)
#end
Then I realized that it could be made much more versatile, and I set out to make a
cubic lattice of any dimensions. Since the
order of placement was still based on my binary algorithm it arranged things in a way
people don't usually think. I changed
things around until it went left to right, top to bottom, front to back ( like a
book). The arrange 3d function is the result.
More recently I figured out that it could be made even more versatile. I could do
things like have three in one row, and four in
the next, and continue alternating. I think I may be able to make a macro that will
spit out the coordinates of icosahedron
vertexes. That would go a long way towards simplifying the process of making an 8
frequency geodesic dome.
>
> > #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.
>
Didn't understand how the array function worked, makes sense now.
>
> I hope this triggers some ideas... :)
>
It has.
>
> Regards,
>
> Tor Olav
> --
> mailto:tor### [at] hotmail com
> http://www.crosswinds.net/~tok/tokrays.html
Dan Johnson
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Dan Johnson wrote:
>
> Tor Olav Kristensen wrote:
>
> > 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
> > >...
>
>...
> I think it took me three days to figure out how to make that macro work. After that
I didn't want to look at it anymore. Do you
> understand what it does, and how?
Yes, I understand what it does.
And now I also understand what's going on.
I think this macro is a clever idea !
> This function started when I made my fist cube out of cylinders, and I looked at the
resulting points.
> <0,0,0>
> <0,0,1>
> <0,1,0>
> <0,1,1>
> <1,0,0>
> <1,0,1>
> <1,1,0>
> <1,1,1>
>
> Hmm binary. So I made a little macro based on base10 to binary conversion.
>
> //macro Cube_points returns a vector for a corner of a cube given an integer 1-8
periodic after 8
> #macro Cube_points (N)
> (mod(N,2)*2*z + mod(div(N+1,2),2)*2*y + mod(div(N+3,4),2)*2*x -1)
> #end
Of course I have to "twist" your code a little bit ;)
<mod(div(N + 3, 4), 2), mod(div(N + 1, 2), 2), mod(N, 2)>*2 - <1, 1, 1>
Hmmm... so it would go on like this:
mod(div(N + (2^0 - 1), 2^0), 2) -> mod(div(N + 0, 1), 2) -> mod(N, 2)
mod(div(N + (2^1 - 1), 2^1), 2) -> mod(div(N + 1, 2), 2)
mod(div(N + (2^2 - 1), 2^2), 2) -> mod(div(N + 3, 4), 2)
mod(div(N + (2^3 - 1), 2^3), 2) -> mod(div(N + 7, 8), 2)
mod(div(N + (2^4 - 1), 2^4), 2) -> mod(div(N + 15, 16), 2)
...
> Then I realized that it could be made much more versatile, and I set out to make a
cubic lattice of any dimensions. Since the
> order of placement was still based on my binary algorithm it arranged things in a
way people don't usually think. I changed
> things around until it went left to right, top to bottom, front to back ( like a
book). The arrange 3d function is the result.
>
> More recently I figured out that it could be made even more versatile. I could do
things like have three in one row, and four in
> the next, and continue alternating. I think I may be able to make a macro that will
spit out the coordinates of icosahedron
> vertexes. That would go a long way towards simplifying the process of making an 8
frequency geodesic dome.
If you manage to do that (or even if you come close)
then please post your results !
--
Best regards,
Tor Olav
mailto:tor### [at] hotmail com
http://www.crosswinds.net/~tok/tokrays.html
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |