discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Is there a better way this could have been done?

JD
Jerry Davis
Wed, Nov 2, 2016 11:15 PM

I have the following snippet.

$fn = 100;

legs() thing();

module legs()
{
for (i = [0:2])
{
if (i == 0)
translate([sin(360*i/3)18, cos(360i/3)18, 0 ])
rotate([27.5,0,0]) children();
if (i == 1)
translate([sin(360
i/3)18, cos(360i/3)18, 0 ])
rotate([-27.5,-27.5,0]) children();
if (i == 2)
translate([sin(360
i/3)18, cos(360i/3)*18, 0 ])
rotate([-27.5,27.5,0]) children();

}
}

module thing()
{
cylinder(d=4, h=20, center=true);
translate([0,0,-10]) sphere(r=3);
}

Other than filling a 3 element array of vectors of the rotate arguments.
Is there a better way to do what I wanted done?

Jerry

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

I have the following snippet. $fn = 100; legs() thing(); module legs() { for (i = [0:2]) { if (i == 0) translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) rotate([27.5,0,0]) children(); if (i == 1) translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) rotate([-27.5,-27.5,0]) children(); if (i == 2) translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) rotate([-27.5,27.5,0]) children(); } } module thing() { cylinder(d=4, h=20, center=true); translate([0,0,-10]) sphere(r=3); } Other than filling a 3 element array of vectors of the rotate arguments. Is there a better way to do what I wanted done? Jerry -- Extra Ham Operator: K7AZJ Registered Linux User: 275424 Raspberry Pi and Openscad developer *The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov
NH
nop head
Wed, Nov 2, 2016 11:49 PM

I think this does the same:

module legs()
{
for (i = [0:2])
rotate([0, 0, 360 * i / 3])
translate([0, 18, 0])
rotate([27.5, 0, 0])
children();
}

I.e. just place the first leg and then rotate it to three positions.

On 2 November 2016 at 23:15, Jerry Davis jdawgaz@gmail.com wrote:

I have the following snippet.

$fn = 100;

legs() thing();

module legs()
{
for (i = [0:2])
{
if (i == 0)
translate([sin(360*i/3)18, cos(360i/3)18, 0 ])
rotate([27.5,0,0]) children();
if (i == 1)
translate([sin(360
i/3)18, cos(360i/3)18, 0 ])
rotate([-27.5,-27.5,0]) children();
if (i == 2)
translate([sin(360
i/3)18, cos(360i/3)*18, 0 ])
rotate([-27.5,27.5,0]) children();

}
}

module thing()
{
cylinder(d=4, h=20, center=true);
translate([0,0,-10]) sphere(r=3);
}

Other than filling a 3 element array of vectors of the rotate arguments.
Is there a better way to do what I wanted done?

Jerry

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I think this does the same: module legs() { for (i = [0:2]) rotate([0, 0, 360 * i / 3]) translate([0, 18, 0]) rotate([27.5, 0, 0]) children(); } I.e. just place the first leg and then rotate it to three positions. On 2 November 2016 at 23:15, Jerry Davis <jdawgaz@gmail.com> wrote: > I have the following snippet. > > $fn = 100; > > legs() thing(); > > module legs() > { > for (i = [0:2]) > { > if (i == 0) > translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) > rotate([27.5,0,0]) children(); > if (i == 1) > translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) > rotate([-27.5,-27.5,0]) children(); > if (i == 2) > translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) > rotate([-27.5,27.5,0]) children(); > > } > } > > module thing() > { > cylinder(d=4, h=20, center=true); > translate([0,0,-10]) sphere(r=3); > } > > > Other than filling a 3 element array of vectors of the rotate arguments. > Is there a better way to do what I wanted done? > > Jerry > > > -- > Extra Ham Operator: K7AZJ > Registered Linux User: 275424 > Raspberry Pi and Openscad developer > > > *The most exciting phrase to hear in science - the one that heralds new > discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
RP
Ronaldo Persiano
Wed, Nov 2, 2016 11:55 PM

Or if you want it parametric:

legs([0,18,0],[27.5,0]) thing();

module legs(p, rot)
{
for (i = [0:120:240])  rotate(i) translate(p) rotate(rot) children();
}

Or if you want it parametric: legs([0,18,0],[27.5,0]) thing(); module legs(p, rot) { for (i = [0:120:240]) rotate(i) translate(p) rotate(rot) children(); }
MH
Martin Herdieckerhoff
Thu, Nov 3, 2016 12:10 AM

Jerry, you could reduce the for-loop to this:

for (i = [0:2])
rotate([0, 0, i*120])
translate([0, 18, 0 ])
rotate([27.5, 0, 0])
children();

Martin

Am 03.11.2016 um 00:15 schrieb Jerry Davis:

I have the following snippet.

$fn = 100;

legs() thing();

