POV-Ray : Newsgroups : povray.binaries.images : re: my very first iso-surface (and second macro) :-) Server Time
7 Nov 2024 11:31:47 EST (-0500)
  re: my very first iso-surface (and second macro) :-) (Message 1 to 2 of 2)  
From: Jaap
Subject: re: my very first iso-surface (and second macro) :-)
Date: 5 Sep 2004 06:30:00
Message: <web.413aea09e929ab82a8399d8d0@news.povray.org>
Arlo J wrote:
> Jaap wrote:
> > my very first iso-surface (and second macro) :-)
> > the thread is a single iso-surface, bold heads and nuts are CSG.
>
> Nice! I'd love to see radiosity render of some of these once you get
> some good textures together. :)
>
> Arlo

here it is:

texture { T_Chrome_5A normal { crackle 0.05 scale 0.25 } }

(maybe i should make rounded edges on the faces of the bold heads
to make the highlights work properly)


Post a reply to this message


Attachments:
Download 'parts4.jpg' (57 KB)

Preview of image 'parts4.jpg'
parts4.jpg


 

From: Jaap
Subject: re: my very first iso-surface (and second macro) :-)
Date: 5 Sep 2004 13:45:00
Message: <web.413b4f7be929ab82a8399d8d0@news.povray.org>
i changed the shamfered thread into a smooth parabole.
the thread ege is now also higlighted.
also rounded some of the edges of the boldheads and nuts.

I realized that using many functions in min( , ) and max( , )
will result in eash finction being calculated, and then only one will be
used.
I added 2 levels of select(z-.., f_a, f_b) to split the function into the
4 parts but this was only 1.5 times faster.
i now have 4 seperate iso surfaces, witch seems to be mutch faster, and
i can also lower the max_gradient and accuracy for parts that are mostly
flat.

#macro thread_macro( thrOD, totalLen, solidLen, thrSpoed )
  // thrOD   : outer diameter, before "cutting" the thread.
  // totalLen: result: <0,0,0> to <0,0,-totalLen>
  // solidLen: <0,0,0> to <0,0,-solidLen> is not threaded.
  // thrSpoed: displacement per revolution (spoed) (=25.4/tpi)
  #local thrAngle = 60;    // (degrees)
  #local chamOut  =  0.00; // chamfer outside (part of threadDepts)
  #local thrRad   = 0.5*thrOD;
  #local thrs     = 1/thrSpoed;
  #local thrDepts = 0.5*thrSpoed/tan(radians(thrAngle)*0.5);
  #local f_rev       = function{ atan2(x,y)/(pi*2) } // 0..1
  #local f_thread_a  = function{ abs(mod(2+(z*thrs+f_rev(x,y,z))*2,2)-1) }
// 0..1
  #local f_thread_b  = function{ pow(f_thread_a(x,y,z),2) }
  #local f_thread    = function{ f_thread_b(x,y,z) }
  #local f_threadCha = function{ thrDepts*max(chamOut,f_thread(x,y,z)) }
  #local f_solidCone = function{ (z-solidLen)*0.25   } // cone between solid
and thread
  #local f_endCone   = function{ thrDepts+z-totalLen } // cone at end of
bold
  #local f_dimple    = function{
2*thrOD-sqrt(pow(x,2)+pow(y,2)+pow(totalLen+thrOD*1.965-z,2))}
  #local f_rad_A     = function{ thrRad
     }
  #local f_rad_B     = function{
thrRad-min(f_threadCha(x,y,z),f_solidCone(x,y,z))}
  #local f_rad_C     = function{ thrRad-    f_threadCha(x,y,z)
     }
  #local f_rad_D     = function{
thrRad-max(f_threadCha(x,y,z),f_endCone(x,y,z))  }
  // part_A // solid
  // part_B // cone: between sollid and thread
  // part_C // thread
  // part_D // thread at end of bolt, with dimple
  #local f_part_A    = function{    sqrt(pow(x,2)+pow(y,2))-f_rad_A(x,y,z)}
  #local f_part_B    = function{    sqrt(pow(x,2)+pow(y,2))-f_rad_B(x,y,z)}
  #local f_part_C    = function{    sqrt(pow(x,2)+pow(y,2))-f_rad_C(x,y,z)}
  #local f_part_D    =
function{max(sqrt(pow(x,2)+pow(y,2))-f_rad_D(x,y,z),f_dimple(x,y,z))}
  // select one of the 4 parts:  (and only use the functions needed for THAT
part!)
  /*
  #local f_part_AB   = function{ select(z-solidLen,               f_part_A
(x,y,z), f_part_B (x,y,z))}
  #local f_part_CD   = function{ select(z-totalLen+thrDepts,      f_part_C
(x,y,z), f_part_D (x,y,z))}
  #local f_final     = function{ select(z-solidLen-thrDepts/0.25,
f_part_AB(x,y,z), f_part_CD(x,y,z))}
  */
  isosurface {
    function{ f_part_A(x,y,z) }
    max_gradient 2.0
    accuracy thrOD/500
    contained_by{box{<-thrRad,-thrRad,0>,<thrRad,thrRad,solidLen>}}
    scale <1,1,-1>
  }
  isosurface {
    function{ f_part_B(x,y,z) }
    max_gradient 2.0
    accuracy thrOD/500

contained_by{box{<-thrRad,-thrRad,solidLen>,<thrRad,thrRad,solidLen+thrDepts/0.25>}}
    scale <1,1,-1>
  }
  isosurface {
    function{ f_part_C(x,y,z) }
    max_gradient 2.0
    accuracy thrOD/500

contained_by{box{<-thrRad,-thrRad,solidLen+thrDepts/0.25>,<thrRad,thrRad,totalLen-thrDepts>}}
    scale <1,1,-1>
  }
  isosurface {
    function{ f_part_D(x,y,z) }
    max_gradient 2.0
    accuracy thrOD/500

contained_by{box{<-thrRad,-thrRad,totalLen-thrDepts>,<thrRad,thrRad,totalLen>}}
    scale <1,1,-1>
  }
#end

jaap.


Post a reply to this message


Attachments:
Download 'parts5.jpg' (73 KB)

Preview of image 'parts5.jpg'
parts5.jpg


 

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