|
|
"Samuel B." <stb### [at] hotmailcom> wrote:
>
> Here's what I came up with this afternoon (with added border):
>
And here's the realized object. It uses a height_field for its relief, and CSG
for everything else. It fits within a box of width=.5; height=.5; depth=object
depth.
/*
N = angular symmetry (int)
CT = frame/circle thickness
YC = y-cutoff for inner points
PO = texture z offset
RD = relief depth (height field)
OD = object depth
Res = height_field resolution x & y (int)
*/
#macro N_Foil_Obj(N, CT, YC, PO, RD, OD, Res)
#declare Eps = .002; // a small value (for CSG)
// angle map for rotation & repetition
#local A =
function(x, y){
floor(atan2(x, y)/pi/2*N+.5)/N*pi*2
}
// distance between two rotated points
#local Dst = vlength(<0, 1>-vrotate(<0, 1>, z*360/N));
// circle y-position, will be also used for radius adjustment
#local CirY = (1-CT) / (1+Dst/2) - CT;
// circle radius
#local CirR = (Dst/2) * CirY;
#macro N_Foil(N, CT, YC, PO)
// pattern function
#local PF =
function{
pattern{
pigment_pattern{
pigment_pattern{
planar
translate -y
scale CT
}
pigment_map{
[0 rgb 0]
[.025/CT granite scale .5 translate PO*z]
}
}
}
}
// function before repetition
#local F =
function{
max(
PF(0, sqrt(x*x+pow(max(y-CirY, -YC), 2))-CirR-CT, 0),
PF(0, -sqrt(x*x+y*y)+1-2*CT, 0)
)
}
// function repeated radially with mirrored x
#local F_ =
function{ F(abs(x*cos(A(x, y)) - y*sin(A(x, y))), x*sin(A(x, y)) + y*cos(A(x,
y)), 0) }
F_(2*(x-.5), 2*(-y+.5), 0)
#end
difference{
// height field
intersection{
height_field{
function Res, Res {
N_Foil(N, CT, YC, PO)
}
smooth
rotate x*270
scale <1+Eps, 1+Eps, RD>
translate -.5*(x+y)
}
cylinder{-z*(RD+Eps), z*OD, .5-Eps}
}
// x position of inner box cutout (doesn't seem to be 100% correct...)
#local XP = abs(pow(YC, 2)-pow(CirR, 2));
// cut out from center from previous object
#for(I, 0, N-1)
cylinder{<0, CirY/2, -(RD+Eps)>, <0, CirY/2, OD+Eps>, (CirR-CT)/2+Eps rotate
z*360/N*I}
box{<-XP-Eps, 0, -(RD+Eps)>, <XP+Eps, CirY/2, OD+Eps> rotate z*360/N*I}
#end
// take out objects from between major circle and minor circle
#if(true)
intersection{
cylinder{<0, 0, -(RD+Eps)>, <0,0, OD+Eps>, .5-CT+Eps}
#for(I, 0, N-1)
cylinder{<0, CirY/2, -RD>, <0, CirY/2, OD>, (CirR+CT)/2-Eps rotate
z*360/N*I inverse}
#end
}
#end
translate -z*OD
}
#end
object{
N_Foil_Obj(6, 0.1, 0.1, 4.0, 0.05, 0.15, 1024)
pigment{rgb .75}
}
Post a reply to this message
Attachments:
Download 'fnfoilb-object.jpg' (102 KB)
Preview of image 'fnfoilb-object.jpg'
|
|