POV-Ray : Newsgroups : povray.general : CSG difference of isosurfaces : Re: CSG difference of isosurfaces Server Time
25 Apr 2024 06:55:01 EDT (-0400)
  Re: CSG difference of isosurfaces  
From: William F Pokorny
Date: 12 Nov 2016 11:23:00
Message: <582741e4$1@news.povray.org>
On 11/12/2016 07:50 AM, clipka wrote:
> Am 12.11.2016 um 11:57 schrieb John Greenwood:
>> In my development of rounded objects I want to define two versions of a complex
>> curvy shape, one bigger than the other, and take the smaller one away from the
>> larger to leave a shell with (almost) uniform thickness.
>>
>
> Another approach to solve the problem would be to implement the
> differencing operation in the isosurface function, rather than via CSG.
> I reckon this might be faster.
>
> In essence, the CSG difference between A and B is equivalent to an
> intersection of A and the inverse of B. You can invert isosurface B by
> flipping the sign of both the function and the threshold; you can then
> adjust the threshold to match that of A by adding a constant to both the
> function and threshold. And if I'm not mistaken you can intersect two
> isosurfaces with identical thresholds and functions FnA() and FnB() by
> using min(FnA(),FnB()) [or max(FnA(),FnB()), can't say off the top of my
> head] as the function of a single isosurface.
>
In this vein of thinking, I often use a set up like that below to get an 
isosurface shell.

Bill P.

//----------------------------------
#version 3.7;
global_settings {
     assumed_gamma 1
     ambient_light srgb <1,1,1>
}
#default { finish {ambient 0.005 diffuse 0.45} }
#declare Grey50 = srgbft <0.5,0.5,0.5,0,0>;
background { color Grey50 }
#declare Camera00 = camera {
     perspective
     location <3,3,-3.001>
     sky <0,1,0>
     angle 35
     right x*(image_width/image_height)
     look_at <0,0,0>
}
#declare White = srgbft <1,1,1,0,0>;
#declare Light00 = light_source { <50,150,-250>, White }
#declare Red = srgbft <1,0,0,0,0>;
#declare CylinderX = cylinder {
     <-1,0,0>, <1,0,0>, 0.01
     pigment { color Red }
}
#declare Green = srgbft <0,1,0,0,0>;
#declare CylinderY = cylinder {
     <0,-1,0>, <0,1,0>, 0.01
     pigment { color Green }
}
#declare Blue = srgbft <0,0,1,0,0>;
#declare CylinderZ = cylinder {
     <0,0,-1>, <0,0,1>, 0.01
     pigment { color Blue }
}
#declare VarShellThickness = 0.04;
#include "functions.inc"
#declare Fn00 = function (x,y,z) {
     f_sphere(x,y,z,0.5)-(VarShellThickness/2.0)
}
#declare Fn00_inv = function (x,y,z) {
     -(f_sphere(x,y,z,0.5))-(VarShellThickness/2.0)
}
#declare FnShell = function (x,y,z) {
     max(Fn00(x,y,z),Fn00_inv(x,y,z))
}
#declare Azure = srgbft <0,0.498,1,0,0>;
#declare Iso99 = isosurface {
     function { FnShell(x,y,z) }
     contained_by { box { <-1,-1,-1>,<1,1,1> } }
     threshold 0
     accuracy 0.0005
     max_gradient 2.1
     max_trace 3
     pigment { color Azure }
}

#declare Rose = srgbft <1,0,0.5,0,0>;
#declare Box00 = box {
     <-1,-1,-1>,<0,1,1>
     pigment { color Rose }
}
#declare Inter00 = intersection {
     object { Box00 }
     object { Iso99 }

//---
camera { Camera00 }
light_source { Light00 }
object { CylinderX }
object { CylinderY }
object { CylinderZ }
object { Inter00 }
//----------------------------------


Post a reply to this message

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