discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Equivalent of offset for a list of points?

RB
roald.baudoux@brutele.be
Mon, Apr 11, 2022 9:45 AM

Sanjeev, here’s the full code using your lib:

use <dotSCAD/src/loft.scad>;

include <sprabhakar2006/dependencies.scad>

stages =200;

stage_height = 1.25;

rad = 50;

f1 = 25;

f2 = 25;

phase1 = 0;

phase2 = 180;

height_depth=5;

depth1 = 20;

depth2 = 20;

thickness = 2;

bottom_thickness = 3;

myslices = 5;

angle_step=0.1;

// generate outer points

points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages))]]];

// generate inner points with offset from outer points for hollowing out

points_base_e = [for (i = [0:1:stages]) f_offset(points_base[i],-thickness)];

// points - outside

points = [for (i = [0:1:stages-1]) [for (j = [0:1:(len(points_base[i])-1)]) concat(points_base[i][j][0],points_base[i][j][1],i * stage_height)]];

// points - inside

points_e = [for (i = [0:1:stages]) [for (j = [0:1:(len(points_base_e[i])-1)]) concat(points_base_e[i][j][0],points_base_e[i][j][1],i * stage_height)]];

//echo("points: ", points);

// separate points in packs for stepped extrusion

steps = [for (i = [0:1:stages-1]) points[i]];

steps_e = [for (i = [0:1:stages]) points_e[i]];

// extrusion with dotSCAD's loft function

difference() {

loft(steps,slices = myslices);

difference() {

	loft(steps_e,slices = myslices);

	cylinder(h = bottom_thickness, r = rad \* 2 + 20, center=true);

}

}

//======================== FUNCTIONS

function elbow(i,a,b,c) = lookup(i, [[0,a],[0.5,b],[1,c]]);

function elbow2(i,a,b,c,d) = lookup(i, [[0,a],[0.33333,b],[0.66666,c],[1,d]]);

function pauw(x,p) = sign(x) * pow(abs(x),p);

Sanjeev, here’s the full code using your lib: > use <dotSCAD/src/loft.scad>; > > include <sprabhakar2006/dependencies.scad> > > stages =200; > > stage_height = 1.25; > > rad = 50; > > f1 = 25; > > f2 = 25; > > phase1 = 0; > > phase2 = 180; > > height_depth=5; > > depth1 = 20; > > depth2 = 20; > > thickness = 2; > > bottom_thickness = 3; > > myslices = 5; > > angle_step=0.1; > > // generate outer points > > points_base = \[for (i = \[0:1:stages\]) let(f = pow(sin(i/stages \* 120),2) \* 7 + 1, var = 1 , a=((sin((i/stages\*360\*f)%360) \* 0.5 + 0.5) \* (var \* height_depth))) \[for(j = \[0:angle_step:360-angle_step\]) \[sin(j) \* (rad+a+(pauw(sin(j \*f1+phase1),0.5)\*0.5+0.5)\*depth1\*i/stages+(pauw(sin(j \*f2+phase2),0.5)\*0.5+0.5)\*depth2\*(1-i/stages)), cos(j) \*(rad+a+(pauw(sin(j \*f1+phase1),0.5)\*0.5+0.5)\*depth1\*i/stages+(pauw(sin(j \*f2+phase2),0.5)\*0.5+0.5)\*depth2\*(1-i/stages))\]\]\]; > > // generate inner points with offset from outer points for hollowing out > > points_base_e = \[for (i = \[0:1:stages\]) f_offset(points_base\[i\],-thickness)\]; > > // points - outside > > points = \[for (i = \[0:1:stages-1\]) \[for (j = \[0:1:(len(points_base\[i\])-1)\]) concat(points_base\[i\]\[j\]\[0\],points_base\[i\]\[j\]\[1\],i \* stage_height)\]\]; > > // points - inside > > points_e = \[for (i = \[0:1:stages\]) \[for (j = \[0:1:(len(points_base_e\[i\])-1)\]) concat(points_base_e\[i\]\[j\]\[0\],points_base_e\[i\]\[j\]\[1\],i \* stage_height)\]\]; > > //echo("points: ", points); > > // separate points in packs for stepped extrusion > > steps = \[for (i = \[0:1:stages-1\]) points\[i\]\]; > > steps_e = \[for (i = \[0:1:stages\]) points_e\[i\]\]; > > // extrusion with dotSCAD's loft function > > difference() { > > loft(steps,slices = myslices); > > difference() { > > loft(steps_e,slices = myslices); > > cylinder(h = bottom_thickness, r = rad \* 2 + 20, center=true); > > } > > } > > //======================== FUNCTIONS > > function elbow(i,a,b,c) = lookup(i, \[\[0,a\],\[0.5,b\],\[1,c\]\]); > > function elbow2(i,a,b,c,d) = lookup(i, \[\[0,a\],\[0.33333,b\],\[0.66666,c\],\[1,d\]\]); > > function pauw(x,p) = sign(x) \* pow(abs(x),p);
SP
Sanjeev Prabhakar
Mon, Apr 11, 2022 5:15 PM

please try this code:

it took 3 minutes 43 sec to render in my system

include <sprabhakar2006/

dependencies.scad>

stages =200;

stage_height = 1.25;

rad = 50;

f1 = 25;

f2 = 25;

phase1 = 0;

phase2 = 180;

height_depth=5;

depth1 = 20;

depth2 = 20;

thickness = 2;

bottom_thickness = 3;

myslices = 5;

angle_step=1;

// generate outer points

points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) *
7 + 1, var = 1 , a=((sin((i/stages360f)%360) * 0.5 + 0.5) * (var *
height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) *
(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j
*f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j
*f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j
*f2+phase2),0.5)0.5+0.5)depth2(1-i/stages)),istage_height]]];

points_base1=[for(p=points_base)offst(c3t2(p),-thickness)];
points_base_e=[for(i=[0:len(points_base1)-1])[for(p=points_base1[i])[p.x,p.y,i*stage_height]]];
//echo(points_base_e);
swp_prism_h(points_base,points_base_e);
//swp(points_base_e);

step angle of 0.1 seems to be an overkill so increased  to 1

On Mon, 11 Apr 2022 at 15:15, roald.baudoux@brutele.be wrote:

Sanjeev, here’s the full code using your lib:

use <dotSCAD/src/loft.scad>;

include <sprabhakar2006/dependencies.scad>

stages =200;

stage_height = 1.25;

rad = 50;

f1 = 25;

f2 = 25;

phase1 = 0;

phase2 = 180;

height_depth=5;

depth1 = 20;

depth2 = 20;

thickness = 2;

bottom_thickness = 3;

myslices = 5;

angle_step=0.1;

// generate outer points

points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) *
7 + 1, var = 1 , a=((sin((i/stages360f)%360) * 0.5 + 0.5) * (var *
height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) *
(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j
*f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j
*f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j
*f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages))]]];

// generate inner points with offset from outer points for hollowing out

points_base_e = [for (i = [0:1:stages])
f_offset(points_base[i],-thickness)];

// points - outside

points = [for (i = [0:1:stages-1]) [for (j =
[0:1:(len(points_base[i])-1)])
concat(points_base[i][j][0],points_base[i][j][1],i * stage_height)]];

// points - inside

points_e = [for (i = [0:1:stages]) [for (j =
[0:1:(len(points_base_e[i])-1)])
concat(points_base_e[i][j][0],points_base_e[i][j][1],i * stage_height)]];

//echo("points: ", points);

// separate points in packs for stepped extrusion

steps = [for (i = [0:1:stages-1]) points[i]];

steps_e = [for (i = [0:1:stages]) points_e[i]];

// extrusion with dotSCAD's loft function

difference() {

loft(steps,slices = myslices);

difference() {

loft(steps_e,slices = myslices);

cylinder(h = bottom_thickness, r = rad * 2 + 20, center=true);

}

}

//======================== FUNCTIONS

function elbow(i,a,b,c) = lookup(i, [[0,a],[0.5,b],[1,c]]);

function elbow2(i,a,b,c,d) = lookup(i,
[[0,a],[0.33333,b],[0.66666,c],[1,d]]);

function pauw(x,p) = sign(x) * pow(abs(x),p);


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

