R
Rudolf
Mon, Feb 24, 2025 4:43 PM
Well I think, I'd rather try to construct the solution first. Don't know
what exactly you are heading for, but it is rather straight forward to
construct a linearly extruded object bounded by the the path you are
looking for. E.g. a cylinder cut by a 6-star at an angle of 35°. This
is a union of the hull of a difference and some mirrored stuff of the
diff of diff of the same. If one of the objects is not symmetrical,
things get a bit more difficult, but it works.
However the use of hull restricts the solution to convex objects. Maybe
this can help.
Am 24.02.2025 um 09:11 schrieb Peter Kriens via Discuss:
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 todiscuss-leave@lists.openscad.org
Well I think, I'd rather try to construct the solution first. Don't know
what exactly you are heading for, but it is rather straight forward to
construct a linearly extruded object bounded by the the path you are
looking for. E.g. a cylinder cut by a 6-star at an angle of 35°. This
is a union of the hull of a difference and some mirrored stuff of the
diff of diff of the same. If one of the objects is not symmetrical,
things get a bit more difficult, but it works.
However the use of hull restricts the solution to convex objects. Maybe
this can help.
Am 24.02.2025 um 09:11 schrieb Peter Kriens via Discuss:
> 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 todiscuss-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 todiscuss-leave@lists.openscad.org
PK
Peter Kriens
Mon, Feb 24, 2025 5:04 PM
I wanted to have the path of the intersecting shapes because that path needs to be extruded in the z direction (assuming shapes are at 45 degree). Since the intersecting path is 3D, the top of that extrusion must also follow the z values.
This is the original paper about the issue: https://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Sugihara18.pdf
Thanks,
Peter
On 24 Feb 2025, at 17:43, Rudolf via Discuss discuss@lists.openscad.org wrote:
Well I think, I'd rather try to construct the solution first. Don't know what exactly you are heading for, but it is rather straight forward to construct a linearly extruded object bounded by the the path you are looking for. E.g. a cylinder cut by a 6-star at an angle of 35°. This is a union of the hull of a difference and some mirrored stuff of the diff of diff of the same. If one of the objects is not symmetrical, things get a bit more difficult, but it works.
However the use of hull restricts the solution to convex objects. Maybe this can help.
<gPoGVbEHdcgtHc2U.png> <V10j8Cs1v555X8kH.png>
Am 24.02.2025 um 09:11 schrieb Peter Kriens via Discuss:
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 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
I wanted to have the path of the intersecting shapes because that path needs to be extruded in the z direction (assuming shapes are at 45 degree). Since the intersecting path is 3D, the top of that extrusion must also follow the z values.
This is the original paper about the issue: https://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Sugihara18.pdf
Thanks,
Peter
> On 24 Feb 2025, at 17:43, Rudolf via Discuss <discuss@lists.openscad.org> wrote:
>
> Well I think, I'd rather try to construct the solution first. Don't know what exactly you are heading for, but it is rather straight forward to construct a linearly extruded object bounded by the the path you are looking for. E.g. a cylinder cut by a 6-star at an angle of 35°. This is a union of the hull of a difference and some mirrored stuff of the diff of diff of the same. If one of the objects is not symmetrical, things get a bit more difficult, but it works.
>
> However the use of hull restricts the solution to convex objects. Maybe this can help.
>
> <gPoGVbEHdcgtHc2U.png> <V10j8Cs1v555X8kH.png>
>
>
>
>
>
> Am 24.02.2025 um 09:11 schrieb Peter Kriens via Discuss:
>> 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> <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 <mailto:discuss-leave@lists.openscad.org>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
R
Rudolf
Tue, Feb 25, 2025 12:09 AM
Nice problem. challenging approach. Yeah, needs a lot of math. I tried
to model Figure 18 to get a feeling for the difficult parts and saw at
least how it works, and that the main challenge is that the "cheating
surfaces" do have two faces defined by three 3D-lines.
Well, the shading in OpenSCADs viewport is a bit missleading, but I
think it is visible that upper surfaces of the cheating bits need a
proper calculation to make the Illusion perfect for both views ...
Am 24.02.2025 um 18:04 schrieb Peter Kriens via Discuss:
I wanted to have the path of the intersecting shapes because that path
needs to be extruded in the z direction (assuming shapes are at 45
degree). Since the intersecting path is 3D, the top of that extrusion
must also follow the z values.
This is the original paper about the issue:
https://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Sugihara18.pdf
Thanks,
Peter
On 24 Feb 2025, at 17:43, Rudolf via Discuss
discuss@lists.openscad.org wrote:
Well I think, I'd rather try to construct the solution first. Don't
know what exactly you are heading for, but it is rather straight
forward to construct a linearly extruded object bounded by the the
path you are looking for. E.g. a cylinder cut by a 6-star at an
angle of 35°. This is a union of the hull of a difference and some
mirrored stuff of the diff of diff of the same. If one of the objects
is not symmetrical, things get a bit more difficult, but it works.
However the use of hull restricts the solution to convex objects.
Maybe this can help.
<gPoGVbEHdcgtHc2U.png> <V10j8Cs1v555X8kH.png>
Am 24.02.2025 um 09:11 schrieb Peter Kriens via Discuss:
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 todiscuss-leave@lists.openscad.org
Nice problem. challenging approach. Yeah, needs a lot of math. I tried
to model Figure 18 to get a feeling for the difficult parts and saw at
least how it works, and that the main challenge is that the "cheating
surfaces" do have two faces defined by three 3D-lines.
Well, the shading in OpenSCADs viewport is a bit missleading, but I
think it is visible that upper surfaces of the cheating bits need a
proper calculation to make the Illusion perfect for both views ...
Am 24.02.2025 um 18:04 schrieb Peter Kriens via Discuss:
> I wanted to have the path of the intersecting shapes because that path
> needs to be extruded in the z direction (assuming shapes are at 45
> degree). Since the intersecting path is 3D, the top of that extrusion
> must also follow the z values.
>
> This is the original paper about the issue:
> https://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Sugihara18.pdf
>
> Thanks,
>
> Peter
>
>
>
>> On 24 Feb 2025, at 17:43, Rudolf via Discuss
>> <discuss@lists.openscad.org> wrote:
>>
>> Well I think, I'd rather try to construct the solution first. Don't
>> know what exactly you are heading for, but it is rather straight
>> forward to construct a linearly extruded object bounded by the the
>> path you are looking for. E.g. a cylinder cut by a 6-star at an
>> angle of 35°. This is a union of the hull of a difference and some
>> mirrored stuff of the diff of diff of the same. If one of the objects
>> is not symmetrical, things get a bit more difficult, but it works.
>>
>> However the use of hull restricts the solution to convex objects.
>> Maybe this can help.
>>
>> <gPoGVbEHdcgtHc2U.png> <V10j8Cs1v555X8kH.png>
>>
>>
>>
>> Am 24.02.2025 um 09:11 schrieb Peter Kriens via Discuss:
>>> 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 todiscuss-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 todiscuss-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 todiscuss-leave@lists.openscad.org
RW
Raymond West
Tue, Feb 25, 2025 3:34 PM
Is this the sort of 'path' you were looking for?
$fn=100;
s=50;// side
d=s*sqrt(2);
t=2.1; //'thickness' of line
intersection(){
rotate([0,0,45])
difference(){
cube ([s,s,s4],true);
cube([s-t,s-t,s4],true);
}
translate([-s2,0,0])
rotate([0,90,0])
difference(){
cylinder(d=d,h=d3);
cylinder(d=d-t,h=d^3);
}
}
if it is for your specific curve, then difference it with some cubes,
say, (or maybe intersect) to select the parts you want, rotate and
extrude in whatever direction you desire.
If you want a generic solution, using polygons points (the polygons
being in different planes) that is quite doable, but then you will want
instead of intersections on planes, intersection of polyhedrons on faces
of an intermediate polyhedron. (As yet, I have not bothered to refer to
the mentioned paper.)
On 24/02/2025 17:04, Peter Kriens via Discuss wrote:
I wanted to have the path of the intersecting shapes because that path
needs to be extruded in the z direction (assuming shapes are at 45
degree). Since the intersecting path is 3D, the top of that extrusion
must also follow the z values.
This is the original paper about the issue:
https://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Sugihara18.pdf
Thanks,
Peter
On 24 Feb 2025, at 17:43, Rudolf via Discuss
discuss@lists.openscad.org wrote:
Well I think, I'd rather try to construct the solution first. Don't
know what exactly you are heading for, but it is rather straight
forward to construct a linearly extruded object bounded by the the
path you are looking for. E.g. a cylinder cut by a 6-star at an
angle of 35°. This is a union of the hull of a difference and some
mirrored stuff of the diff of diff of the same. If one of the objects
is not symmetrical, things get a bit more difficult, but it works.
However the use of hull restricts the solution to convex objects.
Maybe this can help.
<gPoGVbEHdcgtHc2U.png> <V10j8Cs1v555X8kH.png>
Am 24.02.2025 um 09:11 schrieb Peter Kriens via Discuss:
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 todiscuss-leave@lists.openscad.org
Is this the sort of 'path' you were looking for?
$fn=100;
s=50;// side
d=s*sqrt(2);
t=2.1; //'thickness' of line
intersection(){
rotate([0,0,45])
difference(){
cube ([s,s,s*4],true);
cube([s-t,s-t,s*4],true);
}
translate([-s*2,0,0])
rotate([0,90,0])
difference(){
cylinder(d=d,h=d*3);
cylinder(d=d-t,h=d^3);
}
}
if it is for your specific curve, then difference it with some cubes,
say, (or maybe intersect) to select the parts you want, rotate and
extrude in whatever direction you desire.
If you want a generic solution, using polygons points (the polygons
being in different planes) that is quite doable, but then you will want
instead of intersections on planes, intersection of polyhedrons on faces
of an intermediate polyhedron. (As yet, I have not bothered to refer to
the mentioned paper.)
On 24/02/2025 17:04, Peter Kriens via Discuss wrote:
> I wanted to have the path of the intersecting shapes because that path
> needs to be extruded in the z direction (assuming shapes are at 45
> degree). Since the intersecting path is 3D, the top of that extrusion
> must also follow the z values.
>
> This is the original paper about the issue:
> https://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Sugihara18.pdf
>
> Thanks,
>
> Peter
>
>
>
>> On 24 Feb 2025, at 17:43, Rudolf via Discuss
>> <discuss@lists.openscad.org> wrote:
>>
>> Well I think, I'd rather try to construct the solution first. Don't
>> know what exactly you are heading for, but it is rather straight
>> forward to construct a linearly extruded object bounded by the the
>> path you are looking for. E.g. a cylinder cut by a 6-star at an
>> angle of 35°. This is a union of the hull of a difference and some
>> mirrored stuff of the diff of diff of the same. If one of the objects
>> is not symmetrical, things get a bit more difficult, but it works.
>>
>> However the use of hull restricts the solution to convex objects.
>> Maybe this can help.
>>
>> <gPoGVbEHdcgtHc2U.png> <V10j8Cs1v555X8kH.png>
>>
>>
>>
>> Am 24.02.2025 um 09:11 schrieb Peter Kriens via Discuss:
>>> 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 todiscuss-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 todiscuss-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 todiscuss-leave@lists.openscad.org
R
Rudolf
Thu, Feb 27, 2025 9:28 PM
Hi Peter,
Adrian was right, it is not such a big drama to compute the intersection
point of two extruded shapes, as long as they are somehow
"well-behaved". I extracted the relevant functions and modules from my
libraries and wrote your function intersect(shape1, shape2, w1, w2)
and some test stuff with generic OpenSCAD. Find the scad file attached.
The code is indeed quite neat and easy to understand. It computes the
affine intersection of freely translated and rotated 2D-shapes, which
are assumed to be endless in both directions.
The function calculates all planes of the faces that delimit shape2,
intersects each with all lines of shape1 and collects and returns only
those points that are situated on a face This means, two function calls
are needed to get hands on all intersection points. I leave it up to you
to sort the sets together. In most cases you will be fine just using the
richer set.
I didn't have the time to protect the code against instabilities, mostly
singularities from the dot product of two parallel vectors. As usual in
OpenSCAD tiny-angle rotations or tiny-value translations get you around,
as shown in the test code that produced the second example.
Hope this helps you along. I'm curious whether it will bring you forward
with the topology stuff in the paper.
Rudolf
// intersect two 2D shapes at an angle w
function intersect(Sh1, Sh2, w1=w1, w2=w2) =
let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
let(L1 = len(Sh1), L2=len(Sh2))
let(sign = L1<L2)
let(result =
[
for(i = [0:L2-1], j = [0:L1-1])
// define the current face of Sh2
let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
let(P3 = P1+N2, P4 = P2+N2)
let(d = norm(P1-P2))
// calc the intersection of all lines of Sh1 with current face of Sh2
let(A = Sh1[j], B = A+N1)
let(I = line_plane_intersection(A, B, P1, P2, P3))
let(dist1 = distance_point_to_line(P1, P3, I))
let(dist2 = distance_point_to_line(P2, P4, I))
// filter points that closely touch the face
if(dist1+dist2<=d*1.0001)
I
])
result;
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
Hi Peter,
Adrian was right, it is not such a big drama to compute the intersection
point of two extruded shapes, as long as they are somehow
"well-behaved". I extracted the relevant functions and modules from my
libraries and wrote your function *intersect(shape1, shape2, w1, w2)*
and some test stuff with generic OpenSCAD. Find the scad file attached.
The code is indeed quite neat and easy to understand. It computes the
affine intersection of freely translated and rotated 2D-shapes, which
are assumed to be endless in both directions.
The function calculates all planes of the faces that delimit shape2,
intersects each with all lines of shape1 and collects and returns only
those points that are situated on a face This means, two function calls
are needed to get hands on all intersection points. I leave it up to you
to sort the sets together. In most cases you will be fine just using the
richer set.
I didn't have the time to protect the code against instabilities, mostly
singularities from the dot product of two parallel vectors. As usual in
OpenSCAD tiny-angle rotations or tiny-value translations get you around,
as shown in the test code that produced the second example.
Hope this helps you along. I'm curious whether it will bring you forward
with the topology stuff in the paper.
Rudolf
// intersect two 2D shapes at an angle w
function intersect(Sh1, Sh2, w1=w1, w2=w2) =
let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
let(L1 = len(Sh1), L2=len(Sh2))
let(sign = L1<L2)
let(result =
[
for(i = [0:L2-1], j = [0:L1-1])
// define the current face of Sh2
let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
let(P3 = P1+N2, P4 = P2+N2)
let(d = norm(P1-P2))
// calc the intersection of all lines of Sh1 with current face of Sh2
let(A = Sh1[j], B = A+N1)
let(I = line_plane_intersection(A, B, P1, P2, P3))
let(dist1 = distance_point_to_line(P1, P3, I))
let(dist2 = distance_point_to_line(P2, P4, I))
// filter points that closely touch the face
if(dist1+dist2<=d*1.0001)
I
])
result;
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
PK
Peter Kriens
Wed, Mar 5, 2025 10:36 AM
I think I got the ambiguous cylinder to work ... more or less. The code from Rudolf was extremely helpful and taught me a lot about Openscad code. Thanks again. :-)
To start, a final result, viewed from both sides. Note the little hole, if you can see the hole on the other side, you're on the right angle.

