|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Pattern function for an n-foil (like a trefoil, but with more Ns). Fits within a
unit circle.
// +fn -f +a0.3 +am2 +r2
#version 3.7;
global_settings{assumed_gamma 1.}
#default{ finish{emission 1} }
#declare CScale = 1.2;
camera{
orthographic
right x*2 up y*2
location -32*z
look_at 0
scale CScale
}
/*
N = angular symmetry
CT = circle thickness
PO = texture z offset
*/
#macro N_Foil(N, CT, PO)
// 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));
// adjustment for radius and y-translation
#local Scale = (1-CT) / (1+Dst/2);
// 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]
}
translate y*((Dst/2)*Scale+CT)
}
}
}
// function before repetition
#local F =
function{
pattern{
function{
PF(0, sqrt(x*x+pow(max(y, 0), 2)), 0)
}
rotate -z*180/N
translate y*Scale
}
}
// function repeated radially with mirrored x
F(abs(x*cos(A(x, y)) - y*sin(A(x, y))), x*sin(A(x, y)) + y*cos(A(x, y)), 0)
#end
plane{
z, 0
pigment{
function{N_Foil(7, .075, 1)}
}
}
torus{1, 1. * CScale / image_width rotate x*90 pigment{rgb<1, .05, .1>}}
Post a reply to this message
Attachments:
Download 'nfoil.jpg' (70 KB)
Preview of image 'nfoil.jpg'
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Samuel B." <stb### [at] hotmailcom> wrote:
> Pattern function for an n-foil
Ideally, the center would be empty, but I don't know how to approach that
problem atm :P
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Samuel B." <stb### [at] hotmailcom> wrote:
> "Samuel B." <stb### [at] hotmailcom> wrote:
> > Pattern function for an n-foil
>
> Ideally, the center would be empty, but I don't know how to approach that
> problem atm :P
#declare Radius = 0.2;
#declare Circle = function {sqrt (x*x + y*y)}
/ function before repetition
#local F =
function {
pattern {
function{
//PF(0, sqrt(x*x+pow(max(y, 0), 2)), 0)
PF(0, max (sqrt(x*x+pow(max(y, 0), 2)), Circle (x, y, z) - Radius), 0)
}
rotate -z*180/N
translate y*Scale
}
}
Gives me an N-sided hole in the center.
Not sure how to get it to be an actual circle....
- BW
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
hi,
"Bald Eagle" <cre### [at] netscapenet> wrote:
> > "Samuel B." <stb### [at] hotmailcom> wrote:
> > > Pattern function for an n-foil
nice, thanks.
> ...
> Not sure how to get it to be an actual circle....
use many "foils" ? </grin> (appreciate is not what was meant)
regards, jr.
Post a reply to this message
Attachments:
Download '230806-be.png' (191 KB)
Preview of image '230806-be.png'
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Samuel B." <stb### [at] hotmailcom> wrote:
> > "Samuel B." <stb### [at] hotmailcom> wrote:
> > > Pattern function for an n-foil
> >
> > Ideally, the center would be empty [...]
>
> [Bald Eagle's code]
>
> Gives me an N-sided hole in the center.
> Not sure how to get it to be an actual circle....
>
> - BW
It's not an easy function to alter, but your solution looks pretty good! I bet
it would help when making rose windows.
I was hoping to make a more traditional shape, but 'tradition' can be a flexible
idea :P
Here's what I came up with this afternoon (with added border):
/*
N = angular symmetry
CT = circle/frame thickness
YC = y-cutoff
PO = texture z offset
*/
#macro N_Foil(N, CT, YC, PO)
// 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));
// adjustment for radius and y-translation
#local Scale = (1-CT) / (1+Dst/2) - CT;
// 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-Scale, -YC), 2))-(Dst/2)*Scale-CT, 0),
PF(0, -sqrt(x*x+y*y)+1-2*CT, 0)
)
}
// function repeated radially with mirrored x
F(abs(x*cos(A(x, y)) - y*sin(A(x, y))), x*sin(A(x, y)) + y*cos(A(x, y)), 0)
#end
The eventual plan was to make this work for height_fields or isosurfaces.
Sam
Post a reply to this message
Attachments:
Download 'fnfoilb.jpg' (38 KB)
Preview of image 'fnfoilb.jpg'
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > "Samuel B." <stb### [at] hotmailcom> wrote:
> > > > Pattern function for an n-foil
>
> nice, thanks.
>
Np.
>
> > ...
> > Not sure how to get it to be an actual circle....
>
> use many "foils" ? </grin> (appreciate is not what was meant)
>
> regards, jr.
I see you're using it as intended `;P
Sam
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Samuel B." <stb### [at] hotmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > "Samuel B." <stb### [at] hotmailcom> wrote:
> > > "Samuel B." <stb### [at] hotmailcom> wrote:
> > > > Pattern function for an n-foil
> > >
> > > Ideally, the center would be empty [...]
> >
> > [Bald Eagle's code]
> >
> > Gives me an N-sided hole in the center.
> > Not sure how to get it to be an actual circle....
> >
> > - BW
>
> Here's what I came up with this afternoon (with added border):
>
And its usage:
plane{
z, 0
pigment{
function{N_Foil(4, .1, .15, 1)}
}
}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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'
|
|
| |
| |
|
|
|
|
| |
|
|