POV-Ray : Newsgroups : povray.text.scene-files : Improved GEM MACRO Server Time
28 Jul 2024 16:32:14 EDT (-0400)
  Improved GEM MACRO (Message 1 to 3 of 3)  
From: Simen Kvaal
Subject: Improved GEM MACRO
Date: 18 Oct 1999 11:26:45
Message: <380b3c35@news.povray.org>
Hi folks!

I have updated the macro! It had several bugs, but they should be fixed now.
PLEASE TELL ME WHAT YOU THINK OF THIS! Any suggestions/improvements?

Features:
-correct bounding.
-unit scaling - the object will always fit into a unis sphere centered at
<0, 0, 0>
-more freedom. The last version "featured" a top-plane, always making the
gem flat on top.

If anyone wants to use it, feel free.

Here are some details on how to use it:
The idea beind the macro is to create a gem with intersecting planes. You
create a "circle" with a given number of planes, angling at a given angle
from the y-axis. With several of these circles, you can create a good
gem-shape, and the possibilities are almost endless!

Declare some arrays calles angles[], distances[], facets[] and offsets[]
with n elements. You may of course call them whatever you want, but this is
the way I do it. These define the mentioned circles of intersecting planes.

angles[i] contains the angle the planes make with the y-axis.
distances[i] contains the distance from the centre <0, 0, 0> to the plane.
facets[i] contains the number of planes in a circle. NOTE: In "normal" gems,
you have two number of facets, k and 2k (eg 4 and 8). This prodices gems
that are "real"
offsets[i] contains the angular offsets when the planes in one circle are
rotated. Very much like the phase keyword in ripples and waves. Note: "Real"
gems typically use 0 and 0.5 for these, alternating. But feel free!

Here is a simple example:

#declare num = 2;
#declare angles = array[num] { 45, 135 }
#declare distances = array[num] { 1, 1 }
#declare facets = array[num]  { 6, 6 }
#declare offsets = array[num]  { 0, 0.5 }

object {
    Gem(num, angles, distances, facets, offsets)
    texture {
        Some_Cool_Glass_Texture_Or_Whatever
    }
}

Num tells us that we want 2 circles of planes. Angles tells us what angles
these should make with the y-axis. Distances tells us that the planes have
distance 1 from <0, 0, 0>. Facets tells us that there are 6 planes in both
circles. Offsets tells us that ome of the circles are phased with the other,
making an interesting effect. Experiment; this simple gem in fact contains
many pretty ones! Try varying facets.


Simen.

------

Code for Gem-macro:

#macro Gem(num, ang, dist, facet, offs)
//check if gem is bounded
#local lo_bang = -1;
#local hi_bang = -1;
#local maxd = 0;
#local c = 0;
#while (c<num)
        #if (dist[c]>maxd)
                #local maxd=dist[c];
        #end
        #if (ang[c]>90)
                #if (lo_bang=-1)
                        #local lo_bang=c;
                #else
                        #if (ang[lo_bang]<ang[c])
                                #local lo_bang=c;
                        #end
                #end
        #end
        #if (ang[c]<90)
                #if (hi_bang=-1)
                        #local hi_bang=c;
                #else
                        #if (ang[hi_bang]>ang[c])
                                #local hi_bang=c;
                        #end
                #end
        #end

        #local c=c+1;
#end
#if ((lo_bang<0) | (hi_bang<0))
        #error "GEM IS UNBOUNDED! ABORT! ABORT!"
#end

//lo_bang now contains the index of the lower bounding angle.
//hi_bang now contains the index of the upper bounding angle.
//largest distance is now in maxd
//find bouding sphere radius
#local lo_y_dist = abs(dist[lo_bang]/cos(radians(ang[lo_bang])));
#local hi_y_dist = abs(dist[hi_bang]/cos(radians(ang[hi_bang])));
#local bounding_radius = max(lo_y_dist, maxd);
#local bounding_radius = max(bounding_radius, hi_y_dist);
#local y_trans = (hi_y_dist+lo_y_dist);

intersection {

        #local c = 0;
        #while (c<num)
                #local i=0;
                #while (i<facet[c])

                plane { y, dist[c]
                        rotate z*ang[c]
                        rotate y*(360/facet[c]*i + 360/facet[c]*offs[c])
                }


                #local i=i+1;
                #end
        #local c = c+1;
        #end

}

//bound it so it will render faster.
bounded_by { sphere { 0, bounding_radius+0.1 } }
//finally, center the gem
//translate y*y_trans/2
translate y*lo_y_dist
scale 2/y_trans
translate -1*y

#end


Post a reply to this message

From: Nieminen Juha
Subject: Re: Improved GEM MACRO
Date: 19 Oct 1999 05:16:12
Message: <380c36dc@news.povray.org>
Simen Kvaal <sim### [at] studentmatnatuiono> wrote:
: The idea beind the macro is to create a gem with intersecting planes.

  A suggestion: Use boxes instead of planes. It will probably speed up the
rendering.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Simen Kvaal
Subject: Re: Improved GEM MACRO
Date: 20 Oct 1999 04:23:13
Message: <380d7bf1@news.povray.org>
>  A suggestion: Use boxes instead of planes. It will probably speed up the
>rendering.
>


Planes are faster, given that they are bounded, which they are. Aren't boxes
just intersections of six planes? If you render a fairly complex gem with
this macro, with a simple, fast, texture, it will render quite fast!

Tell me if I am wrong.

(c:

Simen.


Post a reply to this message

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