The code Rudolf gave me resulted in the intersection path. However, this path is by its nature ambiguous (pun not intended). Rudolf used an algorithm to intersect each point in the two paths with the other shape. That can give multiple intersection.

What I needed, however, was the bottom of one side and the top of the other side of this 3D path. To be honest, I was ready to give up. However, when I looked on this path from the Z view, I noticed this:

Removing the points on the inside of this shape seems easier than decomposing the 3D path in its constituents. However, my expertise wasn't sufficient to write that code. Chat GPT gave me a function that used the area of the polygon. If you could remove a point of the path without changing its area it is safe to remove that point. However, I could not get this to work well. Looking at BOSL2 I thought union() might work but it didn't, even after I used a function to split it in multiple polygons. Then I found hull2D_path(). Disadvantage is that it uses hulling and that works only for convex shapes but my suspicion is that for this problem that is not a big issue. However, this seems such a common problem that it surprises me I could not find anything in BOSL2 that would do this cleanup for me? Anyway, after the hull2D_path I got:

After some confusion on my side, I realized that hull2D_path() returns indexes of the orinal path, not a new path. This turned out to be really useful since the 3D path from Rudolph for the top used exactly the same indexes! Using this index list, it was trivial to extract the top 3D points that formed its outline. So now I had a bottom (the 2D path) and a top (the 3D path). The 2D path was easy to convert to 3D with z=0.

