discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

flattening curved surfaces

J
jon
Sun, Dec 25, 2016 12:39 AM

I have a bit of code at the end of this question.  It produces a shape
with 4 curved sides, each of which lies on the surface of a cylinder.
Note that this is an example shape: I want to work with families of
similar shapes, not just with this one example.

I would like a way to take each of the 4 surfaces and produce a 2D shape
that, when cut out and bent, would conform to the original surface.  The
idea is to be able to create the original shape out of, say, cardboard
by cutting out the 4 2D shapes and then taping them together.

I have a conceptual idea of how this would be done in a traditional
programming language if I had a list of the coordinates along each of
the 4 boundary lines.  I considered re-writing the code, below, as a
sweep, and generating the coordinates explicitly, but a) that is not
trivial (to me), and ii) I want to solve the more general case where the
equations that determine the shape are not known.  I looked at the
generated STL file, and the coordinates are there, but not organized in
the way that I would want them to be.

This may be more effort than I want to expend, but I wondered if anyone
had a brilliant insight.

Thanks!

Jon

le = 10;    // length
d1 = 25;    // diameter of top
d2 = 35;    // diameter of bottom
d  = -8;    // delta to drop center of bottom

$fn = 100;

module shape() {
translate([0, 0, -6])
intersection() {
translate([-le/2, 0, 0])
difference() {
rotate([0, 90, 0])
cylinder(h = le, d = d1);
translate([-1, 0, d])
rotate([0, 90, 0])
cylinder(h = le + 2, d = d2);
}

         intersection() {
             translate([10, 0, 0])
                 cylinder(h = 100, d = 30);
             translate([-10, 0, 0])
                 cylinder(h = 100, d = 30);
             }
         }
     }

shape();

*difference() {
shape();
translate([0, 0, -4])
scale([0.8, 0.8, 2])
shape();
}

I have a bit of code at the end of this question. It produces a shape with 4 curved sides, each of which lies on the surface of a cylinder. Note that this is an example shape: I want to work with families of similar shapes, not just with this one example. I would like a way to take each of the 4 surfaces and produce a 2D shape that, when cut out and bent, would conform to the original surface. The idea is to be able to create the original shape out of, say, cardboard by cutting out the 4 2D shapes and then taping them together. I have a conceptual idea of how this would be done in a traditional programming language if I had a list of the coordinates along each of the 4 boundary lines. I considered re-writing the code, below, as a sweep, and generating the coordinates explicitly, but a) that is not trivial (to me), and ii) I want to solve the more general case where the equations that determine the shape are not known. I looked at the generated STL file, and the coordinates are there, but not organized in the way that I would want them to be. This may be more effort than I want to expend, but I wondered if anyone had a brilliant insight. Thanks! Jon le = 10; // length d1 = 25; // diameter of top d2 = 35; // diameter of bottom d = -8; // delta to drop center of bottom $fn = 100; module shape() { translate([0, 0, -6]) intersection() { translate([-le/2, 0, 0]) difference() { rotate([0, 90, 0]) cylinder(h = le, d = d1); translate([-1, 0, d]) rotate([0, 90, 0]) cylinder(h = le + 2, d = d2); } intersection() { translate([10, 0, 0]) cylinder(h = 100, d = 30); translate([-10, 0, 0]) cylinder(h = 100, d = 30); } } } shape(); *difference() { shape(); translate([0, 0, -4]) scale([0.8, 0.8, 2]) shape(); }
FV
Frank van der Hulst
Sun, Dec 25, 2016 1:30 AM

You might want to look at map projections... cartographers have been
working on this for centuries  (for the oblate spheroid class of surfaces).

On 25/12/2016 13:40, "jon" jon@jonbondy.com wrote:

I have a bit of code at the end of this question.  It produces a shape
with 4 curved sides, each of which lies on the surface of a cylinder.  Note
that this is an example shape: I want to work with families of similar
shapes, not just with this one example.

I would like a way to take each of the 4 surfaces and produce a 2D shape
that, when cut out and bent, would conform to the original surface.  The
idea is to be able to create the original shape out of, say, cardboard by
cutting out the 4 2D shapes and then taping them together.

