discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

3D of where 2 shapes intersect

PK
Peter Kriens
Sat, Feb 22, 2025 4:19 PM

I am looking for a way to calculate the 3D path where two shapes are intersecting. In this case, a shape can be limited to a linearly extruded 2D path.

For example:

phi = 45;
union() {
rotate([0,phi,0])  rotate([0,0,45]) cube([20,20,80],center=true);
rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true);
}

I would like to have the 3D path indicated in red ...

I am looking for something like:

function intersect( a, b, phi ) = ...

Where an and b are 2D paths of the 2 shapes and phi is 1/2 the intersecting angle for an and b. I understand there are 2, I want the one closes to the XY plane.

I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the built in functions would be great.

BTW, this is related to ambiguous cylinders https://www.youtube.com/watch?v=sQ-Fsv8vVKo. I want to experiment with different shapes but that requires the formula to be generic.

Kind regards,

Peter Kriens
I am looking for a way to calculate the 3D path where two shapes are intersecting. In this case, a shape can be limited to a linearly extruded 2D path. For example: phi = 45; union() { rotate([0,phi,0]) rotate([0,0,45]) cube([20,20,80],center=true); rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true); } I would like to have the 3D path indicated in red ...  I am looking for something like: function intersect( a, b, phi ) = ... Where an and b are 2D paths of the 2 shapes and phi is 1/2 the intersecting angle for an and b. I understand there are 2, I want the one closes to the XY plane. I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the built in functions would be great. BTW, this is related to ambiguous cylinders <https://www.youtube.com/watch?v=sQ-Fsv8vVKo>. I want to experiment with different shapes but that requires the formula to be generic. Kind regards, Peter Kriens
AM
Adrian Mariano
Sat, Feb 22, 2025 9:03 PM

The code in BOSL2's join_prism() computes this intersection when you give
it to prisms as input, but it isn't exposed to users.  Also some recent
tests suggest that this code may have bugs in the case of two arbitrary
linear extrusions.

On Sat, Feb 22, 2025 at 11:20 AM Peter Kriens via Discuss <
discuss@lists.openscad.org> wrote:

I am looking for a way to calculate the 3D path where two shapes are
intersecting. In this case, a shape can be limited to a linearly extruded
2D path.

For example:

phi = 45;
union() {
rotate([0,phi,0])  rotate([0,0,45]) cube([20,20,80],center=true);
rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true);
}

I would like to have the 3D path indicated in red ...

[image: PastedGraphic-1.png]

I am looking for something like:

function intersect( a, b, phi ) = ...

Where an and b are 2D paths of the 2 shapes and phi is 1/2 the
intersecting angle for an and b. I understand there are 2, I want the one
closes to the XY plane.

I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the
built in functions would be great.

BTW, this is related to ambiguous cylinders
https://www.youtube.com/watch?v=sQ-Fsv8vVKo. I want to experiment with
different shapes but that requires the formula to be generic.

Kind regards,

Peter Kriens


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

The code in BOSL2's join_prism() computes this intersection when you give it to prisms as input, but it isn't exposed to users. Also some recent tests suggest that this code may have bugs in the case of two arbitrary linear extrusions. On Sat, Feb 22, 2025 at 11:20 AM Peter Kriens via Discuss < discuss@lists.openscad.org> wrote: > I am looking for a way to calculate the 3D path where two shapes are > intersecting. In this case, a shape can be limited to a linearly extruded > 2D path. > > For example: > > phi = 45; > union() { > rotate([0,phi,0]) rotate([0,0,45]) cube([20,20,80],center=true); > rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true); > } > > I would like to have the 3D path indicated in red ... > > [image: PastedGraphic-1.png] > > I am looking for something like: > > function intersect( a, b, phi ) = ... > > Where an and b are 2D paths of the 2 shapes and phi is 1/2 the > intersecting angle for an and b. I understand there are 2, I want the one > closes to the XY plane. > > I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the > built in functions would be great. > > BTW, this is related to ambiguous cylinders > <https://www.youtube.com/watch?v=sQ-Fsv8vVKo>. I want to experiment with > different shapes but that requires the formula to be generic. > > Kind regards, > > Peter Kriens > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
R
Rudolf
Sun, Feb 23, 2025 12:29 AM