please try this code: it took 3 minutes 43 sec to render in my system include <sprabhakar2006/ dependencies.scad> stages =200; stage_height = 1.25; rad = 50; f1 = 25; f2 = 25; phase1 = 0; phase2 = 180; height_depth=5; depth1 = 20; depth2 = 20; thickness = 2; bottom_thickness = 3; myslices = 5; angle_step=1; // generate outer points points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)),i*stage_height]]]; points_base1=[for(p=points_base)offst(c3t2(p),-thickness)]; points_base_e=[for(i=[0:len(points_base1)-1])[for(p=points_base1[i])[p.x,p.y,i*stage_height]]]; //echo(points_base_e); swp_prism_h(points_base,points_base_e); //swp(points_base_e); step angle of 0.1 seems to be an overkill so increased to 1 On Mon, 11 Apr 2022 at 15:15, <roald.baudoux@brutele.be> wrote: > Sanjeev, here’s the full code using your lib: > > use <dotSCAD/src/loft.scad>; > > include <sprabhakar2006/dependencies.scad> > > stages =200; > > stage_height = 1.25; > > rad = 50; > > f1 = 25; > > f2 = 25; > > phase1 = 0; > > phase2 = 180; > > height_depth=5; > > depth1 = 20; > > depth2 = 20; > > thickness = 2; > > bottom_thickness = 3; > > myslices = 5; > > angle_step=0.1; > > // generate outer points > > points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * > 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * > height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * > (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j > *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j > *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j > *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages))]]]; > > // generate inner points with offset from outer points for hollowing out > > points_base_e = [for (i = [0:1:stages]) > f_offset(points_base[i],-thickness)]; > > // points - outside > > points = [for (i = [0:1:stages-1]) [for (j = > [0:1:(len(points_base[i])-1)]) > concat(points_base[i][j][0],points_base[i][j][1],i * stage_height)]]; > > // points - inside > > points_e = [for (i = [0:1:stages]) [for (j = > [0:1:(len(points_base_e[i])-1)]) > concat(points_base_e[i][j][0],points_base_e[i][j][1],i * stage_height)]]; > > //echo("points: ", points); > > // separate points in packs for stepped extrusion > > steps = [for (i = [0:1:stages-1]) points[i]]; > > steps_e = [for (i = [0:1:stages]) points_e[i]]; > > // extrusion with dotSCAD's loft function > > difference() { > > loft(steps,slices = myslices); > > difference() { > > loft(steps_e,slices = myslices); > > cylinder(h = bottom_thickness, r = rad * 2 + 20, center=true); > > } > > } > > //======================== FUNCTIONS > > function elbow(i,a,b,c) = lookup(i, [[0,a],[0.5,b],[1,c]]); > > function elbow2(i,a,b,c,d) = lookup(i, > [[0,a],[0.33333,b],[0.66666,c],[1,d]]); > > function pauw(x,p) = sign(x) * pow(abs(x),p); > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Tue, Apr 12, 2022 1:37 AM

Sanjeev's version takes 18 minutes to preview for me and 20 minutes to
render with a cube.  I did notice some oddities, though.  The first
image offset1.png shows his offset result in red, with a thickness of
2 next to a 2x2 green square.  It looks like the offset is 1 or less
instead of 2.  Also it's not a very even offset.  The use of offset 1
instead of 2 could potentially make the problem easier to solve.

In BOSL2, offset() can change the number of points: if it adds a
radius curve it increases the point count, and if part of the curve
collapses to a point, the number of points decreases.  In the example
posted, with the offset of 2, the number of points decreases, so the
lists do not have matching point count.  I don't know what loft() does
with that since I use BOSL2 instead, but it is unlikely to be good.
The BOSL2 skin module can actually handle this case---it will line up
mismatched data if you tell it to. But the algorithm is slow (cubic)
so it won't work with such huge inputs as the ones here.

When the mismatched data isn't lined up correctly, I think you get an
invalid VNF, at least in this case.  Certainly both dotSCAD loft() and
BOSL2 skin() produce pretty bad looking, artifact covered results.
Most likely there is some self intersecting patch or other issue as a
result.  (These aren't obvious because they are on the inside of the
model because you have offset inward.)

If you decrease the offset to 1, then it becomes less likely that the
offset collapses to a point.  Certainly for a small enough offset this
will happen.  In that case you can set check_valid=false in BOSL2
offset() and get a result faster, and the points line up.  I did this
with my code and got a preview in 9 minutes using the same settings
Sanjeev used, except offset of 1.  However, the resulting model when
unioned with a cube, failed, showing that somewhere, the offset had a
problem.

How then to solve the problem?  I have seen it happen other times that
someone wants to use offset in a way where the points can be lined up,
so I have written a new option for the BOSL2 offset, so you can write
same_length=true and get a result with the same length.  When several
points collapse in the offset the output repeats the corner point as
many times as necessary.  This output is correctly handled by the
BOSL2 skin().  I have no idea what dotSCAD loft() would do with it.
Using this I have gotten a model that previewed in about an hour with
the angle step set to 0.5.  So here's my code.  You'll need to get
the BOSL2 update that was just posted for this to work.  Note that I
think angle step 1 is a bit too large, but 0.1 is probably
unnecessarily small.  The offset() checks are quadratic, so going from
1 to 0.1 you should expect 100x the run time.  So make sure you have
this as big as you can tolerate.  You can probably also save time with
adaptive spacing of the stages, as some of the model has stages where
there is very little vertical change.  This implementation creates
your object as a single polyhedron without any differences, but I
require the bottom to be a multiple of the number of stages.  (We also
avoid computing the unused offsets for the bottom.)    This model has
so much symmetry that it really seems like it ought to be possible to
construct one "unit" and then replicate it around the circle, but
someone else can do that.  :)

include <BOSL2/std.scad>

stages =200;
stage_height = 1.25;
rad = 50;
f1 = 25;
f2 = 25;
phase1 = 0;
phase2 = 180;
height_depth=5;
depth1 = 20;
depth2 = 20;
thickness = 2;
bottom_stages = 2; //bottom_thickness = 3;
myslices = 0;

// angle_step=0.1;
angle_step=1;

// generate outer points

points_base =
  [for (i = [0:1:stages-1])
    let(f = pow(sin(i/stages * 120),2) * 7 + 1,
        var = 1 ,
        a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth))
    )
    [
     for(j = [0:angle_step:360-angle_step])
        let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages
                        +(pauw(sin(j

*f2+phase2),0.5)0.5+0.5)depth2(1-i/stages)))
R
[sin(j),cos(j)]
]
];

points_base_e = [for (i = [bottom_stages:1:stages-1])

offset(points_base[i],delta=-thickness,
closed=true,
quality=1,same_length=false)];

// points - outside
points = [for (i = [0:1:stages-1]) path3d(points_base[i],i*stage_height)];

// points - inside
points_e = [for (i = idx(points_base_e))

path3d(points_base_e[i],(i+bottom_stages)*stage_height)];

skin(concat(points, reverse(points_e)),slices=myslices);  // up

the outside, then down the inside

function pauw(x,p) = sign(x) * pow(abs(x),p);

The attached images show the offset computed by Sanjeev's code (with
the fingers down) next to a 2x2 square.  Offset looks irregular and is
not 2 units wide.  Second picture with fingers up is BOSL2 code with
offset of 2 next to the 2x2 square.  Final picture with fingers
pointing left is BOSL2 offset of 1.

Final picture shows the model computed using the above code with the
angle spacing set to 0.5.
On Mon, Apr 11, 2022 at 1:16 PM Sanjeev Prabhakar
sprabhakar2006@gmail.com wrote:

please try this code:

it took 3 minutes 43 sec to render in my system

include <sprabhakar2006/

dependencies.scad>

stages =200;

stage_height = 1.25;

rad = 50;

f1 = 25;

f2 = 25;

phase1 = 0;

phase2 = 180;

height_depth=5;

depth1 = 20;

depth2 = 20;

thickness = 2;

bottom_thickness = 3;

myslices = 5;

angle_step=1;

// generate outer points

points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages360f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j *f2+phase2),0.5)0.5+0.5)depth2(1-i/stages)),istage_height]]];

points_base1=[for(p=points_base)offst(c3t2(p),-thickness)];
points_base_e=[for(i=[0:len(points_base1)-1])[for(p=points_base1[i])[p.x,p.y,i*stage_height]]];
//echo(points_base_e);
swp_prism_h(points_base,points_base_e);
//swp(points_base_e);

step angle of 0.1 seems to be an overkill so increased  to 1

On Mon, 11 Apr 2022 at 15:15, roald.baudoux@brutele.be wrote:

Sanjeev, here’s the full code using your lib:

use <dotSCAD/src/loft.scad>;

include <sprabhakar2006/dependencies.scad>

stages =200;

stage_height = 1.25;

rad = 50;

f1 = 25;

f2 = 25;

phase1 = 0;

phase2 = 180;

height_depth=5;

depth1 = 20;

depth2 = 20;

thickness = 2;

bottom_thickness = 3;

myslices = 5;