I have a conceptual idea of how this would be done in a traditional
programming language if I had a list of the coordinates along each of the 4
boundary lines.  I considered re-writing the code, below, as a sweep, and
generating the coordinates explicitly, but a) that is not trivial (to me),
and ii) I want to solve the more general case where the equations that
determine the shape are not known.  I looked at the generated STL file, and
the coordinates are there, but not organized in the way that I would want
them to be.

This may be more effort than I want to expend, but I wondered if anyone
had a brilliant insight.

Thanks!

Jon

le = 10;    // length
d1 = 25;    // diameter of top
d2 = 35;    // diameter of bottom
d  = -8;    // delta to drop center of bottom

$fn = 100;

module shape() {
translate([0, 0, -6])
intersection() {
translate([-le/2, 0, 0])
difference() {
rotate([0, 90, 0])
cylinder(h = le, d = d1);
translate([-1, 0, d])
rotate([0, 90, 0])
cylinder(h = le + 2, d = d2);
}

         intersection() {
             translate([10, 0, 0])
                 cylinder(h = 100, d = 30);
             translate([-10, 0, 0])
                 cylinder(h = 100, d = 30);
             }
         }
     }

shape();

*difference() {
shape();
translate([0, 0, -4])
scale([0.8, 0.8, 2])
shape();
}


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

You might want to look at map projections... cartographers have been working on this for centuries (for the oblate spheroid class of surfaces). On 25/12/2016 13:40, "jon" <jon@jonbondy.com> wrote: > I have a bit of code at the end of this question. It produces a shape > with 4 curved sides, each of which lies on the surface of a cylinder. Note > that this is an example shape: I want to work with families of similar > shapes, not just with this one example. > > I would like a way to take each of the 4 surfaces and produce a 2D shape > that, when cut out and bent, would conform to the original surface. The > idea is to be able to create the original shape out of, say, cardboard by > cutting out the 4 2D shapes and then taping them together. > > I have a conceptual idea of how this would be done in a traditional > programming language if I had a list of the coordinates along each of the 4 > boundary lines. I considered re-writing the code, below, as a sweep, and > generating the coordinates explicitly, but a) that is not trivial (to me), > and ii) I want to solve the more general case where the equations that > determine the shape are not known. I looked at the generated STL file, and > the coordinates are there, but not organized in the way that I would want > them to be. > > This may be more effort than I want to expend, but I wondered if anyone > had a brilliant insight. > > Thanks! > > Jon > > > le = 10; // length > d1 = 25; // diameter of top > d2 = 35; // diameter of bottom > d = -8; // delta to drop center of bottom > > $fn = 100; > > module shape() { > translate([0, 0, -6]) > intersection() { > translate([-le/2, 0, 0]) > difference() { > rotate([0, 90, 0]) > cylinder(h = le, d = d1); > translate([-1, 0, d]) > rotate([0, 90, 0]) > cylinder(h = le + 2, d = d2); > } > > intersection() { > translate([10, 0, 0]) > cylinder(h = 100, d = 30); > translate([-10, 0, 0]) > cylinder(h = 100, d = 30); > } > } > } > > shape(); > > *difference() { > shape(); > translate([0, 0, -4]) > scale([0.8, 0.8, 2]) > shape(); > } > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
CA
Carsten Arnholm
Sun, Dec 25, 2016 1:46 AM

On 25. des. 2016 01:39, jon wrote:

I have a conceptual idea of how this would be done in a traditional
programming language if I had a list of the coordinates along each of
the 4 boundary lines.  I considered re-writing the code, below, as a
sweep, and generating the coordinates explicitly, but a) that is not
trivial (to me), and ii) I want to solve the more general case where the
equations that determine the shape are not known.  I looked at the
generated STL file, and the coordinates are there, but not organized in
the way that I would want them to be.

Whether your idea is really worth pursuing is a issue in itself, but if
you want to try it is probably easier to export to AMF, OpenSCAD can do
it. https://en.wikipedia.org/wiki/Additive_Manufacturing_File_Format

AMF is an XML file format containing the result of booleans in a form
very similar to an OpenSCAD polyhedron, with unique vertices separate
from the (triangular) faces and each face defined as 3 vertex indices.
This means you have topology to work with, not just a "polygon soup" as
in STL. With STL you would have to rediscover a topology first, a
non-trivial task in the general case.

