discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] skin? or extrude circle to square

S
shadowwynd
Tue, Apr 18, 2017 10:37 AM

The simplest way is hull:
(if making a 3d shape with hull, you need to start with 3d shapes, not 2D,
hence linear_extrude)

hull()
{
linear_extrude (0.1) square (100, center=true);
translate ([0, 0, 60]) linear_extrude (0.1) circle (50);
}

This approach works for creating a manifold between any shapes, but it is
incredibly ugly for shapes when you might want to see the "shift" from one
to the other.  For instance, the code below does not make a twisted
transition from shape to shape:

hull()
{
linear_extrude (0.1) square (100, center=true);
translate ([0, 0, 60]) rotate ([0, 0, 90]) linear_extrude (0.1) square
(100, center=true);

}


http://www.thingiverse.com/thing:161646

This uses the concept of "tweening" between polygons.  For instance, to go
between a square and a circle, start with a 360-sided polygon that looks
like a circle, and a 360-sided polygon arranged so that most of the segments
are colinear so that it looks like a square.  The shift from square to
circle is then a weighted average of these two polygons arrays;  at
A(100)B(0) you get A, at A(25)B(75) you get a shape that is 25% A, 75%B,
etc.  The advantage of this approach is that you can do any shape, as long
as you define the polygons beforehand (e.g. triangle to heart, etc.)  This
builds lots of slices from A-->B.

http://www.thingiverse.com/thing:50363

This one uses the concept of superellipses - you can represent a square and
a circle with the same mathematical function.  By adjust the parameter, you
range from a pure square to a pure circle.  The downside is this approach
only works for squares and circles.

--
View this message in context: http://forum.openscad.org/skin-or-extrude-circle-to-square-tp21282p21288.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

The simplest way is hull: (if making a 3d shape with hull, you need to start with 3d shapes, not 2D, hence linear_extrude) hull() { linear_extrude (0.1) square (100, center=true); translate ([0, 0, 60]) linear_extrude (0.1) circle (50); } This approach works for creating a manifold between any shapes, but it is incredibly ugly for shapes when you might want to see the "shift" from one to the other. For instance, the code below does not make a twisted transition from shape to shape: hull() { linear_extrude (0.1) square (100, center=true); translate ([0, 0, 60]) rotate ([0, 0, 90]) linear_extrude (0.1) square (100, center=true); } ------------------------- http://www.thingiverse.com/thing:161646 This uses the concept of "tweening" between polygons. For instance, to go between a square and a circle, start with a 360-sided polygon that looks like a circle, and a 360-sided polygon arranged so that most of the segments are colinear so that it looks like a square. The shift from square to circle is then a weighted average of these two polygons arrays; at A(100)B(0) you get A, at A(25)B(75) you get a shape that is 25% A, 75%B, etc. The advantage of this approach is that you can do any shape, as long as you define the polygons beforehand (e.g. triangle to heart, etc.) This builds lots of slices from A-->B. http://www.thingiverse.com/thing:50363 This one uses the concept of superellipses - you can represent a square and a circle with the same mathematical function. By adjust the parameter, you range from a pure square to a pure circle. The downside is this approach only works for squares and circles. -- View this message in context: http://forum.openscad.org/skin-or-extrude-circle-to-square-tp21282p21288.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Tue, Apr 18, 2017 3:47 PM

@gcb,

The function to_3D either in skin.scad or sweep.scad is an embedding of a
2D polygon in 3D space. I could not find where it has been defined but it
is something like:

function to_3D(p) = [for(pi=p) [pi[0],pi[1],0]];

@shadowwynd,

The hull() alternative is poor once it works only with convex shapes.
The second alternative is far better in shape and preserves non-convexities
but it uses minkowski which is far slower.
The third is also good but works only with specific pair of shapes.

What distinguish skin.scad is its generality and the non use of boolean
operations: it relies on building a polyhedron. Most of code and time of
skin.scad is spent in "regularizing" the input shapes, that is,
representing all the input shapes with the same number of points. The weak
point of skin.scad is the way it generates the intermediate shapes by
linear interpolation. Its strategy would have a gain if a spline
interpolation, for instance, replaces the linear one.

@gcb, The function to_3D either in skin.scad or sweep.scad is an embedding of a 2D polygon in 3D space. I could not find where it has been defined but it is something like: function to_3D(p) = [for(pi=p) [pi[0],pi[1],0]]; @shadowwynd, The hull() alternative is poor once it works only with convex shapes. The second alternative is far better in shape and preserves non-convexities but it uses minkowski which is far slower. The third is also good but works only with specific pair of shapes. What distinguish skin.scad is its generality and the non use of boolean operations: it relies on building a polyhedron. Most of code and time of skin.scad is spent in "regularizing" the input shapes, that is, representing all the input shapes with the same number of points. The weak point of skin.scad is the way it generates the intermediate shapes by linear interpolation. Its strategy would have a gain if a spline interpolation, for instance, replaces the linear one.