module legs()
{
for (i = [0:2])
{
if (i == 0)
translate([sin(360*i/3)18, cos(360i/3)18, 0 ])
rotate([27.5,0,0]) children();
if (i == 1)
translate([sin(360
i/3)18, cos(360i/3)18, 0 ])
rotate([-27.5,-27.5,0]) children();
if (i == 2)
translate([sin(360
i/3)18, cos(360i/3)*18, 0 ])
rotate([-27.5,27.5,0]) children();
}
}

module thing()
{
cylinder(d=4, h=20, center=true);
translate([0,0,-10]) sphere(r=3);
}

Other than filling a 3 element array of vectors of the rotate arguments.
Is there a better way to do what I wanted done?

Jerry

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

/The most exciting phrase to hear in science - the one that heralds
new discoveries - is not "Eureka!" but "That's funny...".
/- Isaac. Asimov


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

**

Jerry, you could reduce the for-loop to this: for (i = [0:2]) rotate([0, 0, i*120]) translate([0, 18, 0 ]) rotate([27.5, 0, 0]) children(); Martin Am 03.11.2016 um 00:15 schrieb Jerry Davis: > I have the following snippet. > > $fn = 100; > > legs() thing(); > > module legs() > { > for (i = [0:2]) > { > if (i == 0) > translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) > rotate([27.5,0,0]) children(); > if (i == 1) > translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) > rotate([-27.5,-27.5,0]) children(); > if (i == 2) > translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) > rotate([-27.5,27.5,0]) children(); > } > } > > module thing() > { > cylinder(d=4, h=20, center=true); > translate([0,0,-10]) sphere(r=3); > } > > > Other than filling a 3 element array of vectors of the rotate arguments. > Is there a better way to do what I wanted done? > > Jerry > > > -- > Extra Ham Operator: K7AZJ > Registered Linux User: 275424 > Raspberry Pi and Openscad developer > > /The most exciting phrase to hear in science - the one that heralds > new discoveries - is not "Eureka!" but "That's funny...". > /- Isaac. Asimov > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org * * **
JD
Jerry Davis
Thu, Nov 3, 2016 1:01 AM

great. thanks for pointing me in the right direction.

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

On Wed, Nov 2, 2016 at 5:10 PM, Martin Herdieckerhoff <
Martin.Herdieckerhoff@mnet-mail.de> wrote:

Jerry, you could reduce the for-loop to this:

for (i = [0:2])
rotate([0, 0, i*120])
translate([0, 18, 0 ])
rotate([27.5, 0, 0])
children();

Martin

Am 03.11.2016 um 00:15 schrieb Jerry Davis:

I have the following snippet.

$fn = 100;

legs() thing();

module legs()
{
for (i = [0:2])
{
if (i == 0)
translate([sin(360*i/3)18, cos(360i/3)18, 0 ])
rotate([27.5,0,0]) children();
if (i == 1)
translate([sin(360
i/3)18, cos(360i/3)18, 0 ])
rotate([-27.5,-27.5,0]) children();
if (i == 2)
translate([sin(360
i/3)18, cos(360i/3)*18, 0 ])
rotate([-27.5,27.5,0]) children();

}
}

module thing()
{
cylinder(d=4, h=20, center=true);
translate([0,0,-10]) sphere(r=3);
}

Other than filling a 3 element array of vectors of the rotate arguments.
Is there a better way to do what I wanted done?

Jerry

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

*The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...". *- Isaac. Asimov


OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

great. thanks for pointing me in the right direction. -- Extra Ham Operator: K7AZJ Registered Linux User: 275424 Raspberry Pi and Openscad developer *The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov On Wed, Nov 2, 2016 at 5:10 PM, Martin Herdieckerhoff < Martin.Herdieckerhoff@mnet-mail.de> wrote: > Jerry, you could reduce the for-loop to this: > > for (i = [0:2]) > rotate([0, 0, i*120]) > translate([0, 18, 0 ]) > rotate([27.5, 0, 0]) > children(); > > Martin > > > > Am 03.11.2016 um 00:15 schrieb Jerry Davis: > > I have the following snippet. > > $fn = 100; > > legs() thing(); > > module legs() > { > for (i = [0:2]) > { > if (i == 0) > translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) > rotate([27.5,0,0]) children(); > if (i == 1) > translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) > rotate([-27.5,-27.5,0]) children(); > if (i == 2) > translate([sin(360*i/3)*18, cos(360*i/3)*18, 0 ]) > rotate([-27.5,27.5,0]) children(); > > } > } > > module thing() > { > cylinder(d=4, h=20, center=true); > translate([0,0,-10]) sphere(r=3); > } > > > Other than filling a 3 element array of vectors of the rotate arguments. > Is there a better way to do what I wanted done? > > Jerry > > > -- > Extra Ham Operator: K7AZJ > Registered Linux User: 275424 > Raspberry Pi and Openscad developer > > > *The most exciting phrase to hear in science - the one that heralds new > discoveries - is not "Eureka!" but "That's funny...". *- Isaac. Asimov > > > _______________________________________________ > OpenSCAD mailing listDiscuss@lists.openscad.orghttp://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >