Here's the result of what I was trying to do. It's close, but not quite
there, I think.
I cheated by taking the coordinates from the output of the echo command, and
pasting them into the second and third board translate()s. I did this
because I am not sure how to extract the pertinent coordinates from the
path.
If you use "!" on the stroke command, you can see the path I made.
include<BOSL2/std.scad>
$fn = 120;
angle1 = 35;
angle2 = 35;
path = turtle(
[ // first board
"left",90,
"move", 3,
"right",90,
"move",30,
"right",90+angle1,
"move",3,
"right",180,
"move",3,
//second board
"right",90,
"move",30,
"right",90+angle2,
"move",3,
]);
union() {
board();
translate([28.2793, 0.542544,0 ])
rotate([0,0,-angle1])
board();
translate([51.7555, -15.2334,0 ])
rotate([0,0,-(angle1+angle2)])
board();
}
module board() {
cube([30,3,2]);
}
stroke(path,width=.1);
echo (path);
--
Sent from: http://forum.openscad.org/
If you want the full state info from turtle() pass full_state=true to it. I
don't understand the remaining difficulty with your approach. Isn't it just
union() {
board();
translate(path[3])
rotate([0,0,-angle1])
board();
translate(path[6])
rotate([0,0,-(angle1+angle2)])
board();
}
One observation is that you are working inward instead of outward. I
understood the problem to be fitting the rectangles onto a known surface,
which is more difficult than the problem you've solved.
Here's a different way to do what you did in BOSL2 that to me is a little
more intuitive:
cube([30,3,2])
position(RIGHT+BACK) cuboid([30,3,2], anchor=LEFT+BACK, spin=-angle1)
position(RIGHT+BACK) cuboid([30,3,2], anchor=LEFT+BACK, spin=-angle1);
This code explicitly positions the cube corners on each other and applies
the desired rotation angle.
lar3ry wrote
Here's the result of what I was trying to do. It's close, but not quite
there, I think.
I cheated by taking the coordinates from the output of the echo command,
and
pasting them into the second and third board translate()s. I did this
because I am not sure how to extract the pertinent coordinates from the
path.
If you use "!" on the stroke command, you can see the path I made.
include<BOSL2/std.scad>
$fn = 120;
angle1 = 35;
angle2 = 35;
path = turtle(
[ // first board
"left",90,
"move", 3,
"right",90,
"move",30,
"right",90+angle1,
"move",3,
"right",180,
"move",3,
//second board
"right",90,
"move",30,
"right",90+angle2,
"move",3,
]);
union() {
board();
translate([28.2793, 0.542544,0 ])
rotate([0,0,-angle1])
board();
translate([51.7555, -15.2334,0 ])
rotate([0,0,-(angle1+angle2)])
board();
}
module board() {
cube([30,3,2]);
}
stroke(path,width=.1);
echo (path);
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@.openscad
--
Sent from: http://forum.openscad.org/
On 3/14/2020 10:34 PM, lar3ry wrote:
Use the turtle to draw a partial outline of a board, starting from
0/0, the upper left corner of the board. I would draw it clockwise,
but instead of finishing up back at the origin, I would only make the
first two moves, the second of which would be at an angle of <90 +
next board angle> degrees. At this time the last two positions of the
path would contain the point at which I want to join the next board
and the point at which I would position the lower left point of the
next board.
I had a similar problem, laying out walls for my house.
Here's the function I used:
function polaradd(origin, dir, length) =
[origin[0] + cos(dir)*length, origin[1] + sin(dir)*length];
Given an original location in Cartesian coordinates and an offset in
polar coordinates (angle and length), returns the new Cartesian location.
Looking at that function again, it could be slightly simplified by using
matrix arithmetic:
function polaradd(origin, dir, length) =
origin + length * [ cos(dir), sin(dir) ];
Actually, I used this one:
function vector(origin, dir, length) = polaradd(origin, 360-dir, length);
because I wanted to work in compass directions, and they're
left-hand-rule. (It didn't matter which axis North aligned with. I
don't think I ever thought about it. +X, it seems. Once I had a start
point I just turtled around.)
adrianv wrote
If you want the full state info from turtle() pass full_state=true to it.
I
don't understand the remaining difficulty with your approach. Isn't it
just
union() {
board();
translate(path[3])
rotate([0,0,-angle1])
board();
translate(path[6])
rotate([0,0,-(angle1+angle2)])
board();
}
Of course. That's what I did, but as I said, I cut and pasted the
translation coordinates from the echo() output because I did not know how to
extract them from the path.
One observation is that you are working inward instead of outward. I
understood the problem to be fitting the rectangles onto a known surface,
which is more difficult than the problem you've solved.
Well, he did not specify anything except that he needed to fitgith it, and I
only assumed that he knew the shape of what he wanted to enclose. I wasn't
actually solving his problem specifically, only trying to explore a method
of doing it.
Here's a different way to do what you did in BOSL2 that to me is a little
more intuitive:
cube([30,3,2])
position(RIGHT+BACK) cuboid([30,3,2], anchor=LEFT+BACK, spin=-angle1)
position(RIGHT+BACK) cuboid([30,3,2], anchor=LEFT+BACK, spin=-angle1);
This code explicitly positions the cube corners on each other and applies
the desired rotation angle.
Yes, that works VERY well.
I have yet to explore much of BOSL2. It's got a lot in it, and I am trying
to get a good idea of what's available in it.
I appreciate your work and the help.
--
Sent from: http://forum.openscad.org/
Not the fastest way to do it, but fairly simple:
Instead of making full blocks, just makes thin end pieces where they meet,
then hull() them two at the time (first do segment 1 & 2, then 2 & 3 and so
on), then union all of it.
--
Sent from: http://forum.openscad.org/