M
MichaelAtOz
Fri, Mar 25, 2016 1:41 AM
I am trying to modulate an object by not changing it's suface so I
designed a code for it to be sliced and the slices be rearranged after a
custom equation. The problem I have is that if the object is not flat and
has holes that need to be preserved, hull does not help much. As a test,
we place two objects and use the code, the two join. Of course, in a
simplified case, I can cut the object and create a module out of every
cut, but is there a way to automize this for, let's say, 100 modules?
module test() {
cube([200,10,2]);
translate([0,12,0])
cube([200,10,2]);
}
//variables for cut points
ca1=-8.89;
ca2=-8.9;
cb1=-9.89;
cb2=-9.9;
//variables for equation
a=110;
b=125;
c=-250;
//variables for y cut points
yca1=-8.89;
yca2=-8.9;
ycb1=-9.89;
ycb2=-9.9;
//variables for y equation
ya=110;
yb=125;
yc=-250;
module x2() {
for (z = [1:50])
hull() {
translate([0,0,log(z+a)*b+c])
{
difference() {
test();
translate([z+ca1,-10,-1]) cube([300,200,200]);
translate([ca2-300+z,-100,-1]) cube([300,200,200]);
}
}
translate([0,0,log(z+a-1)*b+c])
{
difference() {
test();
translate([z+cb1,-10,-1]) cube([300,200,200]);
translate([-300+cb2+z,-100,-1]) cube([300,200,200]);
}
}
}
}
x2();
bump, as it didn't make it to the mailing list.
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16717.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
rav0r wrote
> I am trying to modulate an object by not changing it's suface so I
> designed a code for it to be sliced and the slices be rearranged after a
> custom equation. The problem I have is that if the object is not flat and
> has holes that need to be preserved, hull does not help much. As a test,
> we place two objects and use the code, the two join. Of course, in a
> simplified case, I can cut the object and create a module out of every
> cut, but is there a way to automize this for, let's say, 100 modules?
>
>
>
> module test() {
> cube([200,10,2]);
> translate([0,12,0])
> cube([200,10,2]);
> }
>
>
>
> //variables for cut points
> ca1=-8.89;
> ca2=-8.9;
> cb1=-9.89;
> cb2=-9.9;
>
> //variables for equation
> a=110;
> b=125;
> c=-250;
>
>
> //variables for y cut points
> yca1=-8.89;
> yca2=-8.9;
> ycb1=-9.89;
> ycb2=-9.9;
>
> //variables for y equation
> ya=110;
> yb=125;
> yc=-250;
>
> module x2() {
>
> for (z = [1:50])
> hull() {
> translate([0,0,log(z+a)*b+c])
>
> {
>
> difference() {
> test();
> translate([z+ca1,-10,-1]) cube([300,200,200]);
>
> translate([ca2-300+z,-100,-1]) cube([300,200,200]);
> }
> }
>
>
> translate([0,0,log(z+a-1)*b+c])
>
> {
> difference() {
> test();
> translate([z+cb1,-10,-1]) cube([300,200,200]);
>
> translate([-300+cb2+z,-100,-1]) cube([300,200,200]);
> }
> }
>
> }
> }
>
>
> x2();
bump, as it didn't make it to the mailing list.
-----
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16717.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
A
arnholm@arnholm.org
Fri, Mar 25, 2016 7:37 AM
On 2016-03-25 02:41, MichaelAtOz wrote:
I am trying to modulate an object by not changing it's suface so I
designed a code for it to be sliced and the slices be rearranged after
a
custom equation. The problem I have is that if the object is not flat
and
has holes that need to be preserved, hull does not help much. As a
test,
we place two objects and use the code, the two join. Of course, in a
simplified case, I can cut the object and create a module out of every
cut, but is there a way to automize this for, let's say, 100 modules?
You could perhaps slice the model by means of many intersection()'s with
a thin+wide cube(), stacked on top of each other. This could be in z,y,z
or some other direction. Then reassemble by modulating the slices as
preferred and scale up the slice thickness slightly. Finally union() the
modulated slices.
This should preserve holes and surface shapes. Not sure if it will work
in practice, but you could try.
Carsten Arnholm
On 2016-03-25 02:41, MichaelAtOz wrote:
> rav0r wrote
>> I am trying to modulate an object by not changing it's suface so I
>> designed a code for it to be sliced and the slices be rearranged after
>> a
>> custom equation. The problem I have is that if the object is not flat
>> and
>> has holes that need to be preserved, hull does not help much. As a
>> test,
>> we place two objects and use the code, the two join. Of course, in a
>> simplified case, I can cut the object and create a module out of every
>> cut, but is there a way to automize this for, let's say, 100 modules?
You could perhaps slice the model by means of many intersection()'s with
a thin+wide cube(), stacked on top of each other. This could be in z,y,z
or some other direction. Then reassemble by modulating the slices as
preferred and scale up the slice thickness slightly. Finally union() the
modulated slices.
This should preserve holes and surface shapes. Not sure if it will work
in practice, but you could try.
Carsten Arnholm
R
Ronaldo
Fri, Mar 25, 2016 1:38 PM
Do you mean something like that:
module test2() {
translate([100,0,0])
difference(){
cylinder(r=100,h=10,center=true);
cylinder(r=50,h=12,center=true);
}
}
module slice(x,d) {
intersection(){
children();
translate([x,0,0])
cube([d,1000,1000],center=true);
}
}
function shear_transf(x1,x2,d) = let( r=d/(x2-x1) )
[ [1,0,0,0], [0,1,0,0], [r,0,1,-r*x1], [0,0,0,1] ];
module shear(x1,x2,d) {
multmatrix(shear_transf(x1,x2,d)) children();
}
function f(x,a,b,c) = axx+b*x+c;
module modulate(a,b,c,x1,x2,d){
for(x=[x1:d:x2]) {
translate([0,0,f(x,a,b,c)])
shear(x,x+d,f(x+d,a,b,c)-f(x,a,b,c)) slice(x,d) children();
}
}
modulate(-0.01, 1.5, 10, 0, 200, 2) test2();
translate([0,0,-200]) test2();
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16722.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Do you mean something like that:
module test2() {
translate([100,0,0])
difference(){
cylinder(r=100,h=10,center=true);
cylinder(r=50,h=12,center=true);
}
}
module slice(x,d) {
intersection(){
children();
translate([x,0,0])
cube([d,1000,1000],center=true);
}
}
function shear_transf(x1,x2,d) = let( r=d/(x2-x1) )
[ [1,0,0,0], [0,1,0,0], [r,0,1,-r*x1], [0,0,0,1] ];
module shear(x1,x2,d) {
multmatrix(shear_transf(x1,x2,d)) children();
}
function f(x,a,b,c) = a*x*x+b*x+c;
module modulate(a,b,c,x1,x2,d){
for(x=[x1:d:x2]) {
translate([0,0,f(x,a,b,c)])
shear(x,x+d,f(x+d,a,b,c)-f(x,a,b,c)) slice(x,d) children();
}
}
modulate(-0.01, 1.5, 10, 0, 200, 2) test2();
translate([0,0,-200]) test2();
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16722.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
J
jon
Fri, Mar 25, 2016 1:44 PM
I love it!
Jon
On 3/25/2016 9:38 AM, Ronaldo wrote:
module test2() {
translate([100,0,0])
difference(){
cylinder(r=100,h=10,center=true);
cylinder(r=50,h=12,center=true);
}
}
module slice(x,d) {
intersection(){
children();
translate([x,0,0])
cube([d,1000,1000],center=true);
}
}
function shear_transf(x1,x2,d) = let( r=d/(x2-x1) )
[ [1,0,0,0], [0,1,0,0], [r,0,1,-r*x1], [0,0,0,1] ];
module shear(x1,x2,d) {
multmatrix(shear_transf(x1,x2,d)) children();
}
function f(x,a,b,c) = axx+b*x+c;
module modulate(a,b,c,x1,x2,d){
for(x=[x1:d:x2]) {
translate([0,0,f(x,a,b,c)])
shear(x,x+d,f(x+d,a,b,c)-f(x,a,b,c)) slice(x,d) children();
}
}
modulate(-0.01, 1.5, 10, 0, 200, 2) test2();
translate([0,0,-200]) test2();
I love it!
Jon
On 3/25/2016 9:38 AM, Ronaldo wrote:
> module test2() {
> translate([100,0,0])
> difference(){
> cylinder(r=100,h=10,center=true);
> cylinder(r=50,h=12,center=true);
> }
> }
>
> module slice(x,d) {
> intersection(){
> children();
> translate([x,0,0])
> cube([d,1000,1000],center=true);
> }
> }
>
> function shear_transf(x1,x2,d) = let( r=d/(x2-x1) )
> [ [1,0,0,0], [0,1,0,0], [r,0,1,-r*x1], [0,0,0,1] ];
>
> module shear(x1,x2,d) {
> multmatrix(shear_transf(x1,x2,d)) children();
> }
>
> function f(x,a,b,c) = a*x*x+b*x+c;
>
> module modulate(a,b,c,x1,x2,d){
> for(x=[x1:d:x2]) {
> translate([0,0,f(x,a,b,c)])
> shear(x,x+d,f(x+d,a,b,c)-f(x,a,b,c)) slice(x,d) children();
> }
> }
>
> modulate(-0.01, 1.5, 10, 0, 200, 2) test2();
> translate([0,0,-200]) test2();
>
R
runsun
Fri, Mar 25, 2016 3:48 PM
@ Ronaldo: Very good example usage of multmatrix. Thx for sharing.
$ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py( 1 , 2 , git ), synwrite( 1 , 2 ); $ tips: hash( 1 , 2 ), sweep( 1 , 2 ), var( 1 , 2 ), lerp , animGif , prodVid , precision( 1 , 2 ), xl-control , type , rounded polygon
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16724.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
@ Ronaldo: Very good example usage of multmatrix. Thx for sharing.
-----
$ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py( 1 , 2 , git ), synwrite( 1 , 2 ); $ tips: hash( 1 , 2 ), sweep( 1 , 2 ), var( 1 , 2 ), lerp , animGif , prodVid , precision( 1 , 2 ), xl-control , type , rounded polygon
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16724.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
R
Ronaldo
Fri, Mar 25, 2016 7:57 PM
There was a mistake in the definition of module modulate. The correct one
would be:
module modulate(a,b,c,x1,x2,dx){
for(x=[x1:dx:x2]) {
translate([0,0,f(x+dx/2,a,b,c)])
shear(x,x+dx,f(x+dx,a,b,c)-f(x,a,b,c)) slice(x,dx) children();
}
}
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16725.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
There was a mistake in the definition of module modulate. The correct one
would be:
module modulate(a,b,c,x1,x2,dx){
for(x=[x1:dx:x2]) {
translate([0,0,f(x+dx/2,a,b,c)])
shear(x,x+dx,f(x+dx,a,b,c)-f(x,a,b,c)) slice(x,dx) children();
}
}
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16725.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
R
rav0r
Mon, Apr 4, 2016 8:09 PM
It did work, I came up with this idea, but it takes days to render. Will try
out the other versions.
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16964.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
It did work, I came up with this idea, but it takes days to render. Will try
out the other versions.
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16964.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Mon, Apr 4, 2016 9:45 PM
All depends on the complexity of your starting model and the slice width.
If you could share your model we could suggest other alternatives. For
instance, if your model has only vertical throughout holes, you would get a
little time gain doing the differences after modulation. Anyway, please
share your final solution. I am interested in it.
2016-04-04 17:09 GMT-03:00 rav0r coltoiu.matei@gmail.com:
All depends on the complexity of your starting model and the slice width.
If you could share your model we could suggest other alternatives. For
instance, if your model has only vertical throughout holes, you would get a
little time gain doing the differences after modulation. Anyway, please
share your final solution. I am interested in it.
2016-04-04 17:09 GMT-03:00 rav0r <coltoiu.matei@gmail.com>:
> It did work, I came up with this idea, but it takes days to render. Will
> try
> out the other versions.
>
>
>
> --
> View this message in context:
> http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16964.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
>
R
rav0r
Wed, Apr 6, 2016 4:37 PM
It's a frame with a grid, about 250mm long, 80 mm wide and 5 bars
(longtitudinal) plus 3 cross bars. Openscad is the only application that can
work without issues in regard to "full" stl's, not only facets.
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16984.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
It's a frame with a grid, about 250mm long, 80 mm wide and 5 bars
(longtitudinal) plus 3 cross bars. Openscad is the only application that can
work without issues in regard to "full" stl's, not only facets.
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16984.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
R
Ronaldo
Wed, Apr 6, 2016 4:50 PM
I would take a very different approach for your problem. I would "modulate"
the center lines of each bar, sweep each with the bar section and union
everything. A sweep module may be found in:
https://github.com/openscad/list-comprehension-demos
https://github.com/openscad/list-comprehension-demos
Take the sweep-path.scad as an example. And ask for help if you need.
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16985.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I would take a very different approach for your problem. I would "modulate"
the center lines of each bar, sweep each with the bar section and union
everything. A sweep module may be found in:
https://github.com/openscad/list-comprehension-demos
<https://github.com/openscad/list-comprehension-demos>
Take the sweep-path.scad as an example. And ask for help if you need.
--
View this message in context: http://forum.openscad.org/restrict-hull-function-to-one-or-two-dimensions-tp16696p16985.html
Sent from the OpenSCAD mailing list archive at Nabble.com.