The intersection of a plane with a cylinder is an ellipse. In your
special well-behaved case of phi = 45, and an extruded square shape
intersecting with a circle of same diameter you can scale a circle with
1/sin(phi) and transform it to the intersection plane. This is what my
code shows (but not in a generic way). In the next step you would
describe the parts of the scaled circles you are interested in with a
function and transform it with affine transformations.

However, I would say there is no hope in using OpenSCAD function
language to find the intersection path of arbitrary tilted extruded
shapes, even if the shapes are well-behaved - i.e. their extrusions have
a unique path between your start and end point on the X-axis. If you
tried this you'd be forced to implement complex node search, sort and
calculation algorithms first and you'd encounter a lot of numerical
problems. Much fun.

p = 45;
r = 14.2;

intersection()
{
  rotate([0,p,0])  rotate([0,0,45]) cube([20,20,80],center=true);
  rotate([0,-p,0]) cylinder(r=14.2,h=80,center=true);
}

color("red")
rotate([0, 180-p, 0])
translate([0, 0, r])
rotate([-p, 0, 0])
scale([1, 1/sin(p), 1])
circle(r);

color("green")
rotate([0, -p, 0])
translate([0, 0, r])
rotate([-p, 0, 0])
scale([1, 1/sin(p), 1])
circle(r);

Am 22.02.2025 um 17:19 schrieb Peter Kriens via Discuss:

I am looking for a way to calculate the 3D path where two shapes are
intersecting. In this case, a shape can be limited to a linearly
extruded 2D path.

For example:

phi = 45;
union() {
  rotate([0,phi,0])  rotate([0,0,45]) cube([20,20,80],center=true);
  rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true);
}

I would like to have the 3D path indicated in red ...

PastedGraphic-1.png

I am looking for something like:

function intersect( a, b, phi ) = ...

Where an and b are 2D paths of the 2 shapes and phi is 1/2 the
intersecting angle for an and b. I understand there are 2, I want the
one closes to the XY plane.

I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of
the built in functions would be great.

BTW, this is related to ambiguous cylinders
https://www.youtube.com/watch?v=sQ-Fsv8vVKo. I want to experiment
with different shapes but that requires the formula to be generic.

Kind regards,

Peter Kriens


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

The intersection of a plane with a cylinder is an ellipse. In your special well-behaved case of phi = 45, and an extruded square shape intersecting with a circle of same diameter you can scale a circle with 1/sin(phi) and transform it to the intersection plane. This is what my code shows (but not in a generic way). In the next step you would describe the parts of the scaled circles you are interested in with a function and transform it with affine transformations. However, I would say there is no hope in using OpenSCAD function language to find the intersection path of arbitrary tilted extruded shapes, even if the shapes are well-behaved - i.e. their extrusions have a unique path between your start and end point on the X-axis. If you tried this you'd be forced to implement complex node search, sort and calculation algorithms first and you'd encounter a lot of numerical problems. Much fun. p = 45; r = 14.2; intersection() {   rotate([0,p,0])  rotate([0,0,45]) cube([20,20,80],center=true);   rotate([0,-p,0]) cylinder(r=14.2,h=80,center=true); } color("red") rotate([0, 180-p, 0]) translate([0, 0, r]) rotate([-p, 0, 0]) scale([1, 1/sin(p), 1]) circle(r); color("green") rotate([0, -p, 0]) translate([0, 0, r]) rotate([-p, 0, 0]) scale([1, 1/sin(p), 1]) circle(r); Am 22.02.2025 um 17:19 schrieb Peter Kriens via Discuss: > I am looking for a way to calculate the 3D path where two shapes are > intersecting. In this case, a shape can be limited to a linearly > extruded 2D path. > > For example: > > phi = 45; > union() { >   rotate([0,phi,0])  rotate([0,0,45]) cube([20,20,80],center=true); >   rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true); > } > > I would like to have the 3D path indicated in red ... > > PastedGraphic-1.png > > I am looking for something like: > > function intersect( a, b, phi ) = ... > > Where an and b are 2D paths of the 2 shapes and phi is 1/2 the > intersecting angle for an and b. I understand there are 2, I want the > one closes to the XY plane. > > I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of > the built in functions would be great. > > BTW, this is related to ambiguous cylinders > <https://www.youtube.com/watch?v=sQ-Fsv8vVKo>. I want to experiment > with different shapes but that requires the formula to be generic. > > Kind regards, > > Peter Kriens > > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
AM
Adrian Mariano
Sun, Feb 23, 2025 1:30 AM