angle_step=0.1;

// generate outer points

points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages360f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages))]]];

// generate inner points with offset from outer points for hollowing out

points_base_e = [for (i = [0:1:stages]) f_offset(points_base[i],-thickness)];

// points - outside

points = [for (i = [0:1:stages-1]) [for (j = [0:1:(len(points_base[i])-1)]) concat(points_base[i][j][0],points_base[i][j][1],i * stage_height)]];

// points - inside

points_e = [for (i = [0:1:stages]) [for (j = [0:1:(len(points_base_e[i])-1)]) concat(points_base_e[i][j][0],points_base_e[i][j][1],i * stage_height)]];

//echo("points: ", points);

// separate points in packs for stepped extrusion

steps = [for (i = [0:1:stages-1]) points[i]];

steps_e = [for (i = [0:1:stages]) points_e[i]];

// extrusion with dotSCAD's loft function

difference() {

loft(steps,slices = myslices);

difference() {

loft(steps_e,slices = myslices);

cylinder(h = bottom_thickness, r = rad * 2 + 20, center=true);

}

}

//======================== FUNCTIONS

function elbow(i,a,b,c) = lookup(i, [[0,a],[0.5,b],[1,c]]);

function elbow2(i,a,b,c,d) = lookup(i, [[0,a],[0.33333,b],[0.66666,c],[1,d]]);

function pauw(x,p) = sign(x) * pow(abs(x),p);


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Sanjeev's version takes 18 minutes to preview for me and 20 minutes to render with a cube. I did notice some oddities, though. The first image offset1.png shows his offset result in red, with a thickness of 2 next to a 2x2 green square. It looks like the offset is 1 or less instead of 2. Also it's not a very even offset. The use of offset 1 instead of 2 could potentially make the problem easier to solve. In BOSL2, offset() can change the number of points: if it adds a radius curve it increases the point count, and if part of the curve collapses to a point, the number of points decreases. In the example posted, with the offset of 2, the number of points decreases, so the lists do not have matching point count. I don't know what loft() does with that since I use BOSL2 instead, but it is unlikely to be good. The BOSL2 skin module can actually handle this case---it will line up mismatched data if you tell it to. But the algorithm is slow (cubic) so it won't work with such huge inputs as the ones here. When the mismatched data isn't lined up correctly, I think you get an invalid VNF, at least in this case. Certainly both dotSCAD loft() and BOSL2 skin() produce pretty bad looking, artifact covered results. Most likely there is some self intersecting patch or other issue as a result. (These aren't obvious because they are on the inside of the model because you have offset inward.) If you decrease the offset to 1, then it becomes less likely that the offset collapses to a point. Certainly for a small enough offset this will happen. In that case you can set check_valid=false in BOSL2 offset() and get a result faster, and the points line up. I did this with my code and got a preview in 9 minutes using the same settings Sanjeev used, except offset of 1. However, the resulting model when unioned with a cube, failed, showing that somewhere, the offset had a problem. How then to solve the problem? I have seen it happen other times that someone wants to use offset in a way where the points can be lined up, so I have written a new option for the BOSL2 offset, so you can write same_length=true and get a result with the same length. When several points collapse in the offset the output repeats the corner point as many times as necessary. This output is correctly handled by the BOSL2 skin(). I have no idea what dotSCAD loft() would do with it. Using this I have gotten a model that previewed in about an hour with the angle step set to 0.5. So here's my code. You'll need to get the BOSL2 update that was just posted for this to work. Note that I think angle step 1 is a bit too large, but 0.1 is probably unnecessarily small. The offset() checks are quadratic, so going from 1 to 0.1 you should expect 100x the run time. So make sure you have this as big as you can tolerate. You can probably also save time with adaptive spacing of the stages, as some of the model has stages where there is very little vertical change. This implementation creates your object as a single polyhedron without any differences, but I require the bottom to be a multiple of the number of stages. (We also avoid computing the unused offsets for the bottom.) This model has so much symmetry that it really seems like it ought to be possible to construct one "unit" and then replicate it around the circle, but someone else can do that. :) include <BOSL2/std.scad> stages =200; stage_height = 1.25; rad = 50; f1 = 25; f2 = 25; phase1 = 0; phase2 = 180; height_depth=5; depth1 = 20; depth2 = 20; thickness = 2; bottom_stages = 2; //bottom_thickness = 3; myslices = 0; // angle_step=0.1; angle_step=1; // generate outer points points_base = [for (i = [0:1:stages-1]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth)) ) [ for(j = [0:angle_step:360-angle_step]) let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages +(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages))) R*[sin(j),cos(j)] ] ]; points_base_e = [for (i = [bottom_stages:1:stages-1]) offset(points_base[i],delta=-thickness, closed=true, quality=1,same_length=false)]; // points - outside points = [for (i = [0:1:stages-1]) path3d(points_base[i],i*stage_height)]; // points - inside points_e = [for (i = idx(points_base_e)) path3d(points_base_e[i],(i+bottom_stages)*stage_height)]; skin(concat(points, reverse(points_e)),slices=myslices); // up the outside, then down the inside function pauw(x,p) = sign(x) * pow(abs(x),p); The attached images show the offset computed by Sanjeev's code (with the fingers down) next to a 2x2 square. Offset looks irregular and is not 2 units wide. Second picture with fingers up is BOSL2 code with offset of 2 next to the 2x2 square. Final picture with fingers pointing left is BOSL2 offset of 1. Final picture shows the model computed using the above code with the angle spacing set to 0.5. On Mon, Apr 11, 2022 at 1:16 PM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > > please try this code: > > it took 3 minutes 43 sec to render in my system > > include <sprabhakar2006/ > > dependencies.scad> > > stages =200; > > stage_height = 1.25; > > rad = 50; > > f1 = 25; > > f2 = 25; > > phase1 = 0; > > phase2 = 180; > > height_depth=5; > > depth1 = 20; > > depth2 = 20; > > thickness = 2; > > bottom_thickness = 3; > > myslices = 5; > > angle_step=1; > > // generate outer points > > points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)),i*stage_height]]]; > > points_base1=[for(p=points_base)offst(c3t2(p),-thickness)]; > points_base_e=[for(i=[0:len(points_base1)-1])[for(p=points_base1[i])[p.x,p.y,i*stage_height]]]; > //echo(points_base_e); > swp_prism_h(points_base,points_base_e); > //swp(points_base_e); > > step angle of 0.1 seems to be an overkill so increased to 1 > > On Mon, 11 Apr 2022 at 15:15, <roald.baudoux@brutele.be> wrote: >> >> Sanjeev, here’s the full code using your lib: >> >> use <dotSCAD/src/loft.scad>; >> >> include <sprabhakar2006/dependencies.scad> >> >> stages =200; >> >> stage_height = 1.25; >> >> rad = 50; >> >> f1 = 25; >> >> f2 = 25; >> >> phase1 = 0; >> >> phase2 = 180; >> >> height_depth=5; >> >> depth1 = 20; >> >> depth2 = 20; >> >> thickness = 2; >> >> bottom_thickness = 3; >> >> myslices = 5; >> >> angle_step=0.1; >> >> // generate outer points >> >> points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages))]]]; >> >> // generate inner points with offset from outer points for hollowing out >> >> points_base_e = [for (i = [0:1:stages]) f_offset(points_base[i],-thickness)]; >> >> // points - outside >> >> points = [for (i = [0:1:stages-1]) [for (j = [0:1:(len(points_base[i])-1)]) concat(points_base[i][j][0],points_base[i][j][1],i * stage_height)]]; >> >> // points - inside >> >> points_e = [for (i = [0:1:stages]) [for (j = [0:1:(len(points_base_e[i])-1)]) concat(points_base_e[i][j][0],points_base_e[i][j][1],i * stage_height)]]; >> >> //echo("points: ", points); >> >> // separate points in packs for stepped extrusion >> >> steps = [for (i = [0:1:stages-1]) points[i]]; >> >> steps_e = [for (i = [0:1:stages]) points_e[i]]; >> >> // extrusion with dotSCAD's loft function >> >> difference() { >> >> loft(steps,slices = myslices); >> >> difference() { >> >> loft(steps_e,slices = myslices); >> >> cylinder(h = bottom_thickness, r = rad * 2 + 20, center=true); >> >> } >> >> } >> >> //======================== FUNCTIONS >> >> function elbow(i,a,b,c) = lookup(i, [[0,a],[0.5,b],[1,c]]); >> >> function elbow2(i,a,b,c,d) = lookup(i, [[0,a],[0.33333,b],[0.66666,c],[1,d]]); >> >> function pauw(x,p) = sign(x) * pow(abs(x),p); >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
SP
Sanjeev Prabhakar
Tue, Apr 12, 2022 2:23 AM