These could now be given to skin():

Since the bottom 2D path was perfectly aligned with the top path, this works quite well. To remove the inside of the resulting shape, I offset the 2D bottom path to be a bit smaller and then used difference to remove it from the skinned part:

Along the way I had a scaffold to see what I was doing:

The shape functions are very sensitive to the shapes that are used and I usually get a 'non planar' image. The main issue during construction is with an assert in the line intersection algorithm, It says that lines are parallel (and this not intersect) and then gives up. I intuit this probably can be fixed. Clearly there are some constraints on the shapes. I probably could improve on this but time ran out ...
Feedback how to improve this are welcome.
Peter Kriens

let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
let(L1 = len(Sh1), L2=len(Sh2))
On 27 Feb 2025, at 22:28, Rudolf via Discuss discuss@lists.openscad.org wrote:
Hi Peter,
Adrian was right, it is not such a big drama to compute the intersection point of two extruded shapes, as long as they are somehow "well-behaved". I extracted the relevant functions and modules from my libraries and wrote your function intersect(shape1, shape2, w1, w2) and some test stuff with generic OpenSCAD. Find the scad file attached. The code is indeed quite neat and easy to understand. It computes the affine intersection of freely translated and rotated 2D-shapes, which are assumed to be endless in both directions.
The function calculates all planes of the faces that delimit shape2, intersects each with all lines of shape1 and collects and returns only those points that are situated on a face This means, two function calls are needed to get hands on all intersection points. I leave it up to you to sort the sets together. In most cases you will be fine just using the richer set.
I didn't have the time to protect the code against instabilities, mostly singularities from the dot product of two parallel vectors. As usual in OpenSCAD tiny-angle rotations or tiny-value translations get you around, as shown in the test code that produced the second example.
Hope this helps you along. I'm curious whether it will bring you forward with the topology stuff in the paper.
Rudolf
// intersect two 2D shapes at an angle w
function intersect(Sh1, Sh2, w1=w1, w2=w2) =
let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
let(L1 = len(Sh1), L2=len(Sh2))
let(sign = L1<L2)
let(result =
[
for(i = [0:L2-1], j = [0:L1-1])
// define the current face of Sh2
let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
let(P3 = P1+N2, P4 = P2+N2)
let(d = norm(P1-P2))
// calc the intersection of all lines of Sh1 with current face of Sh2
let(A = Sh1[j], B = A+N1)
let(I = line_plane_intersection(A, B, P1, P2, P3))
let(dist1 = distance_point_to_line(P1, P3, I))
let(dist2 = distance_point_to_line(P2, P4, I))
// filter points that closely touch the face
if(dist1+dist2<=d*1.0001)
I
])
result;
<nGpKKGbcKaEzok3B.png>
<ZcA2AgZ5byJR3asr.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
I think I got the ambiguous cylinder to work ... more or less. The code from Rudolf was extremely helpful and taught me a lot about Openscad code. Thanks again. :-)
To start, a final result, viewed from both sides. Note the little hole, if you can see the hole on the other side, you're on the right angle.