Here is an example taken from the BOSL2 manual for join_prism() which works
by computing the intersection between two arbitrary linear extrusions and
then computes a rounding profile along that intersection.  Here we have the
flower shaped object as one component and an ellipse shaped object as the
second one.  Things will go wrong if the objects aren't well enough
behaved, but the problem is not impossible in OpenSCAD, at least for
reasonable cases.

[image: image.png]

On Sat, Feb 22, 2025 at 7:30 PM Rudolf via Discuss <
discuss@lists.openscad.org> wrote:

The intersection of a plane with a cylinder is an ellipse. In your special
well-behaved case of phi = 45, and an extruded square shape intersecting
with a circle of same diameter you can scale a circle with 1/sin(phi) and
transform it to the intersection plane. This is what my code shows (but not
in a generic way). In the next step you would describe the parts of the
scaled circles you are interested in with a function and transform it with
affine transformations.

However, I would say there is no hope in using OpenSCAD function language
to find the intersection path of arbitrary tilted extruded shapes, even if
the shapes are well-behaved - i.e. their extrusions have a unique path
between your start and end point on the X-axis. If you tried this you'd be
forced to implement complex node search, sort and calculation algorithms
first and you'd encounter a lot of numerical problems. Much fun.

p = 45;
r = 14.2;

intersection()
{
rotate([0,p,0])  rotate([0,0,45]) cube([20,20,80],center=true);
rotate([0,-p,0]) cylinder(r=14.2,h=80,center=true);
}

color("red")
rotate([0, 180-p, 0])
translate([0, 0, r])
rotate([-p, 0, 0])
scale([1, 1/sin(p), 1])
circle(r);

color("green")
rotate([0, -p, 0])
translate([0, 0, r])
rotate([-p, 0, 0])
scale([1, 1/sin(p), 1])
circle(r);

Am 22.02.2025 um 17:19 schrieb Peter Kriens via Discuss:

I am looking for a way to calculate the 3D path where two shapes are
intersecting. In this case, a shape can be limited to a linearly extruded
2D path.

For example:

phi = 45;
union() {
rotate([0,phi,0])  rotate([0,0,45]) cube([20,20,80],center=true);
rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true);
}

I would like to have the 3D path indicated in red ...

[image: PastedGraphic-1.png]

I am looking for something like:

function intersect( a, b, phi ) = ...

Where an and b are 2D paths of the 2 shapes and phi is 1/2 the
intersecting angle for an and b. I understand there are 2, I want the one
closes to the XY plane.

I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the
built in functions would be great.

BTW, this is related to ambiguous cylinders
https://www.youtube.com/watch?v=sQ-Fsv8vVKo. I want to experiment with
different shapes but that requires the formula to be generic.

Kind regards,

Peter Kriens


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

Here is an example taken from the BOSL2 manual for join_prism() which works by computing the intersection between two arbitrary linear extrusions and then computes a rounding profile along that intersection. Here we have the flower shaped object as one component and an ellipse shaped object as the second one. Things will go wrong if the objects aren't well enough behaved, but the problem is not impossible in OpenSCAD, at least for reasonable cases. [image: image.png] On Sat, Feb 22, 2025 at 7:30 PM Rudolf via Discuss < discuss@lists.openscad.org> wrote: > The intersection of a plane with a cylinder is an ellipse. In your special > well-behaved case of phi = 45, and an extruded square shape intersecting > with a circle of same diameter you can scale a circle with 1/sin(phi) and > transform it to the intersection plane. This is what my code shows (but not > in a generic way). In the next step you would describe the parts of the > scaled circles you are interested in with a function and transform it with > affine transformations. > > However, I would say there is no hope in using OpenSCAD function language > to find the intersection path of arbitrary tilted extruded shapes, even if > the shapes are well-behaved - i.e. their extrusions have a unique path > between your start and end point on the X-axis. If you tried this you'd be > forced to implement complex node search, sort and calculation algorithms > first and you'd encounter a lot of numerical problems. Much fun. > > p = 45; > r = 14.2; > > intersection() > { > rotate([0,p,0]) rotate([0,0,45]) cube([20,20,80],center=true); > rotate([0,-p,0]) cylinder(r=14.2,h=80,center=true); > } > > color("red") > rotate([0, 180-p, 0]) > translate([0, 0, r]) > rotate([-p, 0, 0]) > scale([1, 1/sin(p), 1]) > circle(r); > > color("green") > rotate([0, -p, 0]) > translate([0, 0, r]) > rotate([-p, 0, 0]) > scale([1, 1/sin(p), 1]) > circle(r); > > > > > > Am 22.02.2025 um 17:19 schrieb Peter Kriens via Discuss: > > I am looking for a way to calculate the 3D path where two shapes are > intersecting. In this case, a shape can be limited to a linearly extruded > 2D path. > > For example: > > phi = 45; > union() { > rotate([0,phi,0]) rotate([0,0,45]) cube([20,20,80],center=true); > rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true); > } > > I would like to have the 3D path indicated in red ... > > [image: PastedGraphic-1.png] > > I am looking for something like: > > function intersect( a, b, phi ) = ... > > Where an and b are 2D paths of the 2 shapes and phi is 1/2 the > intersecting angle for an and b. I understand there are 2, I want the one > closes to the XY plane. > > I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the > built in functions would be great. > > BTW, this is related to ambiguous cylinders > <https://www.youtube.com/watch?v=sQ-Fsv8vVKo>. I want to experiment with > different shapes but that requires the formula to be generic. > > Kind regards, > > Peter Kriens > > > > > _______________________________________________ > 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 >
SP
Sanjeev Prabhakar
Sun, Feb 23, 2025 1:54 AM

Here is an example of intersection line between 2 solids and then
manipulating the points to get the kind of line you showed in your sketch
step1:
[image: Screenshot 2025-02-23 at 7.12.26 AM.png]

step2:
[image: Screenshot 2025-02-23 at 7.17.02 AM.png]

Here is an example of intersection line between 2 solids and then manipulating the points to get the kind of line you showed in your sketch step1: [image: Screenshot 2025-02-23 at 7.12.26 AM.png] step2: [image: Screenshot 2025-02-23 at 7.17.02 AM.png]
SP
Sanjeev Prabhakar
Sun, Feb 23, 2025 2:17 AM

but the person in video is probably showing this:
[image: Screenshot 2025-02-23 at 7.45.33 AM.png]

but the person in video is probably showing this: [image: Screenshot 2025-02-23 at 7.45.33 AM.png]
SP
Sanjeev Prabhakar
Sun, Feb 23, 2025 2:37 AM

attached is the scad file generated and the code:
need to add more points for further finer results

from openscad2 import *
a=rot('z45',linear_extrude(pts([[-10,-10],[20,0],[0,20],[-20,0]]),50))
b=o_solid([-1,0,0],circle(14,s=500),50,-25,0,25)
a=rsz3dc(a,[30,40,50])
b=rsz3dc(b,[50,40,30])
l1=ip_sol2sol(a,b,0)
l2=ip_sol2sol(a,b,-1)
l3=l2[:250]+l1[250:]
l3=sec2surface_2(l3)
l4=translate(rot('y45',[-50,0,0]),l3)
sol=rot('y45',solid_from_2surfaces(l3,l4))
with open('trial.scad','w+') as f:
f.write(f'''
{swp(sol)}

''')
attached is the scad file generated and the code: need to add more points for further finer results from openscad2 import * a=rot('z45',linear_extrude(pts([[-10,-10],[20,0],[0,20],[-20,0]]),50)) b=o_solid([-1,0,0],circle(14,s=500),50,-25,0,25) a=rsz3dc(a,[30,40,50]) b=rsz3dc(b,[50,40,30]) l1=ip_sol2sol(a,b,0) l2=ip_sol2sol(a,b,-1) l3=l2[:250]+l1[250:] l3=sec2surface_2(l3) l4=translate(rot('y45',[-50,0,0]),l3) sol=rot('y45',solid_from_2surfaces(l3,l4)) with open('trial.scad','w+') as f: f.write(f''' {swp(sol)} ''')
PK
Peter Kriens
Mon, Feb 24, 2025 8:11 AM

