HL
Hans L
Wed, Dec 21, 2016 4:36 PM
I'm not sure the best way to word this, but I want to sort of sweep a
cone across some ranges of angles.
Hopefully the code and shape it produces is more self explanatory.
The code below does make the shape i want but is not particularly
efficient or smooth. I can increase the for loop step resolution, but
then previewing takes like 20s per frame, and OpenSCAD becomes
unusable.
Anyone know some smarter ways to do something like this?
$fn = 48;
module cone(h,angle) {
cylinder(r1=0,r2=h*tan(angle/2),h=h);
}
difference() {
sphere(r=50);
!for(j = [0:5:90]) rotate([j,0])
for(i = [-30:5:30]) rotate([90,0,i])
cone(100,60);
}
I'm not sure the best way to word this, but I want to sort of sweep a
cone across some ranges of angles.
Hopefully the code and shape it produces is more self explanatory.
The code below does make the shape i want but is not particularly
efficient or smooth. I can increase the for loop step resolution, but
then previewing takes like 20s per frame, and OpenSCAD becomes
unusable.
Anyone know some smarter ways to do something like this?
$fn = 48;
module cone(h,angle) {
cylinder(r1=0,r2=h*tan(angle/2),h=h);
}
difference() {
sphere(r=50);
!for(j = [0:5:90]) rotate([j,0])
for(i = [-30:5:30]) rotate([90,0,i])
cone(100,60);
}
HL
Hans L
Wed, Dec 21, 2016 5:00 PM
I guess what I'm really getting at is that I think I could write a
function / list comprehension that generates a list of points for
where this sweep meets the sphere surface. I could define a sort of
triangle fan for this but assuming I did that, I don't know how I
would turn that warped "surface" into a solid.
On Wed, Dec 21, 2016 at 10:36 AM, Hans L thehans@gmail.com wrote:
I'm not sure the best way to word this, but I want to sort of sweep a
cone across some ranges of angles.
Hopefully the code and shape it produces is more self explanatory.
The code below does make the shape i want but is not particularly
efficient or smooth. I can increase the for loop step resolution, but
then previewing takes like 20s per frame, and OpenSCAD becomes
unusable.
Anyone know some smarter ways to do something like this?
$fn = 48;
module cone(h,angle) {
cylinder(r1=0,r2=h*tan(angle/2),h=h);
}
difference() {
sphere(r=50);
!for(j = [0:5:90]) rotate([j,0])
for(i = [-30:5:30]) rotate([90,0,i])
cone(100,60);
}
I guess what I'm really getting at is that I think I could write a
function / list comprehension that generates a list of points for
where this sweep meets the sphere surface. I could define a sort of
triangle fan for this but assuming I did that, I don't know how I
would turn that warped "surface" into a solid.
On Wed, Dec 21, 2016 at 10:36 AM, Hans L <thehans@gmail.com> wrote:
> I'm not sure the best way to word this, but I want to sort of sweep a
> cone across some ranges of angles.
>
> Hopefully the code and shape it produces is more self explanatory.
> The code below does make the shape i want but is not particularly
> efficient or smooth. I can increase the for loop step resolution, but
> then previewing takes like 20s per frame, and OpenSCAD becomes
> unusable.
>
> Anyone know some smarter ways to do something like this?
>
>
> $fn = 48;
>
> module cone(h,angle) {
> cylinder(r1=0,r2=h*tan(angle/2),h=h);
> }
>
> difference() {
> sphere(r=50);
> !for(j = [0:5:90]) rotate([j,0])
> for(i = [-30:5:30]) rotate([90,0,i])
> cone(100,60);
> }
RP
Ronaldo Persiano
Wed, Dec 21, 2016 10:23 PM
Nice shape, hard to code.
To turn the surface into a solid you will have to close it with another one
and call polyhedron. To close it with a spherical surface would be the best
but a very hard way (you will have to triangulate points in the sphere).
You may extend the warped cone surface beyond the sphere surface and close
it with another warped cone with a vertex away the path. Generate the
polyhedron of that and intercept it with the sphere. Anyway, the hard part
would be to generate the points where the sweep meets the sphere.
2016-12-21 15:00 GMT-02:00 Hans L thehans@gmail.com:
I guess what I'm really getting at is that I think I could write a
function / list comprehension that generates a list of points for
where this sweep meets the sphere surface. I could define a sort of
triangle fan for this but assuming I did that, I don't know how I
would turn that warped "surface" into a solid.
On Wed, Dec 21, 2016 at 10:36 AM, Hans L thehans@gmail.com wrote:
I'm not sure the best way to word this, but I want to sort of sweep a
cone across some ranges of angles.
Hopefully the code and shape it produces is more self explanatory.
The code below does make the shape i want but is not particularly
efficient or smooth. I can increase the for loop step resolution, but
then previewing takes like 20s per frame, and OpenSCAD becomes
unusable.
Anyone know some smarter ways to do something like this?
$fn = 48;
module cone(h,angle) {
cylinder(r1=0,r2=h*tan(angle/2),h=h);
}
difference() {
sphere(r=50);
!for(j = [0:5:90]) rotate([j,0])
for(i = [-30:5:30]) rotate([90,0,i])
cone(100,60);
}
Nice shape, hard to code.
To turn the surface into a solid you will have to close it with another one
and call polyhedron. To close it with a spherical surface would be the best
but a very hard way (you will have to triangulate points in the sphere).
You may extend the warped cone surface beyond the sphere surface and close
it with another warped cone with a vertex away the path. Generate the
polyhedron of that and intercept it with the sphere. Anyway, the hard part
would be to generate the points where the sweep meets the sphere.
2016-12-21 15:00 GMT-02:00 Hans L <thehans@gmail.com>:
> I guess what I'm really getting at is that I think I could write a
> function / list comprehension that generates a list of points for
> where this sweep meets the sphere surface. I could define a sort of
> triangle fan for this but assuming I did that, I don't know how I
> would turn that warped "surface" into a solid.
>
> On Wed, Dec 21, 2016 at 10:36 AM, Hans L <thehans@gmail.com> wrote:
> > I'm not sure the best way to word this, but I want to sort of sweep a
> > cone across some ranges of angles.
> >
> > Hopefully the code and shape it produces is more self explanatory.
> > The code below does make the shape i want but is not particularly
> > efficient or smooth. I can increase the for loop step resolution, but
> > then previewing takes like 20s per frame, and OpenSCAD becomes
> > unusable.
> >
> > Anyone know some smarter ways to do something like this?
> >
> >
> > $fn = 48;
> >
> > module cone(h,angle) {
> > cylinder(r1=0,r2=h*tan(angle/2),h=h);
> > }
> >
> > difference() {
> > sphere(r=50);
> > !for(j = [0:5:90]) rotate([j,0])
> > for(i = [-30:5:30]) rotate([90,0,i])
> > cone(100,60);
> > }
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
P
Parkinbot
Wed, Dec 21, 2016 10:57 PM
I could define a sort of triangle fan for this but assuming I did that, I
don't know how I
would turn that warped "surface" into a solid.
Say, you have a 3D polygon that defines the boundary of your warped surface,
it is quite easy to define a solid.
- connecting each line segment with [0, 0, 0] defines the first half of
your faces - the one you are interested in.
- find a "good" opposite point P "on the other side" of the warped surface
- e.g. travel along the symmetry axis and use an origin distance of 2*r.
- now connect each segment with P to close the solid from the other side.
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19672.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
thehans wrote
> I could define a sort of triangle fan for this but assuming I did that, I
> don't know how I
> would turn that warped "surface" into a solid.
Say, you have a 3D polygon that defines the boundary of your warped surface,
it is quite easy to define a solid.
1. connecting each line segment with [0, 0, 0] defines the first half of
your faces - the one you are interested in.
2. find a "good" opposite point P "on the other side" of the warped surface
- e.g. travel along the symmetry axis and use an origin distance of 2*r.
3. now connect each segment with P to close the solid from the other side.
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19672.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
HL
Hans L
Thu, Dec 22, 2016 2:33 AM
I'm not sure if I understand what you mean by "the symmetry axis". I
don't think this would work if a swept angle + cone angle >= 180?
On Wed, Dec 21, 2016 at 4:57 PM, Parkinbot rudolf@parkinbot.com wrote:
I could define a sort of triangle fan for this but assuming I did that, I
don't know how I
would turn that warped "surface" into a solid.
I'm not sure if I understand what you mean by "the symmetry axis". I
don't think this would work if a swept angle + cone angle >= 180?
On Wed, Dec 21, 2016 at 4:57 PM, Parkinbot <rudolf@parkinbot.com> wrote:
> thehans wrote
>> I could define a sort of triangle fan for this but assuming I did that, I
>> don't know how I
>> would turn that warped "surface" into a solid.
>
> Say, you have a 3D polygon that defines the boundary of your warped surface,
> it is quite easy to define a solid.
> 1. connecting each line segment with [0, 0, 0] defines the first half of
> your faces - the one you are interested in.
> 2. find a "good" opposite point P "on the other side" of the warped surface
> - e.g. travel along the symmetry axis and use an origin distance of 2*r.
> 3. now connect each segment with P to close the solid from the other side.
>
>
>
> --
> View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19672.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
P
Parkinbot
Thu, Dec 22, 2016 3:38 AM
I'm not sure if I understand what you mean by "the symmetry axis". I
don't think this would work if a swept angle + cone angle >= 180?
h = 30;
r = 100;
N = [0, 0, 0];
P = [0, 0, 2*h]; // != p0 and shifted along the symmetry axis (here z
axis)
points = concat(p(r, h), [N, P]);
L = len(points);
faces = concat(lower(L-2), upper(L-2));
polyhedron(points, faces);
function p (r=100, h = 10) = [for (i=[0:359]) [rsin(i), rcos(i), 30 +
hsin(4i)]];
function lower(N) = [for (i=[0:N-1]) [N, (i+1)%N, i]];
function upper(N) = [for (i=[0:N-1]) [N+1, i, (i+1)%N]];
thehans wrote
> I'm not sure if I understand what you mean by "the symmetry axis". I
> don't think this would work if a swept angle + cone angle >= 180?
Have a look at this code. The 3D polygon is some wave function. The solid is
composed by a lower and an upper surface. Triangulation done by using two
points N and P with N!=P. The symmetry axis is here the z axis.
<http://forum.openscad.org/file/n19676/thehans.png>
Shifting P along the axis yields for example:
<http://forum.openscad.org/file/n19676/thehans1.png>
> h = 30;
> r = 100;
>
> N = [0, 0, 0];
> P = [0, 0, 2*h]; // != p0 and shifted along the symmetry axis (here z
> axis)
>
> points = concat(p(r, h), [N, P]);
> L = len(points);
> faces = concat(lower(L-2), upper(L-2));
>
> polyhedron(points, faces);
>
> function p (r=100, h = 10) = [for (i=[0:359]) [r*sin(i), r*cos(i), 30 +
> h*sin(4*i)]];
> function lower(N) = [for (i=[0:N-1]) [N, (i+1)%N, i]];
> function upper(N) = [for (i=[0:N-1]) [N+1, i, (i+1)%N]];
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19676.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
R
runsun
Thu, Dec 22, 2016 4:39 AM
Excellent code to achieve that with such a simplicity, Parkinbot.
One thing, though. The result seems to project lines from the center outward
to a cylinder, but not to a ball as thehans is expecting.
$ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); $ tips: Bezier , hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2 , 3 , 4 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg , tests ( 2 ), text , triang , unit ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf ), support_tools
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19679.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Excellent code to achieve that with such a simplicity, Parkinbot.
One thing, though. The result seems to project lines from the center outward
to a cylinder, but not to a ball as thehans is expecting.
-----
$ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); $ tips: Bezier , hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2 , 3 , 4 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg , tests ( 2 ), text , triang , unit ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf ), support_tools
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19679.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, Dec 22, 2016 1:33 PM
My code refers to the statement: "provided we have a 3D polygon describing
the cut, how to turn it into a solid?" Using a single point P as "opposite
point" of the solid is a cone approach. Obviously you could also use a
shifted copy of the lower surface as upper surface" an connect them into a
solid - a slightly generalized linear_extrude() operation.
The rest is obviously something like:
difference()
{
sphere(50);
polyhedron(points, faces, convexity = 4);
}
My code refers to the statement: "provided we have a 3D polygon describing
the cut, how to turn it into a solid?" Using a single point P as "opposite
point" of the solid is a cone approach. Obviously you could also use a
shifted copy of the lower surface as upper surface" an connect them into a
solid - a slightly generalized linear_extrude() operation.
The rest is obviously something like:
> difference()
> {
> sphere(50);
> polyhedron(points, faces, convexity = 4);
> }
Here an example of a sphere half created by some (unshifted) wave function:
<http://forum.openscad.org/file/n19685/thehans2.png>
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19685.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
R
runsun
Thu, Dec 22, 2016 4:33 PM
I probably was thinking too much into it by seeing it as a problem of
spherical coordinate vs the cylinder coordinate solution you provided. In
practice, they don't look much difference.
$ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); $ tips: Bezier , hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2 , 3 , 4 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg , tests ( 2 ), text , triang , unit ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf ), support_tools
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19694.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I probably was thinking too much into it by seeing it as a problem of
spherical coordinate vs the cylinder coordinate solution you provided. In
practice, they don't look much difference.
-----
$ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); $ tips: Bezier , hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2 , 3 , 4 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg , tests ( 2 ), text , triang , unit ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf ), support_tools
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19694.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, Dec 22, 2016 10:18 PM
I mean, you are right in that it is not so easy to calculate that polygon in
spheric coordinates. But thehans didn't tell us, whether his approach was a
real specification or just some heuristic approach to get something like the
wave function.
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19701.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I mean, you are right in that it is not so easy to calculate that polygon in
spheric coordinates. But thehans didn't tell us, whether his approach was a
real specification or just some heuristic approach to get something like the
wave function.
--
View this message in context: http://forum.openscad.org/Sweeping-a-cone-through-a-range-of-angles-about-the-origin-tp19662p19701.html
Sent from the OpenSCAD mailing list archive at Nabble.com.