Thanks Adrian
18 minutes you got with 0.1 step angle?
With 1 degree I got the render in around 4 minutes.
I wonder why there is so much of a difference

On Tue, 12 Apr 2022, 07:08 Adrian Mariano, avm4@cornell.edu wrote:

Sanjeev's version takes 18 minutes to preview for me and 20 minutes to
render with a cube.  I did notice some oddities, though.  The first
image offset1.png shows his offset result in red, with a thickness of
2 next to a 2x2 green square.  It looks like the offset is 1 or less
instead of 2.  Also it's not a very even offset.  The use of offset 1
instead of 2 could potentially make the problem easier to solve.

In BOSL2, offset() can change the number of points: if it adds a
radius curve it increases the point count, and if part of the curve
collapses to a point, the number of points decreases.  In the example
posted, with the offset of 2, the number of points decreases, so the
lists do not have matching point count.  I don't know what loft() does
with that since I use BOSL2 instead, but it is unlikely to be good.
The BOSL2 skin module can actually handle this case---it will line up
mismatched data if you tell it to. But the algorithm is slow (cubic)
so it won't work with such huge inputs as the ones here.

When the mismatched data isn't lined up correctly, I think you get an
invalid VNF, at least in this case.  Certainly both dotSCAD loft() and
BOSL2 skin() produce pretty bad looking, artifact covered results.
Most likely there is some self intersecting patch or other issue as a
result.  (These aren't obvious because they are on the inside of the
model because you have offset inward.)

If you decrease the offset to 1, then it becomes less likely that the
offset collapses to a point.  Certainly for a small enough offset this
will happen.  In that case you can set check_valid=false in BOSL2
offset() and get a result faster, and the points line up.  I did this
with my code and got a preview in 9 minutes using the same settings
Sanjeev used, except offset of 1.  However, the resulting model when
unioned with a cube, failed, showing that somewhere, the offset had a
problem.

How then to solve the problem?  I have seen it happen other times that
someone wants to use offset in a way where the points can be lined up,
so I have written a new option for the BOSL2 offset, so you can write
same_length=true and get a result with the same length.  When several
points collapse in the offset the output repeats the corner point as
many times as necessary.  This output is correctly handled by the
BOSL2 skin().  I have no idea what dotSCAD loft() would do with it.
Using this I have gotten a model that previewed in about an hour with
the angle step set to 0.5.  So here's my code.  You'll need to get
the BOSL2 update that was just posted for this to work.  Note that I
think angle step 1 is a bit too large, but 0.1 is probably
unnecessarily small.  The offset() checks are quadratic, so going from
1 to 0.1 you should expect 100x the run time.  So make sure you have
this as big as you can tolerate.  You can probably also save time with
adaptive spacing of the stages, as some of the model has stages where
there is very little vertical change.  This implementation creates
your object as a single polyhedron without any differences, but I
require the bottom to be a multiple of the number of stages.  (We also
avoid computing the unused offsets for the bottom.)    This model has
so much symmetry that it really seems like it ought to be possible to
construct one "unit" and then replicate it around the circle, but
someone else can do that.  :)

 include <BOSL2/std.scad>

 stages =200;
 stage_height = 1.25;
 rad = 50;
 f1 = 25;
 f2 = 25;
 phase1 = 0;
 phase2 = 180;
 height_depth=5;
 depth1 = 20;
 depth2 = 20;
 thickness = 2;
 bottom_stages = 2; //bottom_thickness = 3;
 myslices = 0;

 // angle_step=0.1;
 angle_step=1;

 // generate outer points

 points_base =
   [for (i = [0:1:stages-1])
     let(f = pow(sin(i/stages * 120),2) * 7 + 1,
         var = 1 ,
         a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var *

height_depth))
)
[
for(j = [0:angle_step:360-angle_step])
let(R=(rad+a+(pauw(sin(j
*f1+phase1),0.5)*0.5+0.5)depth1i/stages
+(pauw(sin(j
*f2+phase2),0.5)0.5+0.5)depth2(1-i/stages)))
R
[sin(j),cos(j)]
]
];

 points_base_e = [for (i = [bottom_stages:1:stages-1])

offset(points_base[i],delta=-thickness,
closed=true,
quality=1,same_length=false)];

 // points - outside
 points = [for (i = [0:1:stages-1])

path3d(points_base[i],i*stage_height)];

 // points - inside
 points_e = [for (i = idx(points_base_e))

path3d(points_base_e[i],(i+bottom_stages)*stage_height)];

 skin(concat(points, reverse(points_e)),slices=myslices);  // up

the outside, then down the inside

 function pauw(x,p) = sign(x) * pow(abs(x),p);

The attached images show the offset computed by Sanjeev's code (with
the fingers down) next to a 2x2 square.  Offset looks irregular and is
not 2 units wide.  Second picture with fingers up is BOSL2 code with
offset of 2 next to the 2x2 square.  Final picture with fingers
pointing left is BOSL2 offset of 1.

Final picture shows the model computed using the above code with the
angle spacing set to 0.5.
On Mon, Apr 11, 2022 at 1:16 PM Sanjeev Prabhakar
sprabhakar2006@gmail.com wrote:

please try this code:

it took 3 minutes 43 sec to render in my system

include <sprabhakar2006/

dependencies.scad>

stages =200;

stage_height = 1.25;

rad = 50;

f1 = 25;

f2 = 25;

phase1 = 0;

phase2 = 180;

height_depth=5;

depth1 = 20;

depth2 = 20;

thickness = 2;

bottom_thickness = 3;

myslices = 5;

angle_step=1;

// generate outer points

points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2)

  • 7 + 1, var = 1 , a=((sin((i/stages360f)%360) * 0.5 + 0.5) * (var *
    height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) *
    (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j
    *f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j
    *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j
    *f2+phase2),0.5)0.5+0.5)depth2(1-i/stages)),istage_height]]];

points_base1=[for(p=points_base)offst(c3t2(p),-thickness)];

points_base_e=[for(i=[0:len(points_base1)-1])[for(p=points_base1[i])[p.x,p.y,i*stage_height]]];

//echo(points_base_e);
swp_prism_h(points_base,points_base_e);
//swp(points_base_e);

step angle of 0.1 seems to be an overkill so increased  to 1

On Mon, 11 Apr 2022 at 15:15, roald.baudoux@brutele.be wrote:

Sanjeev, here’s the full code using your lib:

use <dotSCAD/src/loft.scad>;

include <sprabhakar2006/dependencies.scad>

stages =200;

stage_height = 1.25;

rad = 50;

f1 = 25;

f2 = 25;

phase1 = 0;

phase2 = 180;

height_depth=5;

depth1 = 20;

depth2 = 20;

thickness = 2;

bottom_thickness = 3;

myslices = 5;

angle_step=0.1;

// generate outer points

points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages *

120),2) * 7 + 1, var = 1 , a=((sin((i/stages360f)%360) * 0.5 + 0.5) *
(var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) *
(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j
*f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j
*f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j
*f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages))]]];

// generate inner points with offset from outer points for hollowing out

points_base_e = [for (i = [0:1:stages])

f_offset(points_base[i],-thickness)];

// points - outside

points = [for (i = [0:1:stages-1]) [for (j =

[0:1:(len(points_base[i])-1)])
concat(points_base[i][j][0],points_base[i][j][1],i * stage_height)]];

// points - inside

points_e = [for (i = [0:1:stages]) [for (j =

[0:1:(len(points_base_e[i])-1)])
concat(points_base_e[i][j][0],points_base_e[i][j][1],i * stage_height)]];

//echo("points: ", points);

// separate points in packs for stepped extrusion

steps = [for (i = [0:1:stages-1]) points[i]];

steps_e = [for (i = [0:1:stages]) points_e[i]];

// extrusion with dotSCAD's loft function

difference() {

loft(steps,slices = myslices);

difference() {

loft(steps_e,slices = myslices);

cylinder(h = bottom_thickness, r = rad * 2 + 20, center=true);

}

}

//======================== FUNCTIONS

function elbow(i,a,b,c) = lookup(i, [[0,a],[0.5,b],[1,c]]);

function elbow2(i,a,b,c,d) = lookup(i,

[[0,a],[0.33333,b],[0.66666,c],[1,d]]);

function pauw(x,p) = sign(x) * pow(abs(x),p);


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Thanks Adrian 18 minutes you got with 0.1 step angle? With 1 degree I got the render in around 4 minutes. I wonder why there is so much of a difference On Tue, 12 Apr 2022, 07:08 Adrian Mariano, <avm4@cornell.edu> wrote: > Sanjeev's version takes 18 minutes to preview for me and 20 minutes to > render with a cube. I did notice some oddities, though. The first > image offset1.png shows his offset result in red, with a thickness of > 2 next to a 2x2 green square. It looks like the offset is 1 or less > instead of 2. Also it's not a very even offset. The use of offset 1 > instead of 2 could potentially make the problem easier to solve. > > In BOSL2, offset() can change the number of points: if it adds a > radius curve it increases the point count, and if part of the curve > collapses to a point, the number of points decreases. In the example > posted, with the offset of 2, the number of points decreases, so the > lists do not have matching point count. I don't know what loft() does > with that since I use BOSL2 instead, but it is unlikely to be good. > The BOSL2 skin module can actually handle this case---it will line up > mismatched data if you tell it to. But the algorithm is slow (cubic) > so it won't work with such huge inputs as the ones here. > > When the mismatched data isn't lined up correctly, I think you get an > invalid VNF, at least in this case. Certainly both dotSCAD loft() and > BOSL2 skin() produce pretty bad looking, artifact covered results. > Most likely there is some self intersecting patch or other issue as a > result. (These aren't obvious because they are on the inside of the > model because you have offset inward.) > > If you decrease the offset to 1, then it becomes less likely that the > offset collapses to a point. Certainly for a small enough offset this > will happen. In that case you can set check_valid=false in BOSL2 > offset() and get a result faster, and the points line up. I did this > with my code and got a preview in 9 minutes using the same settings > Sanjeev used, except offset of 1. However, the resulting model when > unioned with a cube, failed, showing that somewhere, the offset had a > problem. > > How then to solve the problem? I have seen it happen other times that > someone wants to use offset in a way where the points can be lined up, > so I have written a new option for the BOSL2 offset, so you can write > same_length=true and get a result with the same length. When several > points collapse in the offset the output repeats the corner point as > many times as necessary. This output is correctly handled by the > BOSL2 skin(). I have no idea what dotSCAD loft() would do with it. > Using this I have gotten a model that previewed in about an hour with > the angle step set to 0.5. So here's my code. You'll need to get > the BOSL2 update that was just posted for this to work. Note that I > think angle step 1 is a bit too large, but 0.1 is probably > unnecessarily small. The offset() checks are quadratic, so going from > 1 to 0.1 you should expect 100x the run time. So make sure you have > this as big as you can tolerate. You can probably also save time with > adaptive spacing of the stages, as some of the model has stages where > there is very little vertical change. This implementation creates > your object as a single polyhedron without any differences, but I > require the bottom to be a multiple of the number of stages. (We also > avoid computing the unused offsets for the bottom.) This model has > so much symmetry that it really seems like it ought to be possible to > construct one "unit" and then replicate it around the circle, but > someone else can do that. :) > > include <BOSL2/std.scad> > > stages =200; > stage_height = 1.25; > rad = 50; > f1 = 25; > f2 = 25; > phase1 = 0; > phase2 = 180; > height_depth=5; > depth1 = 20; > depth2 = 20; > thickness = 2; > bottom_stages = 2; //bottom_thickness = 3; > myslices = 0; > > // angle_step=0.1; > angle_step=1; > > // generate outer points > > points_base = > [for (i = [0:1:stages-1]) > let(f = pow(sin(i/stages * 120),2) * 7 + 1, > var = 1 , > a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * > height_depth)) > ) > [ > for(j = [0:angle_step:360-angle_step]) > let(R=(rad+a+(pauw(sin(j > *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages > +(pauw(sin(j > *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages))) > R*[sin(j),cos(j)] > ] > ]; > > points_base_e = [for (i = [bottom_stages:1:stages-1]) > offset(points_base[i],delta=-thickness, > closed=true, > quality=1,same_length=false)]; > > // points - outside > points = [for (i = [0:1:stages-1]) > path3d(points_base[i],i*stage_height)]; > > // points - inside > points_e = [for (i = idx(points_base_e)) > path3d(points_base_e[i],(i+bottom_stages)*stage_height)]; > > skin(concat(points, reverse(points_e)),slices=myslices); // up > the outside, then down the inside > > function pauw(x,p) = sign(x) * pow(abs(x),p); > > The attached images show the offset computed by Sanjeev's code (with > the fingers down) next to a 2x2 square. Offset looks irregular and is > not 2 units wide. Second picture with fingers up is BOSL2 code with > offset of 2 next to the 2x2 square. Final picture with fingers > pointing left is BOSL2 offset of 1. > > Final picture shows the model computed using the above code with the > angle spacing set to 0.5. > On Mon, Apr 11, 2022 at 1:16 PM Sanjeev Prabhakar > <sprabhakar2006@gmail.com> wrote: > > > > please try this code: > > > > it took 3 minutes 43 sec to render in my system > > > > include <sprabhakar2006/ > > > > dependencies.scad> > > > > stages =200; > > > > stage_height = 1.25; > > > > rad = 50; > > > > f1 = 25; > > > > f2 = 25; > > > > phase1 = 0; > > > > phase2 = 180; > > > > height_depth=5; > > > > depth1 = 20; > > > > depth2 = 20; > > > > thickness = 2; > > > > bottom_thickness = 3; > > > > myslices = 5; > > > > angle_step=1; > > > > // generate outer points > > > > points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) > * 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * > height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * > (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j > *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j > *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j > *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)),i*stage_height]]]; > > > > points_base1=[for(p=points_base)offst(c3t2(p),-thickness)]; > > > points_base_e=[for(i=[0:len(points_base1)-1])[for(p=points_base1[i])[p.x,p.y,i*stage_height]]]; > > //echo(points_base_e); > > swp_prism_h(points_base,points_base_e); > > //swp(points_base_e); > > > > step angle of 0.1 seems to be an overkill so increased to 1 > > > > On Mon, 11 Apr 2022 at 15:15, <roald.baudoux@brutele.be> wrote: > >> > >> Sanjeev, here’s the full code using your lib: > >> > >> use <dotSCAD/src/loft.scad>; > >> > >> include <sprabhakar2006/dependencies.scad> > >> > >> stages =200; > >> > >> stage_height = 1.25; > >> > >> rad = 50; > >> > >> f1 = 25; > >> > >> f2 = 25; > >> > >> phase1 = 0; > >> > >> phase2 = 180; > >> > >> height_depth=5; > >> > >> depth1 = 20; > >> > >> depth2 = 20; > >> > >> thickness = 2; > >> > >> bottom_thickness = 3; > >> > >> myslices = 5; > >> > >> angle_step=0.1; > >> > >> // generate outer points > >> > >> points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * > 120),2) * 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * > (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * > (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j > *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j > *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j > *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages))]]]; > >> > >> // generate inner points with offset from outer points for hollowing out > >> > >> points_base_e = [for (i = [0:1:stages]) > f_offset(points_base[i],-thickness)]; > >> > >> // points - outside > >> > >> points = [for (i = [0:1:stages-1]) [for (j = > [0:1:(len(points_base[i])-1)]) > concat(points_base[i][j][0],points_base[i][j][1],i * stage_height)]]; > >> > >> // points - inside > >> > >> points_e = [for (i = [0:1:stages]) [for (j = > [0:1:(len(points_base_e[i])-1)]) > concat(points_base_e[i][j][0],points_base_e[i][j][1],i * stage_height)]]; > >> > >> //echo("points: ", points); > >> > >> // separate points in packs for stepped extrusion > >> > >> steps = [for (i = [0:1:stages-1]) points[i]]; > >> > >> steps_e = [for (i = [0:1:stages]) points_e[i]]; > >> > >> // extrusion with dotSCAD's loft function > >> > >> difference() { > >> > >> loft(steps,slices = myslices); > >> > >> difference() { > >> > >> loft(steps_e,slices = myslices); > >> > >> cylinder(h = bottom_thickness, r = rad * 2 + 20, center=true); > >> > >> } > >> > >> } > >> > >> //======================== FUNCTIONS > >> > >> function elbow(i,a,b,c) = lookup(i, [[0,a],[0.5,b],[1,c]]); > >> > >> function elbow2(i,a,b,c,d) = lookup(i, > [[0,a],[0.33333,b],[0.66666,c],[1,d]]); > >> > >> function pauw(x,p) = sign(x) * pow(abs(x),p); > >> > >> _______________________________________________ > >> OpenSCAD mailing list > >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > _______________________________________________ > > OpenSCAD mailing list > > To unsubscribe send an email to discuss-leave@lists.openscad.org > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
FH
Father Horton
Tue, Apr 12, 2022 2:50 AM

This model has
so much symmetry that it really seems like it ought to be possible to
construct one "unit" and then replicate it around the circle, but
someone else can do that.  :)

"This is left as an exercise for the reader."

> > This model has > so much symmetry that it really seems like it ought to be possible to > construct one "unit" and then replicate it around the circle, but > someone else can do that. :) > "This is left as an exercise for the reader."
AM
Adrian Mariano
Tue, Apr 12, 2022 3:38 AM

No, 18 minutes was with your code exactly as you posted it, with one
degree angle step.  I guess your computer could be 4.5x faster than
mine.  Or maybe for some reason a different OpenSCAD version is much
faster?  I don't know.  I tried a more recent OpenSCAD and it ran in
15:45, so slightly faster.

Another remark, since I'm posting again:  the object has vertical
anti-symmetry, which means the speed can immediately be doubled by not
recomputing the top half.  So exercise 1 for the reader is to exploit
vertical symmetry and exercise 2 the rotational symmetry.  In
particular, it occurred to me that rotational symmetry could be
exploited at the path level rather than at the object level, so no
complex object union would be needed.

On Mon, Apr 11, 2022 at 10:24 PM Sanjeev Prabhakar
sprabhakar2006@gmail.com wrote:

Thanks Adrian
18 minutes you got with 0.1 step angle?
With 1 degree I got the render in around 4 minutes.
I wonder why there is so much of a difference

On Tue, 12 Apr 2022, 07:08 Adrian Mariano, avm4@cornell.edu wrote:

Sanjeev's version takes 18 minutes to preview for me and 20 minutes to
render with a cube.  I did notice some oddities, though.  The first
image offset1.png shows his offset result in red, with a thickness of
2 next to a 2x2 green square.  It looks like the offset is 1 or less
instead of 2.  Also it's not a very even offset.  The use of offset 1
instead of 2 could potentially make the problem easier to solve.

In BOSL2, offset() can change the number of points: if it adds a
radius curve it increases the point count, and if part of the curve
collapses to a point, the number of points decreases.  In the example
posted, with the offset of 2, the number of points decreases, so the
lists do not have matching point count.  I don't know what loft() does
with that since I use BOSL2 instead, but it is unlikely to be good.
The BOSL2 skin module can actually handle this case---it will line up
mismatched data if you tell it to. But the algorithm is slow (cubic)
so it won't work with such huge inputs as the ones here.

When the mismatched data isn't lined up correctly, I think you get an
invalid VNF, at least in this case.  Certainly both dotSCAD loft() and
BOSL2 skin() produce pretty bad looking, artifact covered results.
Most likely there is some self intersecting patch or other issue as a
result.  (These aren't obvious because they are on the inside of the
model because you have offset inward.)

If you decrease the offset to 1, then it becomes less likely that the
offset collapses to a point.  Certainly for a small enough offset this
will happen.  In that case you can set check_valid=false in BOSL2
offset() and get a result faster, and the points line up.  I did this
with my code and got a preview in 9 minutes using the same settings
Sanjeev used, except offset of 1.  However, the resulting model when
unioned with a cube, failed, showing that somewhere, the offset had a
problem.

How then to solve the problem?  I have seen it happen other times that
someone wants to use offset in a way where the points can be lined up,
so I have written a new option for the BOSL2 offset, so you can write
same_length=true and get a result with the same length.  When several
points collapse in the offset the output repeats the corner point as
many times as necessary.  This output is correctly handled by the
BOSL2 skin().  I have no idea what dotSCAD loft() would do with it.
Using this I have gotten a model that previewed in about an hour with
the angle step set to 0.5.  So here's my code.  You'll need to get
the BOSL2 update that was just posted for this to work.  Note that I
think angle step 1 is a bit too large, but 0.1 is probably
unnecessarily small.  The offset() checks are quadratic, so going from
1 to 0.1 you should expect 100x the run time.  So make sure you have
this as big as you can tolerate.  You can probably also save time with
adaptive spacing of the stages, as some of the model has stages where
there is very little vertical change.  This implementation creates
your object as a single polyhedron without any differences, but I
require the bottom to be a multiple of the number of stages.  (We also
avoid computing the unused offsets for the bottom.)    This model has
so much symmetry that it really seems like it ought to be possible to
construct one "unit" and then replicate it around the circle, but
someone else can do that.  :)

include <BOSL2/std.scad>

stages =200;
stage_height = 1.25;
rad = 50;
f1 = 25;
f2 = 25;
phase1 = 0;
phase2 = 180;
height_depth=5;
depth1 = 20;
depth2 = 20;
thickness = 2;
bottom_stages = 2; //bottom_thickness = 3;
myslices = 0;

// angle_step=0.1;
angle_step=1;

// generate outer points

points_base =
  [for (i = [0:1:stages-1])
    let(f = pow(sin(i/stages * 120),2) * 7 + 1,
        var = 1 ,
        a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth))
    )
    [
     for(j = [0:angle_step:360-angle_step])
        let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages
                        +(pauw(sin(j

*f2+phase2),0.5)0.5+0.5)depth2(1-i/stages)))
R
[sin(j),cos(j)]
]
];

points_base_e = [for (i = [bottom_stages:1:stages-1])

offset(points_base[i],delta=-thickness,
closed=true,
quality=1,same_length=false)];

// points - outside
points = [for (i = [0:1:stages-1]) path3d(points_base[i],i*stage_height)];

// points - inside
points_e = [for (i = idx(points_base_e))

path3d(points_base_e[i],(i+bottom_stages)*stage_height)];

skin(concat(points, reverse(points_e)),slices=myslices);  // up

the outside, then down the inside

function pauw(x,p) = sign(x) * pow(abs(x),p);

The attached images show the offset computed by Sanjeev's code (with
the fingers down) next to a 2x2 square.  Offset looks irregular and is
not 2 units wide.  Second picture with fingers up is BOSL2 code with
offset of 2 next to the 2x2 square.  Final picture with fingers
pointing left is BOSL2 offset of 1.

Final picture shows the model computed using the above code with the
angle spacing set to 0.5.
On Mon, Apr 11, 2022 at 1:16 PM Sanjeev Prabhakar
sprabhakar2006@gmail.com wrote:

please try this code:

it took 3 minutes 43 sec to render in my system

include <sprabhakar2006/

dependencies.scad>

stages =200;

stage_height = 1.25;

rad = 50;

f1 = 25;

f2 = 25;

phase1 = 0;

phase2 = 180;

height_depth=5;

depth1 = 20;

depth2 = 20;

thickness = 2;

bottom_thickness = 3;

myslices = 5;

angle_step=1;

// generate outer points

points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages360f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j *f2+phase2),0.5)0.5+0.5)depth2(1-i/stages)),istage_height]]];

points_base1=[for(p=points_base)offst(c3t2(p),-thickness)];
points_base_e=[for(i=[0:len(points_base1)-1])[for(p=points_base1[i])[p.x,p.y,i*stage_height]]];
//echo(points_base_e);
swp_prism_h(points_base,points_base_e);
//swp(points_base_e);

step angle of 0.1 seems to be an overkill so increased  to 1

On Mon, 11 Apr 2022 at 15:15, roald.baudoux@brutele.be wrote:

Sanjeev, here’s the full code using your lib:

use <dotSCAD/src/loft.scad>;

include <sprabhakar2006/dependencies.scad>

stages =200;

stage_height = 1.25;

rad = 50;

f1 = 25;

f2 = 25;

phase1 = 0;

phase2 = 180;

height_depth=5;

depth1 = 20;

depth2 = 20;

thickness = 2;

bottom_thickness = 3;

myslices = 5;

angle_step=0.1;

// generate outer points

points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages360f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)depth1i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)depth2(1-i/stages))]]];

// generate inner points with offset from outer points for hollowing out

points_base_e = [for (i = [0:1:stages]) f_offset(points_base[i],-thickness)];

// points - outside

points = [for (i = [0:1:stages-1]) [for (j = [0:1:(len(points_base[i])-1)]) concat(points_base[i][j][0],points_base[i][j][1],i * stage_height)]];

// points - inside

points_e = [for (i = [0:1:stages]) [for (j = [0:1:(len(points_base_e[i])-1)]) concat(points_base_e[i][j][0],points_base_e[i][j][1],i * stage_height)]];

//echo("points: ", points);

// separate points in packs for stepped extrusion

steps = [for (i = [0:1:stages-1]) points[i]];

steps_e = [for (i = [0:1:stages]) points_e[i]];

// extrusion with dotSCAD's loft function

difference() {

loft(steps,slices = myslices);

difference() {

loft(steps_e,slices = myslices);

cylinder(h = bottom_thickness, r = rad * 2 + 20, center=true);

}

}