Thanks Rudolf! However, the path I am looking for is 3D, it is not a simple intersection in a plane. It is the z-dimension that makes our eyes believe it happens in the x-y plane.

Peter

On 23 Feb 2025, at 01:29, Rudolf via Discuss discuss@lists.openscad.org wrote:

The intersection of a plane with a cylinder is an ellipse. In your special well-behaved case of phi = 45, and an extruded square shape intersecting with a circle of same diameter you can scale a circle with 1/sin(phi) and transform it to the intersection plane. This is what my code shows (but not in a generic way). In the next step you would describe the parts of the scaled circles you are interested in with a function and transform it with affine transformations.

However, I would say there is no hope in using OpenSCAD function language to find the intersection path of arbitrary tilted extruded shapes, even if the shapes are well-behaved - i.e. their extrusions have a unique path between your start and end point on the X-axis. If you tried this you'd be forced to implement complex node search, sort and calculation algorithms first and you'd encounter a lot of numerical problems. Much fun.

p = 45;
r = 14.2;

intersection()
{
rotate([0,p,0])  rotate([0,0,45]) cube([20,20,80],center=true);
rotate([0,-p,0]) cylinder(r=14.2,h=80,center=true);
}

color("red")
rotate([0, 180-p, 0])
translate([0, 0, r])
rotate([-p, 0, 0])
scale([1, 1/sin(p), 1])
circle(r);

color("green")
rotate([0, -p, 0])
translate([0, 0, r])
rotate([-p, 0, 0])
scale([1, 1/sin(p), 1])
circle(r);

<cTt6ag6v39Bm6Wyp.png>

Am 22.02.2025 um 17:19 schrieb Peter Kriens via Discuss:

I am looking for a way to calculate the 3D path where two shapes are intersecting. In this case, a shape can be limited to a linearly extruded 2D path.

For example:

phi = 45;
union() {
rotate([0,phi,0])  rotate([0,0,45]) cube([20,20,80],center=true);
rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true);
}

I would like to have the 3D path indicated in red ...

<PastedGraphic-1.png>

I am looking for something like:

function intersect( a, b, phi ) = ...

Where an and b are 2D paths of the 2 shapes and phi is 1/2 the intersecting angle for an and b. I understand there are 2, I want the one closes to the XY plane.

I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the built in functions would be great.

BTW, this is related to ambiguous cylinders https://www.youtube.com/watch?v=sQ-Fsv8vVKo. I want to experiment with different shapes but that requires the formula to be generic.

Kind regards,

Peter Kriens

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


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

Thanks Rudolf! However, the path I am looking for is 3D, it is not a simple intersection in a plane. It is the z-dimension that makes our eyes believe it happens in the x-y plane. Peter > On 23 Feb 2025, at 01:29, Rudolf via Discuss <discuss@lists.openscad.org> wrote: > > The intersection of a plane with a cylinder is an ellipse. In your special well-behaved case of phi = 45, and an extruded square shape intersecting with a circle of same diameter you can scale a circle with 1/sin(phi) and transform it to the intersection plane. This is what my code shows (but not in a generic way). In the next step you would describe the parts of the scaled circles you are interested in with a function and transform it with affine transformations. > > However, I would say there is no hope in using OpenSCAD function language to find the intersection path of arbitrary tilted extruded shapes, even if the shapes are well-behaved - i.e. their extrusions have a unique path between your start and end point on the X-axis. If you tried this you'd be forced to implement complex node search, sort and calculation algorithms first and you'd encounter a lot of numerical problems. Much fun. > > p = 45; > r = 14.2; > > intersection() > { > rotate([0,p,0]) rotate([0,0,45]) cube([20,20,80],center=true); > rotate([0,-p,0]) cylinder(r=14.2,h=80,center=true); > } > > color("red") > rotate([0, 180-p, 0]) > translate([0, 0, r]) > rotate([-p, 0, 0]) > scale([1, 1/sin(p), 1]) > circle(r); > > color("green") > rotate([0, -p, 0]) > translate([0, 0, r]) > rotate([-p, 0, 0]) > scale([1, 1/sin(p), 1]) > circle(r); > > > > <cTt6ag6v39Bm6Wyp.png> > > > > > > > > Am 22.02.2025 um 17:19 schrieb Peter Kriens via Discuss: >> I am looking for a way to calculate the 3D path where two shapes are intersecting. In this case, a shape can be limited to a linearly extruded 2D path. >> >> For example: >> >> phi = 45; >> union() { >> rotate([0,phi,0]) rotate([0,0,45]) cube([20,20,80],center=true); >> rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true); >> } >> >> I would like to have the 3D path indicated in red ... >> >> <PastedGraphic-1.png> >> >> I am looking for something like: >> >> function intersect( a, b, phi ) = ... >> >> Where an and b are 2D paths of the 2 shapes and phi is 1/2 the intersecting angle for an and b. I understand there are 2, I want the one closes to the XY plane. >> >> I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the built in functions would be great. >> >> BTW, this is related to ambiguous cylinders <https://www.youtube.com/watch?v=sQ-Fsv8vVKo>. I want to experiment with different shapes but that requires the formula to be generic. >> >> Kind regards, >> >> Peter Kriens >> >> >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
PK
Peter Kriens
Mon, Feb 24, 2025 8:14 AM