The code Rudolf gave me resulted in the intersection path. However, this path is by its nature ambiguous (pun not intended). Rudolf used an algorithm to intersect each point in the two paths with the other shape. That can give multiple intersection.

What I needed, however, was the bottom of one side and the top of the other side of this 3D path. To be honest, I was ready to give up. However, when I looked on this path from the Z view, I noticed this:

Removing the points on the inside of this shape seems easier than decomposing the 3D path in its constituents. However, my expertise wasn't sufficient to write that code. Chat GPT gave me a function that used the area of the polygon. If you could remove a point of the path without changing its area it is safe to remove that point. However, I could not get this to work well. Looking at BOSL2 I thought union() might work but it didn't, even after I used a function to split it in multiple polygons. Then I found hull2D_path(). Disadvantage is that it uses hulling and that works only for convex shapes but my suspicion is that for this problem that is not a big issue. However, this seems such a common problem that it surprises me I could not find anything in BOSL2 that would do this cleanup for me? Anyway, after the hull2D_path I got:

After some confusion on my side, I realized that hull2D_path() returns indexes of the orinal path, not a new path. This turned out to be really useful since the 3D path from Rudolph for the top used exactly the same indexes! Using this index list, it was trivial to extract the top 3D points that formed its outline. So now I had a bottom (the 2D path) and a top (the 3D path). The 2D path was easy to convert to 3D with z=0.

These could now be given to skin():

Since the bottom 2D path was perfectly aligned with the top path, this works quite well. To remove the inside of the resulting shape, I offset the 2D bottom path to be a bit smaller and then used difference to remove it from the skinned part:

Along the way I had a scaffold to see what I was doing:

The shape functions are very sensitive to the shapes that are used and I usually get a 'non planar' image. The main issue during construction is with an assert in the line intersection algorithm, It says that lines are parallel (and this not intersect) and then gives up. I intuit this probably can be fixed. Clearly there are some constraints on the shapes. I probably could improve on this but time ran out ...
Feedback how to improve this are welcome.
Peter Kriens

