I tried to make a list of 3D locations (x, y, z) and then reference them
in a loop. Clearly, I do not understand how to reference the elements
of a list.
sd = 0.5; // sphere diameter
num = 10; // number of x/y/z triplets
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (i = [0:num-1])
translate([locs[i, 0], locs[i, 1], locs[i, 2]]) // <===== error here
sphere(d = sd);
This is the first time I've experienced a list of vectors, but a little bit of fumbling around appears to make it work:
for (i = [0:num-1])
translate(locs[i])
sphere(d = sd);
On Monday, February 27, 2023 at 04:24:29 PM EST, jon <jon@jonbondy.com> wrote:
I tried to make a list of 3D locations (x, y, z) and then reference them
in a loop. Clearly, I do not understand how to reference the elements
of a list.
sd = 0.5; // sphere diameter
num = 10; // number of x/y/z triplets
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (i = [0:num-1])
translate([locs[i, 0], locs[i, 1], locs[i, 2]]) // <===== error here
sphere(d = sd);
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Finally, something I might be able to help with:
locs[i] would be a reference to the relative vector. So use this:
sd = 0.5; // sphere diameter
num = 10; // number of x/y/z triplets
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (i = [0:1:len(locs)-1])
translate(locs[i])
sphere(d = sd);
On Mon, Feb 27, 2023 at 4:23 PM jon jon@jonbondy.com wrote:
I tried to make a list of 3D locations (x, y, z) and then reference them
in a loop. Clearly, I do not understand how to reference the elements
of a list.
sd = 0.5; // sphere diameter
num = 10; // number of x/y/z triplets
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (i = [0:num-1])
translate([locs[i, 0], locs[i, 1], locs[i, 2]]) // <===== error
here
sphere(d = sd);
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Thanks, Fred and Kevin! Obvious once I saw it!
Jon
On 2/27/2023 4:47 PM, Kevin Toppenberg wrote:
Finally, something I might be able to help with:
locs[i] would be a reference to the relative vector. So use this:
sd = 0.5; // sphere diameter
num = 10; // number of x/y/z triplets
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (i = [0:1:len(locs)-1])
translate(locs[i])
sphere(d = sd);
On Mon, Feb 27, 2023 at 4:23 PM jon jon@jonbondy.com wrote:
I tried to make a list of 3D locations (x, y, z) and then
reference them
in a loop. Clearly, I do not understand how to reference the
elements
of a list.
sd = 0.5; // sphere diameter
num = 10; // number of x/y/z triplets
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (i = [0:num-1])
translate([locs[i, 0], locs[i, 1], locs[i, 2]]) // <=====
error here
sphere(d = sd);
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
Or, more simply:
sd = 0.5; // sphere diameter
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (pos = locs)
translate(pos)
sphere(d = sd);
On Mon, 27 Feb 2023 at 21:50, jon jon@jonbondy.com wrote:
Thanks, Fred and Kevin! Obvious once I saw it!
Jon
On 2/27/2023 4:47 PM, Kevin Toppenberg wrote:
Finally, something I might be able to help with:
locs[i] would be a reference to the relative vector. So use this:
sd = 0.5; // sphere diameter
num = 10; // number of x/y/z triplets
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (i = [0:1:len(locs)-1])
translate(locs[i])
sphere(d = sd);
On Mon, Feb 27, 2023 at 4:23 PM jon jon@jonbondy.com wrote:
I tried to make a list of 3D locations (x, y, z) and then reference them
in a loop. Clearly, I do not understand how to reference the elements
of a list.
sd = 0.5; // sphere diameter
num = 10; // number of x/y/z triplets
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (i = [0:num-1])
translate([locs[i, 0], locs[i, 1], locs[i, 2]]) // <===== error
here
sphere(d = sd);
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
nop head:
Thanks! Even better!
On 2/27/2023 5:35 PM, nop head wrote:
Or, more simply:
sd = 0.5; // sphere diameter
locs = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
[7, 8, 9],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5],
[6, 6, 6]
];
for (pos = locs)
translate(pos)
sphere(d = sd);