//======================== FUNCTIONS

function elbow(i,a,b,c) = lookup(i, [[0,a],[0.5,b],[1,c]]);

function elbow2(i,a,b,c,d) = lookup(i, [[0,a],[0.33333,b],[0.66666,c],[1,d]]);

function pauw(x,p) = sign(x) * pow(abs(x),p);


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

No, 18 minutes was with your code exactly as you posted it, with one degree angle step. I guess your computer could be 4.5x faster than mine. Or maybe for some reason a different OpenSCAD version is much faster? I don't know. I tried a more recent OpenSCAD and it ran in 15:45, so slightly faster. Another remark, since I'm posting again: the object has vertical anti-symmetry, which means the speed can immediately be doubled by not recomputing the top half. So exercise 1 for the reader is to exploit vertical symmetry and exercise 2 the rotational symmetry. In particular, it occurred to me that rotational symmetry could be exploited at the path level rather than at the object level, so no complex object union would be needed. On Mon, Apr 11, 2022 at 10:24 PM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > > Thanks Adrian > 18 minutes you got with 0.1 step angle? > With 1 degree I got the render in around 4 minutes. > I wonder why there is so much of a difference > > On Tue, 12 Apr 2022, 07:08 Adrian Mariano, <avm4@cornell.edu> wrote: >> >> Sanjeev's version takes 18 minutes to preview for me and 20 minutes to >> render with a cube. I did notice some oddities, though. The first >> image offset1.png shows his offset result in red, with a thickness of >> 2 next to a 2x2 green square. It looks like the offset is 1 or less >> instead of 2. Also it's not a very even offset. The use of offset 1 >> instead of 2 could potentially make the problem easier to solve. >> >> In BOSL2, offset() can change the number of points: if it adds a >> radius curve it increases the point count, and if part of the curve >> collapses to a point, the number of points decreases. In the example >> posted, with the offset of 2, the number of points decreases, so the >> lists do not have matching point count. I don't know what loft() does >> with that since I use BOSL2 instead, but it is unlikely to be good. >> The BOSL2 skin module can actually handle this case---it will line up >> mismatched data if you tell it to. But the algorithm is slow (cubic) >> so it won't work with such huge inputs as the ones here. >> >> When the mismatched data isn't lined up correctly, I think you get an >> invalid VNF, at least in this case. Certainly both dotSCAD loft() and >> BOSL2 skin() produce pretty bad looking, artifact covered results. >> Most likely there is some self intersecting patch or other issue as a >> result. (These aren't obvious because they are on the inside of the >> model because you have offset inward.) >> >> If you decrease the offset to 1, then it becomes less likely that the >> offset collapses to a point. Certainly for a small enough offset this >> will happen. In that case you can set check_valid=false in BOSL2 >> offset() and get a result faster, and the points line up. I did this >> with my code and got a preview in 9 minutes using the same settings >> Sanjeev used, except offset of 1. However, the resulting model when >> unioned with a cube, failed, showing that somewhere, the offset had a >> problem. >> >> How then to solve the problem? I have seen it happen other times that >> someone wants to use offset in a way where the points can be lined up, >> so I have written a new option for the BOSL2 offset, so you can write >> same_length=true and get a result with the same length. When several >> points collapse in the offset the output repeats the corner point as >> many times as necessary. This output is correctly handled by the >> BOSL2 skin(). I have no idea what dotSCAD loft() would do with it. >> Using this I have gotten a model that previewed in about an hour with >> the angle step set to 0.5. So here's my code. You'll need to get >> the BOSL2 update that was just posted for this to work. Note that I >> think angle step 1 is a bit too large, but 0.1 is probably >> unnecessarily small. The offset() checks are quadratic, so going from >> 1 to 0.1 you should expect 100x the run time. So make sure you have >> this as big as you can tolerate. You can probably also save time with >> adaptive spacing of the stages, as some of the model has stages where >> there is very little vertical change. This implementation creates >> your object as a single polyhedron without any differences, but I >> require the bottom to be a multiple of the number of stages. (We also >> avoid computing the unused offsets for the bottom.) This model has >> so much symmetry that it really seems like it ought to be possible to >> construct one "unit" and then replicate it around the circle, but >> someone else can do that. :) >> >> include <BOSL2/std.scad> >> >> stages =200; >> stage_height = 1.25; >> rad = 50; >> f1 = 25; >> f2 = 25; >> phase1 = 0; >> phase2 = 180; >> height_depth=5; >> depth1 = 20; >> depth2 = 20; >> thickness = 2; >> bottom_stages = 2; //bottom_thickness = 3; >> myslices = 0; >> >> // angle_step=0.1; >> angle_step=1; >> >> // generate outer points >> >> points_base = >> [for (i = [0:1:stages-1]) >> let(f = pow(sin(i/stages * 120),2) * 7 + 1, >> var = 1 , >> a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth)) >> ) >> [ >> for(j = [0:angle_step:360-angle_step]) >> let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages >> +(pauw(sin(j >> *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages))) >> R*[sin(j),cos(j)] >> ] >> ]; >> >> points_base_e = [for (i = [bottom_stages:1:stages-1]) >> offset(points_base[i],delta=-thickness, >> closed=true, >> quality=1,same_length=false)]; >> >> // points - outside >> points = [for (i = [0:1:stages-1]) path3d(points_base[i],i*stage_height)]; >> >> // points - inside >> points_e = [for (i = idx(points_base_e)) >> path3d(points_base_e[i],(i+bottom_stages)*stage_height)]; >> >> skin(concat(points, reverse(points_e)),slices=myslices); // up >> the outside, then down the inside >> >> function pauw(x,p) = sign(x) * pow(abs(x),p); >> >> The attached images show the offset computed by Sanjeev's code (with >> the fingers down) next to a 2x2 square. Offset looks irregular and is >> not 2 units wide. Second picture with fingers up is BOSL2 code with >> offset of 2 next to the 2x2 square. Final picture with fingers >> pointing left is BOSL2 offset of 1. >> >> Final picture shows the model computed using the above code with the >> angle spacing set to 0.5. >> On Mon, Apr 11, 2022 at 1:16 PM Sanjeev Prabhakar >> <sprabhakar2006@gmail.com> wrote: >> > >> > please try this code: >> > >> > it took 3 minutes 43 sec to render in my system >> > >> > include <sprabhakar2006/ >> > >> > dependencies.scad> >> > >> > stages =200; >> > >> > stage_height = 1.25; >> > >> > rad = 50; >> > >> > f1 = 25; >> > >> > f2 = 25; >> > >> > phase1 = 0; >> > >> > phase2 = 180; >> > >> > height_depth=5; >> > >> > depth1 = 20; >> > >> > depth2 = 20; >> > >> > thickness = 2; >> > >> > bottom_thickness = 3; >> > >> > myslices = 5; >> > >> > angle_step=1; >> > >> > // generate outer points >> > >> > points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)),i*stage_height]]]; >> > >> > points_base1=[for(p=points_base)offst(c3t2(p),-thickness)]; >> > points_base_e=[for(i=[0:len(points_base1)-1])[for(p=points_base1[i])[p.x,p.y,i*stage_height]]]; >> > //echo(points_base_e); >> > swp_prism_h(points_base,points_base_e); >> > //swp(points_base_e); >> > >> > step angle of 0.1 seems to be an overkill so increased to 1 >> > >> > On Mon, 11 Apr 2022 at 15:15, <roald.baudoux@brutele.be> wrote: >> >> >> >> Sanjeev, here’s the full code using your lib: >> >> >> >> use <dotSCAD/src/loft.scad>; >> >> >> >> include <sprabhakar2006/dependencies.scad> >> >> >> >> stages =200; >> >> >> >> stage_height = 1.25; >> >> >> >> rad = 50; >> >> >> >> f1 = 25; >> >> >> >> f2 = 25; >> >> >> >> phase1 = 0; >> >> >> >> phase2 = 180; >> >> >> >> height_depth=5; >> >> >> >> depth1 = 20; >> >> >> >> depth2 = 20; >> >> >> >> thickness = 2; >> >> >> >> bottom_thickness = 3; >> >> >> >> myslices = 5; >> >> >> >> angle_step=0.1; >> >> >> >> // generate outer points >> >> >> >> points_base = [for (i = [0:1:stages]) let(f = pow(sin(i/stages * 120),2) * 7 + 1, var = 1 , a=((sin((i/stages*360*f)%360) * 0.5 + 0.5) * (var * height_depth))) [for(j = [0:angle_step:360-angle_step]) [sin(j) * (rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages)), cos(j) *(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages+(pauw(sin(j *f2+phase2),0.5)*0.5+0.5)*depth2*(1-i/stages))]]]; >> >> >> >> // generate inner points with offset from outer points for hollowing out >> >> >> >> points_base_e = [for (i = [0:1:stages]) f_offset(points_base[i],-thickness)]; >> >> >> >> // points - outside >> >> >> >> points = [for (i = [0:1:stages-1]) [for (j = [0:1:(len(points_base[i])-1)]) concat(points_base[i][j][0],points_base[i][j][1],i * stage_height)]]; >> >> >> >> // points - inside >> >> >> >> points_e = [for (i = [0:1:stages]) [for (j = [0:1:(len(points_base_e[i])-1)]) concat(points_base_e[i][j][0],points_base_e[i][j][1],i * stage_height)]]; >> >> >> >> //echo("points: ", points); >> >> >> >> // separate points in packs for stepped extrusion >> >> >> >> steps = [for (i = [0:1:stages-1]) points[i]]; >> >> >> >> steps_e = [for (i = [0:1:stages]) points_e[i]]; >> >> >> >> // extrusion with dotSCAD's loft function >> >> >> >> difference() { >> >> >> >> loft(steps,slices = myslices); >> >> >> >> difference() { >> >> >> >> loft(steps_e,slices = myslices); >> >> >> >> cylinder(h = bottom_thickness, r = rad * 2 + 20, center=true); >> >> >> >> } >> >> >> >> } >> >> >> >> //======================== FUNCTIONS >> >> >> >> function elbow(i,a,b,c) = lookup(i, [[0,a],[0.5,b],[1,c]]); >> >> >> >> function elbow2(i,a,b,c,d) = lookup(i, [[0,a],[0.33333,b],[0.66666,c],[1,d]]); >> >> >> >> function pauw(x,p) = sign(x) * pow(abs(x),p); >> >> >> >> _______________________________________________ >> >> OpenSCAD mailing list >> >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > >> > _______________________________________________ >> > OpenSCAD mailing list >> > To unsubscribe send an email to discuss-leave@lists.openscad.org >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
RB
roald.baudoux@brutele.be
Tue, Apr 12, 2022 6:42 AM