Yes, that is the shape. Thanks.

You are enticing me more and more to try out your environment. Just an old dislike of python that is hard for me to get over ... then again. The Openscad language is actually much worse in the aspects I dislike in Python ... so maybe for a next project.

Peter

On 23 Feb 2025, at 02:54, Sanjeev Prabhakar sprabhakar2006@gmail.com wrote:

Here is an example of intersection line between 2 solids and then manipulating the points to get the kind of line you showed in your sketch
step1:
<Screenshot 2025-02-23 at 7.12.26 AM.png>

step2:
<Screenshot 2025-02-23 at 7.17.02 AM.png>

Yes, that is the shape. Thanks. You are enticing me more and more to try out your environment. Just an old dislike of python that is hard for me to get over ... then again. The Openscad language is actually much worse in the aspects I dislike in Python ... so maybe for a next project. Peter > On 23 Feb 2025, at 02:54, Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > > Here is an example of intersection line between 2 solids and then manipulating the points to get the kind of line you showed in your sketch > step1: > <Screenshot 2025-02-23 at 7.12.26 AM.png> > > step2: > <Screenshot 2025-02-23 at 7.17.02 AM.png> >
PK
Peter Kriens
Mon, Feb 24, 2025 8:40 AM

I love join_prism! Gonna give this a try.

Peter

Can you give me an example how I could get this intersection path?

On 23 Feb 2025, at 02:30, Adrian Mariano via Discuss discuss@lists.openscad.org wrote:

Here is an example taken from the BOSL2 manual for join_prism() which works by computing the intersection between two arbitrary linear extrusions and then computes a rounding profile along that intersection.  Here we have the flower shaped object as one component and an ellipse shaped object as the second one.  Things will go wrong if the objects aren't well enough behaved, but the problem is not impossible in OpenSCAD, at least for reasonable cases.

<image.png>

On Sat, Feb 22, 2025 at 7:30 PM Rudolf via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

The intersection of a plane with a cylinder is an ellipse. In your special well-behaved case of phi = 45, and an extruded square shape intersecting with a circle of same diameter you can scale a circle with 1/sin(phi) and transform it to the intersection plane. This is what my code shows (but not in a generic way). In the next step you would describe the parts of the scaled circles you are interested in with a function and transform it with affine transformations.

However, I would say there is no hope in using OpenSCAD function language to find the intersection path of arbitrary tilted extruded shapes, even if the shapes are well-behaved - i.e. their extrusions have a unique path between your start and end point on the X-axis. If you tried this you'd be forced to implement complex node search, sort and calculation algorithms first and you'd encounter a lot of numerical problems. Much fun.

p = 45;
r = 14.2;

intersection()
{
rotate([0,p,0])  rotate([0,0,45]) cube([20,20,80],center=true);
rotate([0,-p,0]) cylinder(r=14.2,h=80,center=true);
}

color("red")
rotate([0, 180-p, 0])
translate([0, 0, r])
rotate([-p, 0, 0])
scale([1, 1/sin(p), 1])
circle(r);

color("green")
rotate([0, -p, 0])
translate([0, 0, r])
rotate([-p, 0, 0])
scale([1, 1/sin(p), 1])
circle(r);

<cTt6ag6v39Bm6Wyp.png>

Am 22.02.2025 um 17:19 schrieb Peter Kriens via Discuss:

I am looking for a way to calculate the 3D path where two shapes are intersecting. In this case, a shape can be limited to a linearly extruded 2D path.

For example:

phi = 45;
union() {
rotate([0,phi,0])  rotate([0,0,45]) cube([20,20,80],center=true);
rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true);
}

I would like to have the 3D path indicated in red ...

<PastedGraphic-1.png>

I am looking for something like:

function intersect( a, b, phi ) = ...

Where an and b are 2D paths of the 2 shapes and phi is 1/2 the intersecting angle for an and b. I understand there are 2, I want the one closes to the XY plane.

I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the built in functions would be great.

BTW, this is related to ambiguous cylinders https://www.youtube.com/watch?v=sQ-Fsv8vVKo. I want to experiment with different shapes but that requires the formula to be generic.

Kind regards,

Peter Kriens

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


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


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

I love join_prism! Gonna give this a try. Peter Can you give me an example how I could get this intersection path? > On 23 Feb 2025, at 02:30, Adrian Mariano via Discuss <discuss@lists.openscad.org> wrote: > > Here is an example taken from the BOSL2 manual for join_prism() which works by computing the intersection between two arbitrary linear extrusions and then computes a rounding profile along that intersection. Here we have the flower shaped object as one component and an ellipse shaped object as the second one. Things will go wrong if the objects aren't well enough behaved, but the problem is not impossible in OpenSCAD, at least for reasonable cases. > > <image.png> > > > On Sat, Feb 22, 2025 at 7:30 PM Rudolf via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >> The intersection of a plane with a cylinder is an ellipse. In your special well-behaved case of phi = 45, and an extruded square shape intersecting with a circle of same diameter you can scale a circle with 1/sin(phi) and transform it to the intersection plane. This is what my code shows (but not in a generic way). In the next step you would describe the parts of the scaled circles you are interested in with a function and transform it with affine transformations. >> >> However, I would say there is no hope in using OpenSCAD function language to find the intersection path of arbitrary tilted extruded shapes, even if the shapes are well-behaved - i.e. their extrusions have a unique path between your start and end point on the X-axis. If you tried this you'd be forced to implement complex node search, sort and calculation algorithms first and you'd encounter a lot of numerical problems. Much fun. >> >> p = 45; >> r = 14.2; >> >> intersection() >> { >> rotate([0,p,0]) rotate([0,0,45]) cube([20,20,80],center=true); >> rotate([0,-p,0]) cylinder(r=14.2,h=80,center=true); >> } >> >> color("red") >> rotate([0, 180-p, 0]) >> translate([0, 0, r]) >> rotate([-p, 0, 0]) >> scale([1, 1/sin(p), 1]) >> circle(r); >> >> color("green") >> rotate([0, -p, 0]) >> translate([0, 0, r]) >> rotate([-p, 0, 0]) >> scale([1, 1/sin(p), 1]) >> circle(r); >> >> >> >> <cTt6ag6v39Bm6Wyp.png> >> >> >> >> >> >> >> >> Am 22.02.2025 um 17:19 schrieb Peter Kriens via Discuss: >>> I am looking for a way to calculate the 3D path where two shapes are intersecting. In this case, a shape can be limited to a linearly extruded 2D path. >>> >>> For example: >>> >>> phi = 45; >>> union() { >>> rotate([0,phi,0]) rotate([0,0,45]) cube([20,20,80],center=true); >>> rotate([0,-phi,0]) cylinder(r=14.2,h=80,center=true); >>> } >>> >>> I would like to have the 3D path indicated in red ... >>> >>> <PastedGraphic-1.png> >>> >>> I am looking for something like: >>> >>> function intersect( a, b, phi ) = ... >>> >>> Where an and b are 2D paths of the 2 shapes and phi is 1/2 the intersecting angle for an and b. I understand there are 2, I want the one closes to the XY plane. >>> >>> I am stuck ... anybody ideas or hints? I am using BOSL2 so any use of the built in functions would be great. >>> >>> BTW, this is related to ambiguous cylinders <https://www.youtube.com/watch?v=sQ-Fsv8vVKo>. I want to experiment with different shapes but that requires the formula to be generic. >>> >>> Kind regards, >>> >>> Peter Kriens >>> >>> >>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org