|
|
Wasn't it Edwin Miller who wrote:
>I wanted to create a "cone" with the base just like a ellipse and the
>top just like a normal circle. Therefor I have to scale the original cone
>at the base with something like <1,1,0.5> and at the top with <1,1,1>,
>between these both position scaling like a linear function.
>
>If there's no way to solve this problem with the matrix keyword,
>is there any other way to do?
You could do it with an isosurface.
This spline-driven parametric isosurface gives an open "cone" that
varies from <1,1,0.5> to <1,1,1>. (For speed you could use Ingo's
param.inc.)
// Cone with an elliptical base and circular top
#version 3.5;
camera { location <3, 3, -5> look_at <0, 0.5, 0> angle 20}
light_source {<100,200,-500> colour rgb 1}
// The spline that defines the edges of the "cone"
#declare S = function {
spline {
linear_spline
0, <1, 1, 0.5>,
1, <1, 1, 1>
}
}
// The Fx and Fy functions are derived from the
// X and Y values of the spline
#declare Fx = function(x,y) {(S(u).x * sin(v)/2)}
#declare Fy = function(x,y) {u}
#declare Fz = function(x,y) {(S(u).z * cos(v)/2)}
// The U parameter controls the Y height
#declare Umin = 0;
#declare Umax = 1;
// The V value goes round the circumpherence
// plus a little overlap to prevent an edge artefact
#declare Vmin = -pi;
#declare Vmax = 1.001*pi;
// The isosurface
parametric {
function {Fx(u,v)}
function {Fy(u,v)}
function {Fz(u,v)}
<Umin,Vmin>,<Umax,Vmax>
contained_by{box{<-1,0,-1><1,1,1>}}
precompute 18, x,y,z
pigment {rgb 0.9}
finish {phong 0.5 phong_size 10 ambient 0.2}
}
plane {y,0 pigment {rgb 1}}
======================================================
This isosurface gives a closed shape and renders much faster,
unfortunately the sides aren't quite straight.
// Cone with an elliptical base and circular top
#version 3.5;
camera { location <10, 5, -10> look_at <0, 0.5, 0> angle 10 }
light_source {<0,100,-100> colour rgb 1}
background {rgb 0.3}
// This function would give an ordinary cylinder
#declare F=function { x*x + z*z - 0.25}
// The Z value is then transformed by z*(2-y)
// which gives z*1 at the top when y=1
// and z*2 at the bottom when y=0
isosurface {
function {F(x,y,z*(2-y))}
max_gradient 5.5
contained_by{box {<-1,0,-1><1,1,1>}}
pigment {rgb .9}
finish {phong 0.5 phong_size 10}
}
plane {y,0 pigment {rgb 1}}
Post a reply to this message
|
|