@Sajeev : thanky you but unfortunately, it’s important for me to have a 0.1 degree resolution otherwise some curves really don’t look like curves. But indeed this figure seem to have some influence on the success or the failure of the rendering.

@Adrian: thanks a lot for updating BOSL2’s only to solve this issue!

About this remark : “This model has so much symmetry that it really seems like it ought to be possible to construct one "unit" and then replicate it around the circle”. Actually my current explorations target the evolution of dimensions and shapes according to the height and the angle around the cylinder. So my very basic way of conceiving the model is as a modulated surface. Therefore I am not sure that thinking with units would be helpful. For instance, the curvature of the sine could evolve along these dimensions (see the “pauw” function for instance). You can also see that the frequency of the evolutions of the diameter along the vertical axis changes constantly, that is at the phase level. I don’t know if you could have this with some kind of module. But I’d be happy to be wrong if this could help get a faster rendering of course…

@Sajeev : thanky you but unfortunately, it’s important for me to have a 0.1 degree resolution otherwise some curves really don’t look like curves. But indeed this figure seem to have some influence on the success or the failure of the rendering.\ \ @Adrian: thanks a lot for updating BOSL2’s only to solve this issue! About this remark : “This model has so much symmetry that it really seems like it ought to be possible to construct one "unit" and then replicate it around the circle”. Actually my current explorations target the evolution of dimensions and shapes according to the height and the angle around the cylinder. So my very basic way of conceiving the model is as a modulated surface. Therefore I am not sure that thinking with units would be helpful. For instance, the curvature of the sine could evolve along these dimensions (see the “pauw” function for instance). You can also see that the frequency of the evolutions of the diameter along the vertical axis changes constantly, that is at the phase level. I don’t know if you could have this with some kind of module. But I’d be happy to be wrong if this could help get a faster rendering of course…
RB
roald.baudoux@brutele.be
Tue, Apr 12, 2022 7:02 AM

In the definition of R two multiplications were missing.

let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages
                        +(pauw(sin(j*f2+phase2),0.5)0.5+0.5)depth2(1-i/stages)))

should be:

let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages
                        +(pauw(sin(j*f2+phase2),0.5)*0.5+0.5)*depth2(1-i/stages)))

I suppose there's also something missing in:

R[sin(j),cos(j)]

because it triggers an error message. But what?
In the definition of R two multiplications were missing. ``` let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages +(pauw(sin(j*f2+phase2),0.5)0.5+0.5)depth2(1-i/stages))) should be: let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages +(pauw(sin(j*f2+phase2),0.5)*0.5+0.5)*depth2(1-i/stages))) I suppose there's also something missing in: R[sin(j),cos(j)] because it triggers an error message. But what? ```
AM
Adrian Mariano
Tue, Apr 12, 2022 10:48 AM

It sounds like something is eating asterisk symbols for you.  Not sure
why that would happen.  When I look at what I posted it looks correct.
That line should have an asterisk after the R.  I'll try including the
code as an attachment here.

With regards to symmetry, I can only speak about what I see in your
existing model.  Your equations are complex, so I haven't tried to
understand them.  Right now you have a lot of symmetry: at each stage
it looks like 25 fold rotational symmetry.  That means in principle
you can make the model 25^2 faster by exploiting this, which would be
a huge win.  I think it would be fairly easy to do actually.  At each
stage, instead of computing the whole curve, compute 1/25 of the
curve, plus some extra points.  Then do an offset (closed=false).
Remove the extra points, which are there to prevent end effects, and
then rotate the remaining points around 24 times (zrot can do that)
and concatenate the result.  Because this makes the offset very much
shorter it will make the calculation enormously faster and enable that
very fine sampling you want.  Of course, you need a way to figure out
or know the symmetry, which is always going to be possible if you have
a fixed representation and you're exploring parameters, but it won't
be so easy if you're changing the equations in more significant ways
as you explore.  Note that if you have a rotational evolution you
have to come back to where you started, so it's natural for symmetry
to arise.  Exploiting vertical symmetry makes less of a difference.

On Tue, Apr 12, 2022 at 3:02 AM roald.baudoux@brutele.be wrote:

In the definition of R two multiplications were missing.

let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)0.5+0.5)depth1i/stages
+(pauw(sin(j
f2+phase2),0.5)0.5+0.5)depth2(1-i/stages)))

should be:

let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)0.5+0.5)depth1i/stages
+(pauw(sin(j
f2+phase2),0.5)*0.5+0.5)*depth2(1-i/stages)))

I suppose there's also something missing in:

R[sin(j),cos(j)]

because it triggers an error message. But what?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

It sounds like something is eating asterisk symbols for you. Not sure why that would happen. When I look at what I posted it looks correct. That line should have an asterisk after the R. I'll try including the code as an attachment here. With regards to symmetry, I can only speak about what I see in your existing model. Your equations are complex, so I haven't tried to understand them. Right now you have a lot of symmetry: at each stage it looks like 25 fold rotational symmetry. That means in principle you can make the model 25^2 faster by exploiting this, which would be a huge win. I think it would be fairly easy to do actually. At each stage, instead of computing the whole curve, compute 1/25 of the curve, plus some extra points. Then do an offset (closed=false). Remove the extra points, which are there to prevent end effects, and then rotate the remaining points around 24 times (zrot can do that) and concatenate the result. Because this makes the offset very much shorter it will make the calculation enormously faster and enable that very fine sampling you want. Of course, you need a way to figure out or know the symmetry, which is always going to be possible if you have a fixed representation and you're exploring parameters, but it won't be so easy if you're changing the equations in more significant ways as you explore. Note that if you have a rotational evolution you have to come back to where you started, so it's natural for symmetry to arise. Exploiting vertical symmetry makes less of a difference. On Tue, Apr 12, 2022 at 3:02 AM <roald.baudoux@brutele.be> wrote: > > In the definition of R two multiplications were missing. > > let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages > +(pauw(sin(j*f2+phase2),0.5)0.5+0.5)depth2(1-i/stages))) > > should be: > > let(R=(rad+a+(pauw(sin(j *f1+phase1),0.5)*0.5+0.5)*depth1*i/stages > +(pauw(sin(j*f2+phase2),0.5)*0.5+0.5)*depth2(1-i/stages))) > > I suppose there's also something missing in: > > R[sin(j),cos(j)] > > because it triggers an error message. But what? > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
RB
roald.baudoux@brutele.be
Tue, Apr 12, 2022 11:27 AM

Thank you Adrian!

Thank you Adrian!