> let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
> let(L1 = len(Sh1), L2=len(Sh2))
>
> On 27 Feb 2025, at 22:28, Rudolf via Discuss <discuss@lists.openscad.org> wrote:
>
> Hi Peter,
>
> Adrian was right, it is not such a big drama to compute the intersection point of two extruded shapes, as long as they are somehow "well-behaved". I extracted the relevant functions and modules from my libraries and wrote your function intersect(shape1, shape2, w1, w2) and some test stuff with generic OpenSCAD. Find the scad file attached. The code is indeed quite neat and easy to understand. It computes the affine intersection of freely translated and rotated 2D-shapes, which are assumed to be endless in both directions.
>
> The function calculates all planes of the faces that delimit shape2, intersects each with all lines of shape1 and collects and returns only those points that are situated on a face This means, two function calls are needed to get hands on all intersection points. I leave it up to you to sort the sets together. In most cases you will be fine just using the richer set.
>
> I didn't have the time to protect the code against instabilities, mostly singularities from the dot product of two parallel vectors. As usual in OpenSCAD tiny-angle rotations or tiny-value translations get you around, as shown in the test code that produced the second example.
>
> Hope this helps you along. I'm curious whether it will bring you forward with the topology stuff in the paper.
>
> Rudolf
>
> // intersect two 2D shapes at an angle w
> function intersect(Sh1, Sh2, w1=w1, w2=w2) =
> let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
> let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
> let(L1 = len(Sh1), L2=len(Sh2))
> let(sign = L1<L2)
> let(result =
> [
> for(i = [0:L2-1], j = [0:L1-1])
> // define the current face of Sh2
> let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
> let(P3 = P1+N2, P4 = P2+N2)
> let(d = norm(P1-P2))
>
> // calc the intersection of all lines of Sh1 with current face of Sh2
> let(A = Sh1[j], B = A+N1)
> let(I = line_plane_intersection(A, B, P1, P2, P3))
> let(dist1 = distance_point_to_line(P1, P3, I))
> let(dist2 = distance_point_to_line(P2, P4, I))
> // filter points that closely touch the face
> if(dist1+dist2<=d*1.0001)
> I
> ])
> result;
>
>
> <nGpKKGbcKaEzok3B.png>
>
>
>
> <ZcA2AgZ5byJR3asr.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>
> <intersection.scad>_______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
GS
Guenther Sohler
Wed, Mar 5, 2025 10:53 AM
In PythonSCAD (and potentially soon in OpenSCAD) you could
- output mesh on Object A and create a list of edges
- output mesh on Object B and create a list of edges
- union/difference Object A with B , output mesh and create list of edges
- select Set of Edges from 3 which are neither in included in 1) nor 2)
- sum up the lengths of Edges from 4)
my little 2 cents. I use exactly that algorithm for filling the cut line of
2 objects
On Thu, Feb 27, 2025 at 10:28 PM Rudolf via Discuss <
discuss@lists.openscad.org> wrote:
Hi Peter,
Adrian was right, it is not such a big drama to compute the intersection
point of two extruded shapes, as long as they are somehow "well-behaved". I
extracted the relevant functions and modules from my libraries and wrote
your function intersect(shape1, shape2, w1, w2) and some test stuff
with generic OpenSCAD. Find the scad file attached. The code is indeed
quite neat and easy to understand. It computes the affine intersection of
freely translated and rotated 2D-shapes, which are assumed to be endless in
both directions.
The function calculates all planes of the faces that delimit shape2,
intersects each with all lines of shape1 and collects and returns only
those points that are situated on a face This means, two function calls are
needed to get hands on all intersection points. I leave it up to you to
sort the sets together. In most cases you will be fine just using the
richer set.
I didn't have the time to protect the code against instabilities, mostly
singularities from the dot product of two parallel vectors. As usual in
OpenSCAD tiny-angle rotations or tiny-value translations get you around, as
shown in the test code that produced the second example.
Hope this helps you along. I'm curious whether it will bring you forward
with the topology stuff in the paper.
Rudolf
// intersect two 2D shapes at an angle w
function intersect(Sh1, Sh2, w1=w1, w2=w2) =
let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
let(L1 = len(Sh1), L2=len(Sh2))
let(sign = L1<L2)
let(result =
[
for(i = [0:L2-1], j = [0:L1-1])
// define the current face of Sh2
let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
let(P3 = P1+N2, P4 = P2+N2)
let(d = norm(P1-P2))
// calc the intersection of all lines of Sh1 with current face of Sh2
let(A = Sh1[j], B = A+N1)
let(I = line_plane_intersection(A, B, P1, P2, P3))
let(dist1 = distance_point_to_line(P1, P3, I))
let(dist2 = distance_point_to_line(P2, P4, I))
// filter points that closely touch the face
if(dist1+dist2<=d*1.0001)
I
])
result;
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
In PythonSCAD (and potentially soon in OpenSCAD) you could
1) output mesh on Object A and create a list of edges
2) output mesh on Object B and create a list of edges
3) union/difference Object A with B , output mesh and create list of edges
4) select Set of Edges from 3 which are neither in included in 1) nor 2)
5) sum up the lengths of Edges from 4)
my little 2 cents. I use exactly that algorithm for filling the cut line of
2 objects
On Thu, Feb 27, 2025 at 10:28 PM Rudolf via Discuss <
discuss@lists.openscad.org> wrote:
> Hi Peter,
>
> Adrian was right, it is not such a big drama to compute the intersection
> point of two extruded shapes, as long as they are somehow "well-behaved". I
> extracted the relevant functions and modules from my libraries and wrote
> your function *intersect(shape1, shape2, w1, w2)* and some test stuff
> with generic OpenSCAD. Find the scad file attached. The code is indeed
> quite neat and easy to understand. It computes the affine intersection of
> freely translated and rotated 2D-shapes, which are assumed to be endless in
> both directions.
>
> The function calculates all planes of the faces that delimit shape2,
> intersects each with all lines of shape1 and collects and returns only
> those points that are situated on a face This means, two function calls are
> needed to get hands on all intersection points. I leave it up to you to
> sort the sets together. In most cases you will be fine just using the
> richer set.
>
> I didn't have the time to protect the code against instabilities, mostly
> singularities from the dot product of two parallel vectors. As usual in
> OpenSCAD tiny-angle rotations or tiny-value translations get you around, as
> shown in the test code that produced the second example.
>
> Hope this helps you along. I'm curious whether it will bring you forward
> with the topology stuff in the paper.
>
> Rudolf
>
> // intersect two 2D shapes at an angle w
> function intersect(Sh1, Sh2, w1=w1, w2=w2) =
> let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
> let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
> let(L1 = len(Sh1), L2=len(Sh2))
> let(sign = L1<L2)
> let(result =
> [
> for(i = [0:L2-1], j = [0:L1-1])
> // define the current face of Sh2
> let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
> let(P3 = P1+N2, P4 = P2+N2)
> let(d = norm(P1-P2))
>
> // calc the intersection of all lines of Sh1 with current face of Sh2
> let(A = Sh1[j], B = A+N1)
> let(I = line_plane_intersection(A, B, P1, P2, P3))
> let(dist1 = distance_point_to_line(P1, P3, I))
> let(dist2 = distance_point_to_line(P2, P4, I))
> // filter points that closely touch the face
> if(dist1+dist2<=d*1.0001)
> I
> ])
> result;
>
>
>
> 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
>
PK
Peter Kriens
Fri, Mar 7, 2025 8:21 AM
I am having one more problem and I can't seem to find a good solution.
I have a closed 3D path. How do I make this into a wall that descents to the z=0? The problem is that the top must have the Z-variances so extrudes seem out of the questions. I want the top of the wall to be flat and be able to parameterize its overall thickness (the current algorithm that uses difference() can create very steep walls when angles are high.)

Is there any function in BOSL2 that can do this?
Peter
On 5 Mar 2025, at 11:53, Guenther Sohler via Discuss discuss@lists.openscad.org wrote:
In PythonSCAD (and potentially soon in OpenSCAD) you could
- output mesh on Object A and create a list of edges
- output mesh on Object B and create a list of edges
- union/difference Object A with B , output mesh and create list of edges
- select Set of Edges from 3 which are neither in included in 1) nor 2)
- sum up the lengths of Edges from 4)
my little 2 cents. I use exactly that algorithm for filling the cut line of 2 objects
On Thu, Feb 27, 2025 at 10:28 PM Rudolf via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:
Hi Peter,
Adrian was right, it is not such a big drama to compute the intersection point of two extruded shapes, as long as they are somehow "well-behaved". I extracted the relevant functions and modules from my libraries and wrote your function intersect(shape1, shape2, w1, w2) and some test stuff with generic OpenSCAD. Find the scad file attached. The code is indeed quite neat and easy to understand. It computes the affine intersection of freely translated and rotated 2D-shapes, which are assumed to be endless in both directions.
The function calculates all planes of the faces that delimit shape2, intersects each with all lines of shape1 and collects and returns only those points that are situated on a face This means, two function calls are needed to get hands on all intersection points. I leave it up to you to sort the sets together. In most cases you will be fine just using the richer set.
I didn't have the time to protect the code against instabilities, mostly singularities from the dot product of two parallel vectors. As usual in OpenSCAD tiny-angle rotations or tiny-value translations get you around, as shown in the test code that produced the second example.
Hope this helps you along. I'm curious whether it will bring you forward with the topology stuff in the paper.
Rudolf
// intersect two 2D shapes at an angle w
function intersect(Sh1, Sh2, w1=w1, w2=w2) =
let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
let(L1 = len(Sh1), L2=len(Sh2))
let(sign = L1<L2)
let(result =
[
for(i = [0:L2-1], j = [0:L1-1])
// define the current face of Sh2
let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
let(P3 = P1+N2, P4 = P2+N2)
let(d = norm(P1-P2))
// calc the intersection of all lines of Sh1 with current face of Sh2
let(A = Sh1[j], B = A+N1)
let(I = line_plane_intersection(A, B, P1, P2, P3))
let(dist1 = distance_point_to_line(P1, P3, I))
let(dist2 = distance_point_to_line(P2, P4, I))
// filter points that closely touch the face
if(dist1+dist2<=d*1.0001)
I
])
result;
<nGpKKGbcKaEzok3B.png>
<ZcA2AgZ5byJR3asr.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
I am having one more problem and I can't seem to find a good solution.
I have a closed 3D path. How do I make this into a wall that descents to the z=0? The problem is that the top must have the Z-variances so extrudes seem out of the questions. I want the top of the wall to be flat and be able to parameterize its overall thickness (the current algorithm that uses difference() can create very steep walls when angles are high.)

Is there any function in BOSL2 that can do this?
Peter
> On 5 Mar 2025, at 11:53, Guenther Sohler via Discuss <discuss@lists.openscad.org> wrote:
>
> In PythonSCAD (and potentially soon in OpenSCAD) you could
>
> 1) output mesh on Object A and create a list of edges
> 2) output mesh on Object B and create a list of edges
> 3) union/difference Object A with B , output mesh and create list of edges
> 4) select Set of Edges from 3 which are neither in included in 1) nor 2)
> 5) sum up the lengths of Edges from 4)
>
> my little 2 cents. I use exactly that algorithm for filling the cut line of 2 objects
>
>
>
>
>
> On Thu, Feb 27, 2025 at 10:28 PM Rudolf via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote:
>> Hi Peter,
>>
>> Adrian was right, it is not such a big drama to compute the intersection point of two extruded shapes, as long as they are somehow "well-behaved". I extracted the relevant functions and modules from my libraries and wrote your function intersect(shape1, shape2, w1, w2) and some test stuff with generic OpenSCAD. Find the scad file attached. The code is indeed quite neat and easy to understand. It computes the affine intersection of freely translated and rotated 2D-shapes, which are assumed to be endless in both directions.
>>
>> The function calculates all planes of the faces that delimit shape2, intersects each with all lines of shape1 and collects and returns only those points that are situated on a face This means, two function calls are needed to get hands on all intersection points. I leave it up to you to sort the sets together. In most cases you will be fine just using the richer set.
>>
>> I didn't have the time to protect the code against instabilities, mostly singularities from the dot product of two parallel vectors. As usual in OpenSCAD tiny-angle rotations or tiny-value translations get you around, as shown in the test code that produced the second example.
>>
>> Hope this helps you along. I'm curious whether it will bring you forward with the topology stuff in the paper.
>>
>> Rudolf
>>
>> // intersect two 2D shapes at an angle w
>> function intersect(Sh1, Sh2, w1=w1, w2=w2) =
>> let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
>> let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
>> let(L1 = len(Sh1), L2=len(Sh2))
>> let(sign = L1<L2)
>> let(result =
>> [
>> for(i = [0:L2-1], j = [0:L1-1])
>> // define the current face of Sh2
>> let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
>> let(P3 = P1+N2, P4 = P2+N2)
>> let(d = norm(P1-P2))
>>
>> // calc the intersection of all lines of Sh1 with current face of Sh2
>> let(A = Sh1[j], B = A+N1)
>> let(I = line_plane_intersection(A, B, P1, P2, P3))
>> let(dist1 = distance_point_to_line(P1, P3, I))
>> let(dist2 = distance_point_to_line(P2, P4, I))
>> // filter points that closely touch the face
>> if(dist1+dist2<=d*1.0001)
>> I
>> ])
>> result;
>>
>>
>> <nGpKKGbcKaEzok3B.png>
>>
>>
>>
>> <ZcA2AgZ5byJR3asr.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
R
Rudolf
Fri, Mar 7, 2025 9:31 AM
not perfect, but I think viable in your case: you can calculate scalex,
scaley values for the 2D shape that keeps the wall thickness at least at
X and Y axis. Scaling only X,Y coordinates provides you an inner shape
with the same number of points and lets you build a sequence of squares
in the second step which you can use to do a circular extrude around Z
instead of linear extruding along Z.
Am 07.03.2025 um 09:21 schrieb Peter Kriens via Discuss:
I am having one more problem and I can't seem to find a good solution.
I have a closed 3D path. How do I make this into a wall that descents
to the z=0? The problem is that the top must have the Z-variances so
extrudes seem out of the questions. I want the top of the wall to be
flat and be able to parameterize its overall thickness (the current
algorithm that uses difference() can create very steep walls when
angles are high.)
PastedGraphic-7.pngPastedGraphic-9.png
Is there any function in BOSL2 that can do this?
Peter
On 5 Mar 2025, at 11:53, Guenther Sohler via Discuss
discuss@lists.openscad.org wrote:
In PythonSCAD (and potentially soon in OpenSCAD) you could
- output mesh on Object A and create a list of edges
- output mesh on Object B and create a list of edges
- union/difference Object A with B , output mesh and create list of
edges
- select Set of Edges from 3 which are neither in included in 1)
nor 2)
- sum up the lengths of Edges from 4)
my little 2 cents. I use exactly that algorithm for filling the cut
line of 2 objects
On Thu, Feb 27, 2025 at 10:28 PM Rudolf via Discuss
discuss@lists.openscad.org wrote:
Hi Peter,
Adrian was right, it is not such a big drama to compute the
intersection point of two extruded shapes, as long as they are
somehow "well-behaved". I extracted the relevant functions and
modules from my libraries and wrote your function
*intersect(shape1, shape2, w1, w2)* and some test stuff with
generic OpenSCAD. Find the scad file attached. The code is indeed
quite neat and easy to understand. It computes the affine
intersection of freely translated and rotated 2D-shapes, which
are assumed to be endless in both directions.
The function calculates all planes of the faces that delimit
shape2, intersects each with all lines of shape1 and collects and
returns only those points that are situated on a face This means,
two function calls are needed to get hands on all intersection
points. I leave it up to you to sort the sets together. In most
cases you will be fine just using the richer set.
I didn't have the time to protect the code against instabilities,
mostly singularities from the dot product of two parallel
vectors. As usual in OpenSCAD tiny-angle rotations or tiny-value
translations get you around, as shown in the test code that
produced the second example.
Hope this helps you along. I'm curious whether it will bring you
forward with the topology stuff in the paper.
Rudolf
// intersect two 2D shapes at an angle w
function intersect(Sh1, Sh2, w1=w1, w2=w2) =
let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
let(L1 = len(Sh1), L2=len(Sh2))
let(sign = L1<L2)
let(result =
[
for(i = [0:L2-1], j = [0:L1-1])
// define the current face of Sh2
let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
let(P3 = P1+N2, P4 = P2+N2)
let(d = norm(P1-P2))
// calc the intersection of all lines of Sh1 with current
face of Sh2
let(A = Sh1[j], B = A+N1)
let(I = line_plane_intersection(A, B, P1, P2, P3))
let(dist1 = distance_point_to_line(P1, P3, I))
let(dist2 = distance_point_to_line(P2, P4, I))
// filter points that closely touch the face
if(dist1+dist2<=d*1.0001)
I
])
result;
<nGpKKGbcKaEzok3B.png>
<ZcA2AgZ5byJR3asr.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 todiscuss-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
not perfect, but I think viable in your case: you can calculate scalex,
scaley values for the 2D shape that keeps the wall thickness at least at
X and Y axis. Scaling only X,Y coordinates provides you an inner shape
with the same number of points and lets you build a sequence of squares
in the second step which you can use to do a circular extrude around Z
instead of linear extruding along Z.
Am 07.03.2025 um 09:21 schrieb Peter Kriens via Discuss:
> I am having one more problem and I can't seem to find a good solution.
>
> I have a closed 3D path. How do I make this into a wall that descents
> to the z=0? The problem is that the top must have the Z-variances so
> extrudes seem out of the questions. I want the top of the wall to be
> flat and be able to parameterize its overall thickness (the current
> algorithm that uses difference() can create very steep walls when
> angles are high.)
>
> PastedGraphic-7.pngPastedGraphic-9.png
>
>
>
> Is there any function in BOSL2 that can do this?
>
> Peter
>
>
>> On 5 Mar 2025, at 11:53, Guenther Sohler via Discuss
>> <discuss@lists.openscad.org> wrote:
>>
>> In PythonSCAD (and potentially soon in OpenSCAD) you could
>>
>> 1) output mesh on Object A and create a list of edges
>> 2) output mesh on Object B and create a list of edges
>> 3) union/difference Object A with B , output mesh and create list of
>> edges
>> 4) select Set of Edges from 3 which are neither in included in 1)
>> nor 2)
>> 5) sum up the lengths of Edges from 4)
>>
>> my little 2 cents. I use exactly that algorithm for filling the cut
>> line of 2 objects
>>
>>
>>
>>
>>
>> On Thu, Feb 27, 2025 at 10:28 PM Rudolf via Discuss
>> <discuss@lists.openscad.org> wrote:
>>
>> Hi Peter,
>>
>> Adrian was right, it is not such a big drama to compute the
>> intersection point of two extruded shapes, as long as they are
>> somehow "well-behaved". I extracted the relevant functions and
>> modules from my libraries and wrote your function
>> *intersect(shape1, shape2, w1, w2)* and some test stuff with
>> generic OpenSCAD. Find the scad file attached. The code is indeed
>> quite neat and easy to understand. It computes the affine
>> intersection of freely translated and rotated 2D-shapes, which
>> are assumed to be endless in both directions.
>>
>> The function calculates all planes of the faces that delimit
>> shape2, intersects each with all lines of shape1 and collects and
>> returns only those points that are situated on a face This means,
>> two function calls are needed to get hands on all intersection
>> points. I leave it up to you to sort the sets together. In most
>> cases you will be fine just using the richer set.
>>
>> I didn't have the time to protect the code against instabilities,
>> mostly singularities from the dot product of two parallel
>> vectors. As usual in OpenSCAD tiny-angle rotations or tiny-value
>> translations get you around, as shown in the test code that
>> produced the second example.
>>
>> Hope this helps you along. I'm curious whether it will bring you
>> forward with the topology stuff in the paper.
>>
>> Rudolf
>>
>> // intersect two 2D shapes at an angle w
>> function intersect(Sh1, Sh2, w1=w1, w2=w2) =
>> let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
>> let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
>> let(L1 = len(Sh1), L2=len(Sh2))
>> let(sign = L1<L2)
>> let(result =
>> [
>> for(i = [0:L2-1], j = [0:L1-1])
>> // define the current face of Sh2
>> let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
>> let(P3 = P1+N2, P4 = P2+N2)
>> let(d = norm(P1-P2))
>>
>> // calc the intersection of all lines of Sh1 with current
>> face of Sh2
>> let(A = Sh1[j], B = A+N1)
>> let(I = line_plane_intersection(A, B, P1, P2, P3))
>> let(dist1 = distance_point_to_line(P1, P3, I))
>> let(dist2 = distance_point_to_line(P2, P4, I))
>> // filter points that closely touch the face
>> if(dist1+dist2<=d*1.0001)
>> I
>> ])
>> result;
>>
>>
>> <nGpKKGbcKaEzok3B.png>
>>
>>
>> <ZcA2AgZ5byJR3asr.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 todiscuss-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 todiscuss-leave@lists.openscad.org
DP
Dan Perry
Fri, Mar 7, 2025 10:13 AM
This would be my solution:
- Take the x-y values from your 3d path as the exterior of the solution.
- Use offset() to create the interior. offset(exterior,
delta=-wall_thickness, closed=true);
- Difference() 2 from 1 and linear_extrude() to max z-height.
- Take the x-z values from your 3d path, linear_extrude, rotate and
translate it, then difference() it to cut the top to your desired shape.
Dan
On Fri, Mar 7, 2025 at 8:21 AM Peter Kriens via Discuss <
discuss@lists.openscad.org> wrote:
I am having one more problem and I can't seem to find a good solution.
I have a closed 3D path. How do I make this into a wall that descents to
the z=0? The problem is that the top must have the Z-variances so extrudes
seem out of the questions. I want the top of the wall to be flat and be
able to parameterize its overall thickness (the current algorithm that uses
difference() can create very steep walls when angles are high.)
[image: PastedGraphic-7.png][image: PastedGraphic-9.png]
Is there any function in BOSL2 that can do this?
Peter
On 5 Mar 2025, at 11:53, Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:
In PythonSCAD (and potentially soon in OpenSCAD) you could
- output mesh on Object A and create a list of edges
- output mesh on Object B and create a list of edges
- union/difference Object A with B , output mesh and create list of edges
- select Set of Edges from 3 which are neither in included in 1) nor 2)
- sum up the lengths of Edges from 4)
my little 2 cents. I use exactly that algorithm for filling the cut line
of 2 objects
On Thu, Feb 27, 2025 at 10:28 PM Rudolf via Discuss <
discuss@lists.openscad.org> wrote:
Hi Peter,
Adrian was right, it is not such a big drama to compute the intersection
point of two extruded shapes, as long as they are somehow "well-behaved". I
extracted the relevant functions and modules from my libraries and wrote
your function intersect(shape1, shape2, w1, w2) and some test stuff
with generic OpenSCAD. Find the scad file attached. The code is indeed
quite neat and easy to understand. It computes the affine intersection of
freely translated and rotated 2D-shapes, which are assumed to be endless in
both directions.
The function calculates all planes of the faces that delimit shape2,
intersects each with all lines of shape1 and collects and returns only
those points that are situated on a face This means, two function calls are
needed to get hands on all intersection points. I leave it up to you to
sort the sets together. In most cases you will be fine just using the
richer set.
I didn't have the time to protect the code against instabilities, mostly
singularities from the dot product of two parallel vectors. As usual in
OpenSCAD tiny-angle rotations or tiny-value translations get you around, as
shown in the test code that produced the second example.
Hope this helps you along. I'm curious whether it will bring you forward
with the topology stuff in the paper.
Rudolf
// intersect two 2D shapes at an angle w
function intersect(Sh1, Sh2, w1=w1, w2=w2) =
let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
let(L1 = len(Sh1), L2=len(Sh2))
let(sign = L1<L2)
let(result =
[
for(i = [0:L2-1], j = [0:L1-1])
// define the current face of Sh2
let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
let(P3 = P1+N2, P4 = P2+N2)
let(d = norm(P1-P2))
// calc the intersection of all lines of Sh1 with current face of Sh2
let(A = Sh1[j], B = A+N1)
let(I = line_plane_intersection(A, B, P1, P2, P3))
let(dist1 = distance_point_to_line(P1, P3, I))
let(dist2 = distance_point_to_line(P2, P4, I))
// filter points that closely touch the face
if(dist1+dist2<=d*1.0001)
I
])
result;
<nGpKKGbcKaEzok3B.png>
<ZcA2AgZ5byJR3asr.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
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
This would be my solution:
1. Take the x-y values from your 3d path as the exterior of the solution.
2. Use offset() to create the interior. offset(exterior,
delta=-wall_thickness, closed=true);
3. Difference() 2 from 1 and linear_extrude() to max z-height.
4. Take the x-z values from your 3d path, linear_extrude, rotate and
translate it, then difference() it to cut the top to your desired shape.
Dan
On Fri, Mar 7, 2025 at 8:21 AM Peter Kriens via Discuss <
discuss@lists.openscad.org> wrote:
> I am having one more problem and I can't seem to find a good solution.
>
> I have a closed 3D path. How do I make this into a wall that descents to
> the z=0? The problem is that the top must have the Z-variances so extrudes
> seem out of the questions. I want the top of the wall to be flat and be
> able to parameterize its overall thickness (the current algorithm that uses
> difference() can create very steep walls when angles are high.)
>
> [image: PastedGraphic-7.png][image: PastedGraphic-9.png]
>
>
>
> Is there any function in BOSL2 that can do this?
>
> Peter
>
>
> On 5 Mar 2025, at 11:53, Guenther Sohler via Discuss <
> discuss@lists.openscad.org> wrote:
>
> In PythonSCAD (and potentially soon in OpenSCAD) you could
>
> 1) output mesh on Object A and create a list of edges
> 2) output mesh on Object B and create a list of edges
> 3) union/difference Object A with B , output mesh and create list of edges
> 4) select Set of Edges from 3 which are neither in included in 1) nor 2)
> 5) sum up the lengths of Edges from 4)
>
> my little 2 cents. I use exactly that algorithm for filling the cut line
> of 2 objects
>
>
>
>
>
> On Thu, Feb 27, 2025 at 10:28 PM Rudolf via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> Hi Peter,
>>
>> Adrian was right, it is not such a big drama to compute the intersection
>> point of two extruded shapes, as long as they are somehow "well-behaved". I
>> extracted the relevant functions and modules from my libraries and wrote
>> your function *intersect(shape1, shape2, w1, w2)* and some test stuff
>> with generic OpenSCAD. Find the scad file attached. The code is indeed
>> quite neat and easy to understand. It computes the affine intersection of
>> freely translated and rotated 2D-shapes, which are assumed to be endless in
>> both directions.
>>
>> The function calculates all planes of the faces that delimit shape2,
>> intersects each with all lines of shape1 and collects and returns only
>> those points that are situated on a face This means, two function calls are
>> needed to get hands on all intersection points. I leave it up to you to
>> sort the sets together. In most cases you will be fine just using the
>> richer set.
>>
>> I didn't have the time to protect the code against instabilities, mostly
>> singularities from the dot product of two parallel vectors. As usual in
>> OpenSCAD tiny-angle rotations or tiny-value translations get you around, as
>> shown in the test code that produced the second example.
>>
>> Hope this helps you along. I'm curious whether it will bring you forward
>> with the topology stuff in the paper.
>>
>> Rudolf
>>
>> // intersect two 2D shapes at an angle w
>> function intersect(Sh1, Sh2, w1=w1, w2=w2) =
>> let(Sh1 = Rx(w1, Sh1), Sh2 = Rx(w2, Sh2))
>> let(N1 = Rx(w1, [0,0,1]), N2 = Rx(w2, [0,0,1]))
>> let(L1 = len(Sh1), L2=len(Sh2))
>> let(sign = L1<L2)
>> let(result =
>> [
>> for(i = [0:L2-1], j = [0:L1-1])
>> // define the current face of Sh2
>> let(P1 = Sh2[i], P2=Sh2[(i+1)%L2])
>> let(P3 = P1+N2, P4 = P2+N2)
>> let(d = norm(P1-P2))
>>
>> // calc the intersection of all lines of Sh1 with current face of Sh2
>> let(A = Sh1[j], B = A+N1)
>> let(I = line_plane_intersection(A, B, P1, P2, P3))
>> let(dist1 = distance_point_to_line(P1, P3, I))
>> let(dist2 = distance_point_to_line(P2, P4, I))
>> // filter points that closely touch the face
>> if(dist1+dist2<=d*1.0001)
>> I
>> ])
>> result;
>>
>> <nGpKKGbcKaEzok3B.png>
>>
>>
>> <ZcA2AgZ5byJR3asr.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
>>
>> _______________________________________________
>> 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
>