So in principle, using a traditional programming language, you could
read the AMF and detect the "boundary lines" by evaluating the angles
between neighbouring faces (finding neighbouring faces requires topology
evaluation). That would be just the start of another non-trivial task to
detect the faces bound by those boundaries. It could certainly succeed,
but a general solution would take quite some effort.

Using only OpenSCAD, something like that is not possible at all, since
there is no way in the language to access the vertices and faces of the
result of a boolean operation.

Carsten Arnholm

On 25. des. 2016 01:39, jon wrote: > I have a conceptual idea of how this would be done in a traditional > programming language if I had a list of the coordinates along each of > the 4 boundary lines. I considered re-writing the code, below, as a > sweep, and generating the coordinates explicitly, but a) that is not > trivial (to me), and ii) I want to solve the more general case where the > equations that determine the shape are not known. I looked at the > generated STL file, and the coordinates are there, but not organized in > the way that I would want them to be. Whether your idea is really worth pursuing is a issue in itself, but if you want to try it is probably easier to export to AMF, OpenSCAD can do it. https://en.wikipedia.org/wiki/Additive_Manufacturing_File_Format AMF is an XML file format containing the result of booleans in a form very similar to an OpenSCAD polyhedron, with unique vertices separate from the (triangular) faces and each face defined as 3 vertex indices. This means you have topology to work with, not just a "polygon soup" as in STL. With STL you would have to rediscover a topology first, a non-trivial task in the general case. So in principle, using a traditional programming language, you could read the AMF and detect the "boundary lines" by evaluating the angles between neighbouring faces (finding neighbouring faces requires topology evaluation). That would be just the start of another non-trivial task to detect the faces bound by those boundaries. It could certainly succeed, but a general solution would take quite some effort. Using only OpenSCAD, something like that is not possible at all, since there is no way in the language to access the vertices and faces of the result of a boolean operation. Carsten Arnholm
J
jon
Sun, Dec 25, 2016 1:52 AM

That was not the answer I was hoping for, but it certainly is the answer
I was looking for!

Thank you!

On 12/24/2016 8:46 PM, Carsten Arnholm wrote:

On 25. des. 2016 01:39, jon wrote:

I have a conceptual idea of how this would be done in a traditional
programming language if I had a list of the coordinates along each of
the 4 boundary lines.  I considered re-writing the code, below, as a
sweep, and generating the coordinates explicitly, but a) that is not
trivial (to me), and ii) I want to solve the more general case where the
equations that determine the shape are not known.  I looked at the
generated STL file, and the coordinates are there, but not organized in
the way that I would want them to be.

Whether your idea is really worth pursuing is a issue in itself, but
if you want to try it is probably easier to export to AMF, OpenSCAD
can do it.
https://en.wikipedia.org/wiki/Additive_Manufacturing_File_Format

AMF is an XML file format containing the result of booleans in a form
very similar to an OpenSCAD polyhedron, with unique vertices separate
from the (triangular) faces and each face defined as 3 vertex indices.
This means you have topology to work with, not just a "polygon soup"
as in STL. With STL you would have to rediscover a topology first, a
non-trivial task in the general case.

So in principle, using a traditional programming language, you could
read the AMF and detect the "boundary lines" by evaluating the angles
between neighbouring faces (finding neighbouring faces requires
topology evaluation). That would be just the start of another
non-trivial task to detect the faces bound by those boundaries. It
could certainly succeed, but a general solution would take quite some
effort.

Using only OpenSCAD, something like that is not possible at all, since
there is no way in the language to access the vertices and faces of
the result of a boolean operation.

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2016.0.7924 / Virus Database: 4739/13648 - Release Date:
12/24/16

