|
|
Le 12/06/2020 à 16:38, Kima a écrit :
> Consider this prism
>
> prism {
> linear_sweep
> cubic_spline
> 0, 1, 18,
> <3,-5>, <3,5>, <-5,0>, <3, -5>, <3,5>, <-5,0>,
> <2,-4>, <2,4>, <-4,0>, <2,-4>, <2,4>, <-4,0>,
> <1,-3>, <1,3>, <-3,0>, <1, -3>, <1,3>, <-3,0>
> pigment { color rgb<0,1,0> }
> }
>
> I want to draw the biggest sphere with the centre of <0,0,0> which can fit
> within the inner part of the prism (not the whole prism; and then, min_extent
> and max_extent are useless here).
>
> Is there a direct way to do so?
Wrong approach and wrong specification.
The radius of the sphere at 0 which can fit inside the inner prism is 0.
Because a prism extend between the planes y=0 and y=1.
If we ignore that point to return to the basic problem, it is easier to
sample the inner prism by isolating it via a spline.
==================
#version 3.7;
global_settings{ assumed_gamma 1.0 }
#default{ finish { emission 0.5 diffuse 0.5 } }
camera { orthographic
location -90*y
up z
right -image_width/image_height*x
look_at 0
angle 12.5
}
prism {
linear_sweep
cubic_spline
0, 1, 18,
<3,-5>, <3,5>, <-5,0>, <3, -5>, <3,5>, <-5,0>,
<2,-4>, <2,4>, <-4,0>, <2,-4>, <2,4>, <-4,0>,
<1,-3>, <1,3>, <-3,0>, <1, -3>, <1,3>, <-3,0>
pigment { color rgb<0,1,0> }
}
light_source { <-1,-1,0.5>*40, 1 }
#declare Sp=spline { cubic_spline
-1, <1,-3>,
0, <1,3>,
1, <-3,0>,
2,<1, -3>,
3, <1,3>,
4, <-3,0>
}
#declare LOWEST = 10;// big enough to start
#for(i,0,3,0.01)
#local Pt = <Sp(i).x, 0, Sp(i).y> ;
#local LENGTH=vlength(Pt);
#declare LOWEST=min(LOWEST,LENGTH);
#end
#debug concat("\nLargest radius of fitting cylinder is ",
str(LOWEST,3,3), "\n")
sphere { 0,LOWEST pigment { color red 1 } }
Post a reply to this message
|
|