[OpenSCAD] Ovals
FourthDr
who_doctor at hotmail.com
Tue Sep 4 20:16:41 EDT 2018
RevarBat:
Thanks for the code. I'll have to tinker with it a while. I also found this
code on another discussion forum, I added the sphere and was trying to merge
it with the cone.
// rotate-extrude test
// by Oliver Fenn
$fn=64; // Bem .: 2nd power
// Shaping function x from [x0: xe], steadily increasing in [x0: xe]
x0=0.0;
xe=1.0;
// Examples:
// x, xx, xxx,
// 1-sin(acos(x)), 1-cos(90x), 1-cos(180x), sin(90x)
// log(x+1), 1-1/(x+1)
function f(x) = 1-sin(acos(x)); // ball, at half the height of the diameter!
// Two-dimensional polygon determined by f (x), x from [x0: xe]
module shape (start, end, to)
{
steps = (end-start)/to;
polygon
(
[
for(x=[start:steps:(end+steps)])
(x<=end)?[x-start, f(x)-f(start)]:[0, f(end)-f(start)]
]
);
} // shape
// cone over radius and height
module cone_r (rad, height)
{
hfact = height/(f(xe)-f(x0));
translate([34, 34, height])
mirror([0, 0, 1])
scale([rad/(xe-x0), rad/(xe-x0), hfact]) // Scale the cone to size
rotate_extrude()
shape(x0, xe, $fn);
} // cone_r
// construction
{
//added by FourthDr
translate([34,34,112.5])
sphere(3., $fn=100);
}
cone_r(16.945, 114.94);
// join cone_r and sphere
--
Sent from: http://forum.openscad.org/
More information about the Discuss
mailing list