That was not the answer I was hoping for, but it certainly is the answer I was looking for! Thank you! On 12/24/2016 8:46 PM, Carsten Arnholm wrote: > On 25. des. 2016 01:39, jon wrote: >> I have a conceptual idea of how this would be done in a traditional >> programming language if I had a list of the coordinates along each of >> the 4 boundary lines. I considered re-writing the code, below, as a >> sweep, and generating the coordinates explicitly, but a) that is not >> trivial (to me), and ii) I want to solve the more general case where the >> equations that determine the shape are not known. I looked at the >> generated STL file, and the coordinates are there, but not organized in >> the way that I would want them to be. > > Whether your idea is really worth pursuing is a issue in itself, but > if you want to try it is probably easier to export to AMF, OpenSCAD > can do it. > https://en.wikipedia.org/wiki/Additive_Manufacturing_File_Format > > AMF is an XML file format containing the result of booleans in a form > very similar to an OpenSCAD polyhedron, with unique vertices separate > from the (triangular) faces and each face defined as 3 vertex indices. > This means you have topology to work with, not just a "polygon soup" > as in STL. With STL you would have to rediscover a topology first, a > non-trivial task in the general case. > > So in principle, using a traditional programming language, you could > read the AMF and detect the "boundary lines" by evaluating the angles > between neighbouring faces (finding neighbouring faces requires > topology evaluation). That would be just the start of another > non-trivial task to detect the faces bound by those boundaries. It > could certainly succeed, but a general solution would take quite some > effort. > > Using only OpenSCAD, something like that is not possible at all, since > there is no way in the language to access the vertices and faces of > the result of a boolean operation. > > Carsten Arnholm > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > ----- > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2016.0.7924 / Virus Database: 4739/13648 - Release Date: > 12/24/16 > >
R
runsun
Sun, Dec 25, 2016 2:31 AM

jon_bondy wrote

Note that this is an example shape: I want to work with families of
similar shapes, not just with this one example.

I imagine that if it's possible to generate those shapes in polyhedron, it
won't be hard to achieve what you want.


$  Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 );   $ tips: Bezier , hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2 , 3 , 4 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg , tests ( 2 ), text , triang , unit ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf ), support_tools

--
View this message in context: http://forum.openscad.org/flattening-curved-surfaces-tp19727p19731.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

jon_bondy wrote > Note that this is an example shape: I want to work with families of > similar shapes, not just with this one example. I imagine that if it's possible to generate those shapes in polyhedron, it won't be hard to achieve what you want. ----- $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); &nbsp; $ tips: Bezier , hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2 , 3 , 4 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg , tests ( 2 ), text , triang , unit ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf ), support_tools -- View this message in context: http://forum.openscad.org/flattening-curved-surfaces-tp19727p19731.html Sent from the OpenSCAD mailing list archive at Nabble.com.
CA
Carsten Arnholm
Sun, Dec 25, 2016 9:16 AM

On 25. des. 2016 02:52, jon wrote:

That was not the answer I was hoping for, but it certainly is the answer
I was looking for!

Thank you!

You are welcome. At least it may have saved you some time chasing the
unobtainable.

Carsten Arnholm

On 25. des. 2016 02:52, jon wrote: > That was not the answer I was hoping for, but it certainly is the answer > I was looking for! > > Thank you! You are welcome. At least it may have saved you some time chasing the unobtainable. Carsten Arnholm
NH
nop head
Sun, Dec 25, 2016 11:47 AM

Incidental to the question but when I put a # in front of the first
cylinder it doesn't show the whole cylinder. It does for the other three
cylinders. Why is that?

On 25 December 2016 at 09:16, Carsten Arnholm arnholm@arnholm.org wrote:

On 25. des. 2016 02:52, jon wrote:

That was not the answer I was hoping for, but it certainly is the answer
I was looking for!

Thank you!

You are welcome. At least it may have saved you some time chasing the
unobtainable.

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Incidental to the question but when I put a # in front of the first cylinder it doesn't show the whole cylinder. It does for the other three cylinders. Why is that? On 25 December 2016 at 09:16, Carsten Arnholm <arnholm@arnholm.org> wrote: > On 25. des. 2016 02:52, jon wrote: > >> That was not the answer I was hoping for, but it certainly is the answer >> I was looking for! >> >> Thank you! >> > > You are welcome. At least it may have saved you some time chasing the > unobtainable. > > > Carsten Arnholm > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
R
Ronaldo
Sun, Dec 25, 2016 12:16 PM

cacb wrote

On 25. des. 2016 01:39, jon wrote:
Using only OpenSCAD, something like that is not possible at all, since
there is no way in the language to access the vertices and faces of the
result of a boolean operation.

Carsten is right but there is a workaround. A python code by Neon22 converts
AMF files (possibly exported by OpenSCAD) to a text file in the OpenSCAD
polyhedron format. See this  discussion
http://forum.openscad.org/Wrapping-text-around-a-complex-geometry-td18145.html#a18156
. By using its output file in you OpenSCAD code, you will have access to the
model vertices and a code may be devised to find and unfold the developable
surfaces. However, the latest doesn't seem to be a trivial task. See for
instance:
http://complexitys.com/english/geometry/developable-surfaces/#.WF9isH10ca9
http://complexitys.com/english/geometry/developable-surfaces/#.WF9isH10ca9

