discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

How can I connect these two pieces?

FH
Father Horton
Sat, Mar 8, 2025 4:14 PM

BOSL2’s turtle is my tool of choice for any time I need a path of connected
lines and arcs. It’s much easier than math.

On Sat, Mar 8, 2025 at 8:06 AM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

I had the impression that the poster wanted the math, not an answer....but
BOSL2's turtle command also has lines and arcs in one command.  You can
pass the result to path_sweep with the profile of your choice.

include<BOSL2/std.scad>
r=15;
stem=25;
angle=45;
path = turtle(["right", 90,
"arcright", r, 180+angle,
"untilx", 0,
"left", angle,
//              "arcleft", 9, angle,
"move", stem], [r,0]);
stroke(path,width=2);

It's easy to eliminate the sharp corner, though it does misalign the stem
with the center of the hook circle.

[image: image.png]
[image: image.png]

On Sat, Mar 8, 2025 at 8:40 AM Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:

Pythonscad path Extrude would be best Match. It has Lines and arcs in one
command and you can even define the Cross section.

Raymond West via Discuss discuss@lists.openscad.org schrieb am Sa., 8.
März 2025, 14:34:

I've ignored what has gone before, and have this, pretty well
parametric. Wrt a practical hook, then this design fails, it is merely an
example of stringing together a list of points to get a solid shape, with
some variation.

// Function to generate points on a circle's circumference
function pointcircle(d, a1, a2, s) = let(
radius = d / 2,
// Calculate the angular step and handle direction
angle_diff = (a2 - a1 + (a2 >= a1 ? 0 : 360)),
num_points = ceil(abs(angle_diff) / (360 / s))
) [for (i = [0 : num_points - 1])
let(angle = a1 + i * angle_diff / (num_points - 1))
[radius * cos(angle), radius * sin(angle), 0]
];

module pointshull(list){
for(k=[0:1:len(list)-2]){
hull(){
translate(list[k])sphere(w/2);
translate(list[k+1])sphere(w/2);
}
}
}

module shape(){
round=pointcircle(diam,sa,ea,res);
straight= [[0,es],[0,ss]];
all= concat(straight,round);
pointshull(all);
}

shape();

diam = 50;  // diam of 'hook'
sa = 135;  // start angle
ea = 0;    // end angle
res = 200;  // resolution for circle
ss = 35;    // start of straight
w = 8;      // diameter of 'wire'

es = ss+40; // end of straight
$fn = res/8;// smaller = quicker

If you want a square cross section, so you can easily fdm print, then do
it as 2d, and linear extrude. Using a $fn=4 or similar distorts the cross
section around the curve, since 'the cube' does not rotate as it follows
the path, so to speak.

On 07/03/2025 21:03, Raymond West via Discuss wrote:

Probably best to work with points, and generate the polygon for the mid
section. You know the rh point at bottom of top piece ((3/2, 18.25) you can
use trig  (sin & cos) to get the inner point of the 45 degree cut. You can
calculate the length of the middle section, (Pythagoras?) and the width
will be 3. You can generate the four points for the middle rectangle (or a
square based on the calculated length and 3) and calculate its position. (
you have already found the two points needed. (atan2 and translate). You do
not need the lh, bottom point of the upper piece, (-3/2,18.25) since if you
use that you will get a tapered middle section, unless you do another
calculation to get one of the corners of the middle piece.

You could write a generic script, where you enter the width and radius
and length of straight section, and produce the shape in whatever size you
want, merely by adjusting those three values. (or set the width and length
as a function of the radius, and then you only need to enter the radius)
On 07/03/2025 20:06, Mark Harrison via Discuss wrote:

Here is a hook with a lower curved part and an upper straight part.  How
can I calculate the proper dimension/position of the middle connecting
part?  In this sample I visually positioned it by trial and error, but I
would like to learn how to calculate this.

Pure SCAD, or a pointer to other code that might solve the geometry
appreciated.  I am as interested in learning the general solution/principle
as I am in the practical solution to the problem.

// looped lower portion of hook
difference() {
circle(d=30);
circle(d=24);
square(30);
rotate(45) square(30);
}
// visually drawn mid-portion of hook
#rotate(45) translate([0,12]) square([14,3]);
// straight upper portion of hook
translate([-3/2,18.25]) square([3,16]);

[image: image.png]

--
Mark Harrison
marhar@gmail.com


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


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

BOSL2’s turtle is my tool of choice for any time I need a path of connected lines and arcs. It’s much easier than math. On Sat, Mar 8, 2025 at 8:06 AM Adrian Mariano via Discuss < discuss@lists.openscad.org> wrote: > I had the impression that the poster wanted the math, not an answer....but > BOSL2's turtle command also has lines and arcs in one command. You can > pass the result to path_sweep with the profile of your choice. > > include<BOSL2/std.scad> > r=15; > stem=25; > angle=45; > path = turtle(["right", 90, > "arcright", r, 180+angle, > "untilx", 0, > "left", angle, > // "arcleft", 9, angle, > "move", stem], [r,0]); > stroke(path,width=2); > > It's easy to eliminate the sharp corner, though it does misalign the stem > with the center of the hook circle. > > [image: image.png] > [image: image.png] > > > On Sat, Mar 8, 2025 at 8:40 AM Guenther Sohler via Discuss < > discuss@lists.openscad.org> wrote: > >> Pythonscad path Extrude would be best Match. It has Lines and arcs in one >> command and you can even define the Cross section. >> >> Raymond West via Discuss <discuss@lists.openscad.org> schrieb am Sa., 8. >> März 2025, 14:34: >> >>> I've ignored what has gone before, and have this, pretty well >>> parametric. Wrt a practical hook, then this design fails, it is merely an >>> example of stringing together a list of points to get a solid shape, with >>> some variation. >>> >>> >>> >>> // Function to generate points on a circle's circumference >>> function pointcircle(d, a1, a2, s) = let( >>> radius = d / 2, >>> // Calculate the angular step and handle direction >>> angle_diff = (a2 - a1 + (a2 >= a1 ? 0 : 360)), >>> num_points = ceil(abs(angle_diff) / (360 / s)) >>> ) [for (i = [0 : num_points - 1]) >>> let(angle = a1 + i * angle_diff / (num_points - 1)) >>> [radius * cos(angle), radius * sin(angle), 0] >>> ]; >>> >>> module pointshull(list){ >>> for(k=[0:1:len(list)-2]){ >>> hull(){ >>> translate(list[k])sphere(w/2); >>> translate(list[k+1])sphere(w/2); >>> } >>> } >>> } >>> >>> module shape(){ >>> round=pointcircle(diam,sa,ea,res); >>> straight= [[0,es],[0,ss]]; >>> all= concat(straight,round); >>> pointshull(all); >>> } >>> >>> shape(); >>> >>> diam = 50; // diam of 'hook' >>> sa = 135; // start angle >>> ea = 0; // end angle >>> res = 200; // resolution for circle >>> ss = 35; // start of straight >>> w = 8; // diameter of 'wire' >>> >>> es = ss+40; // end of straight >>> $fn = res/8;// smaller = quicker >>> >>> >>> >>> If you want a square cross section, so you can easily fdm print, then do >>> it as 2d, and linear extrude. Using a $fn=4 or similar distorts the cross >>> section around the curve, since 'the cube' does not rotate as it follows >>> the path, so to speak. >>> >>> >>> On 07/03/2025 21:03, Raymond West via Discuss wrote: >>> >>> Probably best to work with points, and generate the polygon for the mid >>> section. You know the rh point at bottom of top piece ((3/2, 18.25) you can >>> use trig (sin & cos) to get the inner point of the 45 degree cut. You can >>> calculate the length of the middle section, (Pythagoras?) and the width >>> will be 3. You can generate the four points for the middle rectangle (or a >>> square based on the calculated length and 3) and calculate its position. ( >>> you have already found the two points needed. (atan2 and translate). You do >>> not need the lh, bottom point of the upper piece, (-3/2,18.25) since if you >>> use that you will get a tapered middle section, unless you do another >>> calculation to get one of the corners of the middle piece. >>> >>> You could write a generic script, where you enter the width and radius >>> and length of straight section, and produce the shape in whatever size you >>> want, merely by adjusting those three values. (or set the width and length >>> as a function of the radius, and then you only need to enter the radius) >>> On 07/03/2025 20:06, Mark Harrison via Discuss wrote: >>> >>> Here is a hook with a lower curved part and an upper straight part. How >>> can I calculate the proper dimension/position of the middle connecting >>> part? In this sample I visually positioned it by trial and error, but I >>> would like to learn how to calculate this. >>> >>> Pure SCAD, or a pointer to other code that might solve the geometry >>> appreciated. I am as interested in learning the general solution/principle >>> as I am in the practical solution to the problem. >>> >>> // looped lower portion of hook >>> difference() { >>> circle(d=30); >>> circle(d=24); >>> square(30); >>> rotate(45) square(30); >>> } >>> // visually drawn mid-portion of hook >>> #rotate(45) translate([0,12]) square([14,3]); >>> // straight upper portion of hook >>> translate([-3/2,18.25]) square([3,16]); >>> >>> [image: image.png] >>> >>> -- >>> Mark Harrison >>> marhar@gmail.com >>> >>> _______________________________________________ >>> 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 >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
GS
Guenther Sohler
Sat, Mar 8, 2025 4:19 PM

Does Bosl2 Turtle also Support Moving in 3d Space ?

Am Samstag, 8. März 2025 schrieb Father Horton via Discuss <
discuss@lists.openscad.org>:

BOSL2’s turtle is my tool of choice for any time I need a path of
connected lines and arcs. It’s much easier than math.

On Sat, Mar 8, 2025 at 8:06 AM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

I had the impression that the poster wanted the math, not an
answer....but BOSL2's turtle command also has lines and arcs in one
command.  You can pass the result to path_sweep with the profile of your
choice.

include<BOSL2/std.scad>
r=15;
stem=25;
angle=45;
path = turtle(["right", 90,
"arcright", r, 180+angle,
"untilx", 0,
"left", angle,
//              "arcleft", 9, angle,
"move", stem], [r,0]);
stroke(path,width=2);

It's easy to eliminate the sharp corner, though it does misalign the stem
with the center of the hook circle.

[image: image.png]
[image: image.png]

On Sat, Mar 8, 2025 at 8:40 AM Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:

Pythonscad path Extrude would be best Match. It has Lines and arcs in
one command and you can even define the Cross section.

Raymond West via Discuss discuss@lists.openscad.org schrieb am Sa.,
8. März 2025, 14:34:

I've ignored what has gone before, and have this, pretty well
parametric. Wrt a practical hook, then this design fails, it is merely an
example of stringing together a list of points to get a solid shape, with
some variation.

// Function to generate points on a circle's circumference
function pointcircle(d, a1, a2, s) = let(
radius = d / 2,
// Calculate the angular step and handle direction
angle_diff = (a2 - a1 + (a2 >= a1 ? 0 : 360)),
num_points = ceil(abs(angle_diff) / (360 / s))
) [for (i = [0 : num_points - 1])
let(angle = a1 + i * angle_diff / (num_points - 1))
[radius * cos(angle), radius * sin(angle), 0]
];

module pointshull(list){
for(k=[0:1:len(list)-2]){
hull(){
translate(list[k])sphere(w/2);
translate(list[k+1])sphere(w/2);
}
}
}

module shape(){
round=pointcircle(diam,sa,ea,res);
straight= [[0,es],[0,ss]];
all= concat(straight,round);
pointshull(all);
}

shape();

diam = 50;  // diam of 'hook'
sa = 135;  // start angle
ea = 0;    // end angle
res = 200;  // resolution for circle
ss = 35;    // start of straight
w = 8;      // diameter of 'wire'

es = ss+40; // end of straight
$fn = res/8;// smaller = quicker

If you want a square cross section, so you can easily fdm print, then
do it as 2d, and linear extrude. Using a $fn=4 or similar distorts the
cross section around the curve, since 'the cube' does not rotate as it
follows the path, so to speak.

On 07/03/2025 21:03, Raymond West via Discuss wrote:

Probably best to work with points, and generate the polygon for the mid
section. You know the rh point at bottom of top piece ((3/2, 18.25) you can
use trig  (sin & cos) to get the inner point of the 45 degree cut. You can
calculate the length of the middle section, (Pythagoras?) and the width
will be 3. You can generate the four points for the middle rectangle (or a
square based on the calculated length and 3) and calculate its position. (
you have already found the two points needed. (atan2 and translate). You do
not need the lh, bottom point of the upper piece, (-3/2,18.25) since if you
use that you will get a tapered middle section, unless you do another
calculation to get one of the corners of the middle piece.

You could write a generic script, where you enter the width and radius
and length of straight section, and produce the shape in whatever size you
want, merely by adjusting those three values. (or set the width and length
as a function of the radius, and then you only need to enter the radius)
On 07/03/2025 20:06, Mark Harrison via Discuss wrote:

Here is a hook with a lower curved part and an upper straight part.
How can I calculate the proper dimension/position of the middle connecting
part?  In this sample I visually positioned it by trial and error, but I
would like to learn how to calculate this.

Pure SCAD, or a pointer to other code that might solve the geometry
appreciated.  I am as interested in learning the general solution/principle
as I am in the practical solution to the problem.

// looped lower portion of hook
difference() {
circle(d=30);
circle(d=24);
square(30);
rotate(45) square(30);
}
// visually drawn mid-portion of hook
#rotate(45) translate([0,12]) square([14,3]);
// straight upper portion of hook
translate([-3/2,18.25]) square([3,16]);

[image: image.png]

--
Mark Harrison
marhar@gmail.com


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


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

--
Null

Does Bosl2 Turtle also Support Moving in 3d Space ? Am Samstag, 8. März 2025 schrieb Father Horton via Discuss < discuss@lists.openscad.org>: > BOSL2’s turtle is my tool of choice for any time I need a path of > connected lines and arcs. It’s much easier than math. > > On Sat, Mar 8, 2025 at 8:06 AM Adrian Mariano via Discuss < > discuss@lists.openscad.org> wrote: > >> I had the impression that the poster wanted the math, not an >> answer....but BOSL2's turtle command also has lines and arcs in one >> command. You can pass the result to path_sweep with the profile of your >> choice. >> >> include<BOSL2/std.scad> >> r=15; >> stem=25; >> angle=45; >> path = turtle(["right", 90, >> "arcright", r, 180+angle, >> "untilx", 0, >> "left", angle, >> // "arcleft", 9, angle, >> "move", stem], [r,0]); >> stroke(path,width=2); >> >> It's easy to eliminate the sharp corner, though it does misalign the stem >> with the center of the hook circle. >> >> [image: image.png] >> [image: image.png] >> >> >> On Sat, Mar 8, 2025 at 8:40 AM Guenther Sohler via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> Pythonscad path Extrude would be best Match. It has Lines and arcs in >>> one command and you can even define the Cross section. >>> >>> Raymond West via Discuss <discuss@lists.openscad.org> schrieb am Sa., >>> 8. März 2025, 14:34: >>> >>>> I've ignored what has gone before, and have this, pretty well >>>> parametric. Wrt a practical hook, then this design fails, it is merely an >>>> example of stringing together a list of points to get a solid shape, with >>>> some variation. >>>> >>>> >>>> >>>> // Function to generate points on a circle's circumference >>>> function pointcircle(d, a1, a2, s) = let( >>>> radius = d / 2, >>>> // Calculate the angular step and handle direction >>>> angle_diff = (a2 - a1 + (a2 >= a1 ? 0 : 360)), >>>> num_points = ceil(abs(angle_diff) / (360 / s)) >>>> ) [for (i = [0 : num_points - 1]) >>>> let(angle = a1 + i * angle_diff / (num_points - 1)) >>>> [radius * cos(angle), radius * sin(angle), 0] >>>> ]; >>>> >>>> module pointshull(list){ >>>> for(k=[0:1:len(list)-2]){ >>>> hull(){ >>>> translate(list[k])sphere(w/2); >>>> translate(list[k+1])sphere(w/2); >>>> } >>>> } >>>> } >>>> >>>> module shape(){ >>>> round=pointcircle(diam,sa,ea,res); >>>> straight= [[0,es],[0,ss]]; >>>> all= concat(straight,round); >>>> pointshull(all); >>>> } >>>> >>>> shape(); >>>> >>>> diam = 50; // diam of 'hook' >>>> sa = 135; // start angle >>>> ea = 0; // end angle >>>> res = 200; // resolution for circle >>>> ss = 35; // start of straight >>>> w = 8; // diameter of 'wire' >>>> >>>> es = ss+40; // end of straight >>>> $fn = res/8;// smaller = quicker >>>> >>>> >>>> >>>> If you want a square cross section, so you can easily fdm print, then >>>> do it as 2d, and linear extrude. Using a $fn=4 or similar distorts the >>>> cross section around the curve, since 'the cube' does not rotate as it >>>> follows the path, so to speak. >>>> >>>> >>>> On 07/03/2025 21:03, Raymond West via Discuss wrote: >>>> >>>> Probably best to work with points, and generate the polygon for the mid >>>> section. You know the rh point at bottom of top piece ((3/2, 18.25) you can >>>> use trig (sin & cos) to get the inner point of the 45 degree cut. You can >>>> calculate the length of the middle section, (Pythagoras?) and the width >>>> will be 3. You can generate the four points for the middle rectangle (or a >>>> square based on the calculated length and 3) and calculate its position. ( >>>> you have already found the two points needed. (atan2 and translate). You do >>>> not need the lh, bottom point of the upper piece, (-3/2,18.25) since if you >>>> use that you will get a tapered middle section, unless you do another >>>> calculation to get one of the corners of the middle piece. >>>> >>>> You could write a generic script, where you enter the width and radius >>>> and length of straight section, and produce the shape in whatever size you >>>> want, merely by adjusting those three values. (or set the width and length >>>> as a function of the radius, and then you only need to enter the radius) >>>> On 07/03/2025 20:06, Mark Harrison via Discuss wrote: >>>> >>>> Here is a hook with a lower curved part and an upper straight part. >>>> How can I calculate the proper dimension/position of the middle connecting >>>> part? In this sample I visually positioned it by trial and error, but I >>>> would like to learn how to calculate this. >>>> >>>> Pure SCAD, or a pointer to other code that might solve the geometry >>>> appreciated. I am as interested in learning the general solution/principle >>>> as I am in the practical solution to the problem. >>>> >>>> // looped lower portion of hook >>>> difference() { >>>> circle(d=30); >>>> circle(d=24); >>>> square(30); >>>> rotate(45) square(30); >>>> } >>>> // visually drawn mid-portion of hook >>>> #rotate(45) translate([0,12]) square([14,3]); >>>> // straight upper portion of hook >>>> translate([-3/2,18.25]) square([3,16]); >>>> >>>> [image: image.png] >>>> >>>> -- >>>> Mark Harrison >>>> marhar@gmail.com >>>> >>>> _______________________________________________ >>>> 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 >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > -- Null
AM
Adrian Mariano
Sat, Mar 8, 2025 4:27 PM

Moving in 3D is substantially more complicated because you need to track
not just position and direction but also roll, so a completely separate
turtle3d() command exists for this purpose, which is able to return a list
of transformation matrices instead of just a path.

https://github.com/BelfrySCAD/BOSL2/wiki/turtle3d.scad

On Sat, Mar 8, 2025 at 11:19 AM Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:

Does Bosl2 Turtle also Support Moving in 3d Space ?

Am Samstag, 8. März 2025 schrieb Father Horton via Discuss <
discuss@lists.openscad.org>:

BOSL2’s turtle is my tool of choice for any time I need a path of
connected lines and arcs. It’s much easier than math.

On Sat, Mar 8, 2025 at 8:06 AM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

I had the impression that the poster wanted the math, not an
answer....but BOSL2's turtle command also has lines and arcs in one
command.  You can pass the result to path_sweep with the profile of your
choice.

include<BOSL2/std.scad>
r=15;
stem=25;
angle=45;
path = turtle(["right", 90,
"arcright", r, 180+angle,
"untilx", 0,
"left", angle,
//              "arcleft", 9, angle,
"move", stem], [r,0]);
stroke(path,width=2);

It's easy to eliminate the sharp corner, though it does misalign the
stem with the center of the hook circle.

[image: image.png]
[image: image.png]

On Sat, Mar 8, 2025 at 8:40 AM Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:

Pythonscad path Extrude would be best Match. It has Lines and arcs in
one command and you can even define the Cross section.

Raymond West via Discuss discuss@lists.openscad.org schrieb am Sa.,
8. März 2025, 14:34:

I've ignored what has gone before, and have this, pretty well
parametric. Wrt a practical hook, then this design fails, it is merely an
example of stringing together a list of points to get a solid shape, with
some variation.

// Function to generate points on a circle's circumference
function pointcircle(d, a1, a2, s) = let(
radius = d / 2,
// Calculate the angular step and handle direction
angle_diff = (a2 - a1 + (a2 >= a1 ? 0 : 360)),
num_points = ceil(abs(angle_diff) / (360 / s))
) [for (i = [0 : num_points - 1])
let(angle = a1 + i * angle_diff / (num_points - 1))
[radius * cos(angle), radius * sin(angle), 0]
];

module pointshull(list){
for(k=[0:1:len(list)-2]){
hull(){
translate(list[k])sphere(w/2);
translate(list[k+1])sphere(w/2);
}
}
}

module shape(){
round=pointcircle(diam,sa,ea,res);
straight= [[0,es],[0,ss]];
all= concat(straight,round);
pointshull(all);
}

shape();

diam = 50;  // diam of 'hook'
sa = 135;  // start angle
ea = 0;    // end angle
res = 200;  // resolution for circle
ss = 35;    // start of straight
w = 8;      // diameter of 'wire'

es = ss+40; // end of straight
$fn = res/8;// smaller = quicker

If you want a square cross section, so you can easily fdm print, then
do it as 2d, and linear extrude. Using a $fn=4 or similar distorts the
cross section around the curve, since 'the cube' does not rotate as it
follows the path, so to speak.

On 07/03/2025 21:03, Raymond West via Discuss wrote:

Probably best to work with points, and generate the polygon for the
mid section. You know the rh point at bottom of top piece ((3/2, 18.25) you
can use trig  (sin & cos) to get the inner point of the 45 degree cut. You
can calculate the length of the middle section, (Pythagoras?) and the width
will be 3. You can generate the four points for the middle rectangle (or a
square based on the calculated length and 3) and calculate its position. (
you have already found the two points needed. (atan2 and translate). You do
not need the lh, bottom point of the upper piece, (-3/2,18.25) since if you
use that you will get a tapered middle section, unless you do another
calculation to get one of the corners of the middle piece.

You could write a generic script, where you enter the width and radius
and length of straight section, and produce the shape in whatever size you
want, merely by adjusting those three values. (or set the width and length
as a function of the radius, and then you only need to enter the radius)
On 07/03/2025 20:06, Mark Harrison via Discuss wrote:

Here is a hook with a lower curved part and an upper straight part.
How can I calculate the proper dimension/position of the middle connecting
part?  In this sample I visually positioned it by trial and error, but I
would like to learn how to calculate this.

Pure SCAD, or a pointer to other code that might solve the geometry
appreciated.  I am as interested in learning the general solution/principle
as I am in the practical solution to the problem.

// looped lower portion of hook
difference() {
circle(d=30);
circle(d=24);
square(30);
rotate(45) square(30);
}
// visually drawn mid-portion of hook
#rotate(45) translate([0,12]) square([14,3]);
// straight upper portion of hook
translate([-3/2,18.25]) square([3,16]);

[image: image.png]

--
Mark Harrison
marhar@gmail.com


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


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

--
Null


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

Moving in 3D is substantially more complicated because you need to track not just position and direction but also roll, so a completely separate turtle3d() command exists for this purpose, which is able to return a list of transformation matrices instead of just a path. https://github.com/BelfrySCAD/BOSL2/wiki/turtle3d.scad On Sat, Mar 8, 2025 at 11:19 AM Guenther Sohler via Discuss < discuss@lists.openscad.org> wrote: > Does Bosl2 Turtle also Support Moving in 3d Space ? > > Am Samstag, 8. März 2025 schrieb Father Horton via Discuss < > discuss@lists.openscad.org>: > >> BOSL2’s turtle is my tool of choice for any time I need a path of >> connected lines and arcs. It’s much easier than math. >> >> On Sat, Mar 8, 2025 at 8:06 AM Adrian Mariano via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> I had the impression that the poster wanted the math, not an >>> answer....but BOSL2's turtle command also has lines and arcs in one >>> command. You can pass the result to path_sweep with the profile of your >>> choice. >>> >>> include<BOSL2/std.scad> >>> r=15; >>> stem=25; >>> angle=45; >>> path = turtle(["right", 90, >>> "arcright", r, 180+angle, >>> "untilx", 0, >>> "left", angle, >>> // "arcleft", 9, angle, >>> "move", stem], [r,0]); >>> stroke(path,width=2); >>> >>> It's easy to eliminate the sharp corner, though it does misalign the >>> stem with the center of the hook circle. >>> >>> [image: image.png] >>> [image: image.png] >>> >>> >>> On Sat, Mar 8, 2025 at 8:40 AM Guenther Sohler via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> Pythonscad path Extrude would be best Match. It has Lines and arcs in >>>> one command and you can even define the Cross section. >>>> >>>> Raymond West via Discuss <discuss@lists.openscad.org> schrieb am Sa., >>>> 8. März 2025, 14:34: >>>> >>>>> I've ignored what has gone before, and have this, pretty well >>>>> parametric. Wrt a practical hook, then this design fails, it is merely an >>>>> example of stringing together a list of points to get a solid shape, with >>>>> some variation. >>>>> >>>>> >>>>> >>>>> // Function to generate points on a circle's circumference >>>>> function pointcircle(d, a1, a2, s) = let( >>>>> radius = d / 2, >>>>> // Calculate the angular step and handle direction >>>>> angle_diff = (a2 - a1 + (a2 >= a1 ? 0 : 360)), >>>>> num_points = ceil(abs(angle_diff) / (360 / s)) >>>>> ) [for (i = [0 : num_points - 1]) >>>>> let(angle = a1 + i * angle_diff / (num_points - 1)) >>>>> [radius * cos(angle), radius * sin(angle), 0] >>>>> ]; >>>>> >>>>> module pointshull(list){ >>>>> for(k=[0:1:len(list)-2]){ >>>>> hull(){ >>>>> translate(list[k])sphere(w/2); >>>>> translate(list[k+1])sphere(w/2); >>>>> } >>>>> } >>>>> } >>>>> >>>>> module shape(){ >>>>> round=pointcircle(diam,sa,ea,res); >>>>> straight= [[0,es],[0,ss]]; >>>>> all= concat(straight,round); >>>>> pointshull(all); >>>>> } >>>>> >>>>> shape(); >>>>> >>>>> diam = 50; // diam of 'hook' >>>>> sa = 135; // start angle >>>>> ea = 0; // end angle >>>>> res = 200; // resolution for circle >>>>> ss = 35; // start of straight >>>>> w = 8; // diameter of 'wire' >>>>> >>>>> es = ss+40; // end of straight >>>>> $fn = res/8;// smaller = quicker >>>>> >>>>> >>>>> >>>>> If you want a square cross section, so you can easily fdm print, then >>>>> do it as 2d, and linear extrude. Using a $fn=4 or similar distorts the >>>>> cross section around the curve, since 'the cube' does not rotate as it >>>>> follows the path, so to speak. >>>>> >>>>> >>>>> On 07/03/2025 21:03, Raymond West via Discuss wrote: >>>>> >>>>> Probably best to work with points, and generate the polygon for the >>>>> mid section. You know the rh point at bottom of top piece ((3/2, 18.25) you >>>>> can use trig (sin & cos) to get the inner point of the 45 degree cut. You >>>>> can calculate the length of the middle section, (Pythagoras?) and the width >>>>> will be 3. You can generate the four points for the middle rectangle (or a >>>>> square based on the calculated length and 3) and calculate its position. ( >>>>> you have already found the two points needed. (atan2 and translate). You do >>>>> not need the lh, bottom point of the upper piece, (-3/2,18.25) since if you >>>>> use that you will get a tapered middle section, unless you do another >>>>> calculation to get one of the corners of the middle piece. >>>>> >>>>> You could write a generic script, where you enter the width and radius >>>>> and length of straight section, and produce the shape in whatever size you >>>>> want, merely by adjusting those three values. (or set the width and length >>>>> as a function of the radius, and then you only need to enter the radius) >>>>> On 07/03/2025 20:06, Mark Harrison via Discuss wrote: >>>>> >>>>> Here is a hook with a lower curved part and an upper straight part. >>>>> How can I calculate the proper dimension/position of the middle connecting >>>>> part? In this sample I visually positioned it by trial and error, but I >>>>> would like to learn how to calculate this. >>>>> >>>>> Pure SCAD, or a pointer to other code that might solve the geometry >>>>> appreciated. I am as interested in learning the general solution/principle >>>>> as I am in the practical solution to the problem. >>>>> >>>>> // looped lower portion of hook >>>>> difference() { >>>>> circle(d=30); >>>>> circle(d=24); >>>>> square(30); >>>>> rotate(45) square(30); >>>>> } >>>>> // visually drawn mid-portion of hook >>>>> #rotate(45) translate([0,12]) square([14,3]); >>>>> // straight upper portion of hook >>>>> translate([-3/2,18.25]) square([3,16]); >>>>> >>>>> [image: image.png] >>>>> >>>>> -- >>>>> Mark Harrison >>>>> marhar@gmail.com >>>>> >>>>> _______________________________________________ >>>>> 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 >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> > > -- > Null > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jon Bondy
Sat, Mar 8, 2025 5:21 PM

Yes

https://github.com/BelfrySCAD/BOSL2/wiki/turtle3d.scad

On 3/8/2025 11:19 AM, Guenther Sohler via Discuss wrote:

Does Bosl2 Turtle also Support Moving in 3d Space ?

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Yes https://github.com/BelfrySCAD/BOSL2/wiki/turtle3d.scad On 3/8/2025 11:19 AM, Guenther Sohler via Discuss wrote: > Does Bosl2 Turtle also Support Moving in 3d Space ? > -- This email has been checked for viruses by AVG antivirus software. www.avg.com