--
View this message in context: http://forum.openscad.org/flattening-curved-surfaces-tp19727p19735.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

cacb wrote > On 25. des. 2016 01:39, jon wrote: > Using only OpenSCAD, something like that is not possible at all, since > there is no way in the language to access the vertices and faces of the > result of a boolean operation. Carsten is right but there is a workaround. A python code by Neon22 converts AMF files (possibly exported by OpenSCAD) to a text file in the OpenSCAD polyhedron format. See this discussion <http://forum.openscad.org/Wrapping-text-around-a-complex-geometry-td18145.html#a18156> . By using its output file in you OpenSCAD code, you will have access to the model vertices and a code may be devised to find and unfold the developable surfaces. However, the latest doesn't seem to be a trivial task. See for instance: http://complexitys.com/english/geometry/developable-surfaces/#.WF9isH10ca9 <http://complexitys.com/english/geometry/developable-surfaces/#.WF9isH10ca9> -- View this message in context: http://forum.openscad.org/flattening-curved-surfaces-tp19727p19735.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Sun, Dec 25, 2016 1:40 PM

Jon,
I like your approach and I don't think it is too difficult to implement, if
you restrict the design to a set of constraints, which your parser can
assume to hold without further testing. (Also I don't see any advantage in
using AMF instead of STL.)

Rules:

  1. (unrolling) - Your design is composed by a set of surfaces, which are
    unrollable in 2D. This puts a bunch of restrictions on the surfaces (!!!)
  2. (separation) - two edge-adjacent triangles belong to different surfaces,
    if the scalar product of their normals exceeds some threshold parameter TH.

So what does your algorithm? It reads the triags into a set T and
a) finds and hooks the three (common edge) neighbours to each triag in T.
b) calculates the scalar products of each two neighboured triag normals and
classifies by means of the threshold TH, if the two triags belong to the
same surfaces or not. Not-on-the-same-surface neighbours will be unhooked.
c) select any triag in T and move it to a set S. Continue with all its
same-surface neighbours and so on, until all same-surface triags are in S.
d. repeat with c until T is empty and get a set SS of surfaces.
e) unroll each surface S in SS into 2D. For example start with any triag t
i) find an affine transformation f that maps t undistorted to 2D (always
can be found).
ii) apply f to all direct neighbours and find for each of them a rotation
g that maps them to the 2D plane
iii) continue with ii using g(f(t)) until done.

You see, the scheme is quite straight forward (and easy to implement) and
the only difficulty you will encounter is step e), where it turns out
whether your design obeys to rule 1 or not.  If it doesn't, you will have to
find a way (=heuristics) to deal with it. This can get more nasty.

--
View this message in context: http://forum.openscad.org/flattening-curved-surfaces-tp19727p19736.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Jon, I like your approach and I don't think it is too difficult to implement, if you restrict the design to a set of constraints, which your parser can assume to hold without further testing. (Also I don't see any advantage in using AMF instead of STL.) Rules: 1. (unrolling) - Your design is composed by a set of surfaces, which are unrollable in 2D. This puts a bunch of restrictions on the surfaces (!!!) 2. (separation) - two edge-adjacent triangles belong to different surfaces, if the scalar product of their normals exceeds some threshold parameter TH. So what does your algorithm? It reads the triags into a set T and a) finds and hooks the three (common edge) neighbours to each triag in T. b) calculates the scalar products of each two neighboured triag normals and classifies by means of the threshold TH, if the two triags belong to the same surfaces or not. Not-on-the-same-surface neighbours will be unhooked. c) select any triag in T and move it to a set S. Continue with all its same-surface neighbours and so on, until all same-surface triags are in S. d. repeat with c until T is empty and get a set SS of surfaces. e) unroll each surface S in SS into 2D. For example start with any triag t i) find an affine transformation f that maps t undistorted to 2D (always can be found). ii) apply f to all direct neighbours and find for each of them a rotation g that maps them to the 2D plane iii) continue with ii using g(f(t)) until done. You see, the scheme is quite straight forward (and easy to implement) and the only difficulty you will encounter is step e), where it turns out whether your design obeys to rule 1 or not. If it doesn't, you will have to find a way (=heuristics) to deal with it. This can get more nasty. -- View this message in context: http://forum.openscad.org/flattening-curved-surfaces-tp19727p19736.html Sent from the OpenSCAD mailing list archive at Nabble.com.
J
jon
Sun, Dec 25, 2016 1:44 PM

I KNEW there was a reason that I was about to retire!  This should keep
me out of trouble for a while!  Thanks for the pseudo code!

Jon

On 12/25/2016 8:40 AM, Parkinbot wrote:

Jon,
I like your approach and I don't think it is too difficult to implement, if
you restrict the design to a set of constraints, which your parser can
assume to hold without further testing. (Also I don't see any advantage in
using AMF instead of STL.)

Rules:

  1. (unrolling) - Your design is composed by a set of surfaces, which are
    unrollable in 2D. This puts a bunch of restrictions on the surfaces (!!!)
  2. (separation) - two edge-adjacent triangles belong to different surfaces,
    if the scalar product of their normals exceeds some threshold parameter TH.

So what does your algorithm? It reads the triags into a set T and
a) finds and hooks the three (common edge) neighbours to each triag in T.
b) calculates the scalar products of each two neighboured triag normals and
classifies by means of the threshold TH, if the two triags belong to the
same surfaces or not. Not-on-the-same-surface neighbours will be unhooked.
c) select any triag in T and move it to a set S. Continue with all its
same-surface neighbours and so on, until all same-surface triags are in S.
d. repeat with c until T is empty and get a set SS of surfaces.
e) unroll each surface S in SS into 2D. For example start with any triag t
i) find an affine transformation f that maps t undistorted to 2D (always
can be found).
ii) apply f to all direct neighbours and find for each of them a rotation
g that maps them to the 2D plane
iii) continue with ii using g(f(t)) until done.

You see, the scheme is quite straight forward (and easy to implement) and
the only difficulty you will encounter is step e), where it turns out
whether your design obeys to rule 1 or not.  If it doesn't, you will have to
find a way (=heuristics) to deal with it. This can get more nasty.

--
View this message in context: http://forum.openscad.org/flattening-curved-surfaces-tp19727p19736.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2016.0.7924 / Virus Database: 4739/13649 - Release Date: 12/24/16

I KNEW there was a reason that I was about to retire! This should keep me out of trouble for a while! Thanks for the pseudo code! Jon On 12/25/2016 8:40 AM, Parkinbot wrote: > Jon, > I like your approach and I don't think it is too difficult to implement, if > you restrict the design to a set of constraints, which your parser can > assume to hold without further testing. (Also I don't see any advantage in > using AMF instead of STL.) > > Rules: > 1. (unrolling) - Your design is composed by a set of surfaces, which are > unrollable in 2D. This puts a bunch of restrictions on the surfaces (!!!) > 2. (separation) - two edge-adjacent triangles belong to different surfaces, > if the scalar product of their normals exceeds some threshold parameter TH. > > So what does your algorithm? It reads the triags into a set T and > a) finds and hooks the three (common edge) neighbours to each triag in T. > b) calculates the scalar products of each two neighboured triag normals and > classifies by means of the threshold TH, if the two triags belong to the > same surfaces or not. Not-on-the-same-surface neighbours will be unhooked. > c) select any triag in T and move it to a set S. Continue with all its > same-surface neighbours and so on, until all same-surface triags are in S. > d. repeat with c until T is empty and get a set SS of surfaces. > e) unroll each surface S in SS into 2D. For example start with any triag t > i) find an affine transformation f that maps t undistorted to 2D (always > can be found). > ii) apply f to all direct neighbours and find for each of them a rotation > g that maps them to the 2D plane > iii) continue with ii using g(f(t)) until done. > > You see, the scheme is quite straight forward (and easy to implement) and > the only difficulty you will encounter is step e), where it turns out > whether your design obeys to rule 1 or not. If it doesn't, you will have to > find a way (=heuristics) to deal with it. This can get more nasty. > > > > > -- > View this message in context: http://forum.openscad.org/flattening-curved-surfaces-tp19727p19736.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > ----- > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2016.0.7924 / Virus Database: 4739/13649 - Release Date: 12/24/16 > >