discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Chiseled Font?

RP
Ronaldo Persiano
Thu, Feb 20, 2020 2:28 PM

Honestly, I'm a little surprised that polyhedron doesn't just handle it.
It's not a super challenging thing to have the computer fix as long as the
surface is simply connected and orientable.

It is not a simple task to find whether a consistent winding is reversed or
not. The only way I have found was to compute the polyhedron volume by:

function polyhedron_volume(v,f) =
//  based on
https://iconline.ipleiria.pt/bitstream/10400.8/1433/1/artigo-7.pdf
let( crx = [for(fi=f, j=[1:1:len(fi)-2])
let( v0=v[fi[0]],
v1=v[fi[j]],
v2=v[fi[(j+1)%len(fi)]] )
(cross(v1-v0, v2-v0)*((v0+v1+v2).x)).x ] )
-sum(crx)/6;

where sum() computes the sum of the vectors in a list. If
polyhedron_volume() is negative, the winding is reversed. It works provided
the winding is consistent.

> > Honestly, I'm a little surprised that polyhedron doesn't just handle it. > It's not a super challenging thing to have the computer fix as long as the > surface is simply connected and orientable. > It is not a simple task to find whether a consistent winding is reversed or not. The only way I have found was to compute the polyhedron volume by: function polyhedron_volume(v,f) = // based on https://iconline.ipleiria.pt/bitstream/10400.8/1433/1/artigo-7.pdf let( crx = [for(fi=f, j=[1:1:len(fi)-2]) let( v0=v[fi[0]], v1=v[fi[j]], v2=v[fi[(j+1)%len(fi)]] ) (cross(v1-v0, v2-v0)*((v0+v1+v2).x)).x ] ) -sum(crx)/6; where sum() computes the sum of the vectors in a list. If polyhedron_volume() is negative, the winding is reversed. It works provided the winding is consistent.
P
Parkinbot
Thu, Feb 20, 2020 4:04 PM

It seems that a consistent wrong orientation is being handled. At least if
you do a Boolean operation on a purple object and a regular one or on two
purple objects you don't get a CGAL error.

The only miracle is indeed that:
scale([1,1,-1])
cube(100);

like other regular (cylinder() or xxx_extrude()) objects aren't display
purple by F12. I guess that F12 just ignores them.

Ronaldo wrote

Honestly, I'm a little surprised that polyhedron doesn't just handle it.
It's not a super challenging thing to have the computer fix as long as
the
surface is simply connected and orientable.

It seems that a consistent wrong orientation is being handled. At least if you do a Boolean operation on a purple object and a regular one or on two purple objects you don't get a CGAL error. The only miracle is indeed that: scale([1,1,-1]) cube(100); like other regular (cylinder() or xxx_extrude()) objects aren't display purple by F12. I guess that F12 just ignores them. Ronaldo wrote >> >> Honestly, I'm a little surprised that polyhedron doesn't just handle it. >> It's not a super challenging thing to have the computer fix as long as >> the >> surface is simply connected and orientable. >> -- Sent from: http://forum.openscad.org/
JB
Jordan Brown
Thu, Feb 20, 2020 4:42 PM

On 2/20/2020 8:04 AM, Parkinbot wrote:

It seems that a consistent wrong orientation is being handled. At least if you do a Boolean operation on a purple object and a regular one or on two purple objects you don't get a CGAL error.

The only miracle is indeed that:
scale([1,1,-1])
cube(100);

like other regular (cylinder() or xxx_extrude()) objects aren't display
purple by F12. I guess that F12 just ignores them.

I built a cube with polyhedron() and mirrors and negative scales don't
turn it purple.  When I flip one of the faces, it's consistently purple
across the various reflections.

It seems like it would be easy enough to fix a polyhedron after an
arbitrary scale(); you'd just reverse the winding order of all of the
faces if there were an odd number of negative scales.

I expect that you could derive the same information from a
transformation matrix, but right now I'm not up to the math to do it.

I've reverted my change to the manual, restoring the "same direction" /
"prefers clockwise" version.

Did we ever get an authoritative resolution on the negative scale question?

On 2/20/2020 8:04 AM, Parkinbot wrote: > It seems that a consistent wrong orientation is being handled. At least if you do a Boolean operation on a purple object and a regular one or on two purple objects you don't get a CGAL error. > > The only miracle is indeed that: > scale([1,1,-1]) > cube(100); > > like other regular (cylinder() or xxx_extrude()) objects aren't display > purple by F12. I guess that F12 just ignores them. I built a cube with polyhedron() and mirrors and negative scales don't turn it purple.  When I flip one of the faces, it's consistently purple across the various reflections. It seems like it would be easy enough to fix a polyhedron after an arbitrary scale(); you'd just reverse the winding order of all of the faces if there were an odd number of negative scales. I expect that you could derive the same information from a transformation matrix, but right now I'm not up to the math to do it. I've reverted my change to the manual, restoring the "same direction" / "prefers clockwise" version. Did we ever get an authoritative resolution on the negative scale question?
RP
Ronaldo Persiano
Thu, Feb 20, 2020 5:13 PM

I expect that you could derive the same information from a transformation
matrix, but right now I'm not up to the math to do it.

A 4x4 transformation matrix includes some sort of mirroring if its
determinant is less than 0. If the determinant is zero, the
transformation is a projection on a lower dimension space and may or may
not include a mirroring. It seems that multmatrix doesn't computes the
matrix determinant or, at least, ignores if it is zero and does a
projection on a lower dimension space but considers it a 3D object!

multmatrix( [ [1,0,0,0], [1,0,0,0],[0,0,-1,0]]) cube(10);
square();

> > I expect that you could derive the same information from a transformation > matrix, but right now I'm not up to the math to do it. > A 4x4 transformation matrix includes some sort of mirroring if its determinant is less than 0. If the determinant is zero, the transformation is a projection on a lower dimension space and may or may not include a mirroring. It seems that multmatrix doesn't computes the matrix determinant or, at least, ignores if it is zero and does a projection on a lower dimension space but considers it a 3D object! multmatrix( [ [1,0,0,0], [1,0,0,0],[0,0,-1,0]]) cube(10); square();
P
Parkinbot
Thu, Feb 20, 2020 6:03 PM

An exploit of the sign of the determinant of the multmatrix would be an
explanation.

JordanBrown wrote

Did we ever get an authoritative resolution on the negative scale
question?

the ultimate authority is always the compiler ;-)
another place to check is the source code ...

--
Sent from: http://forum.openscad.org/

An exploit of the sign of the determinant of the multmatrix would be an explanation. JordanBrown wrote > Did we ever get an authoritative resolution on the negative scale > question? the ultimate authority is always the compiler ;-) another place to check is the source code ... -- Sent from: http://forum.openscad.org/
JB
Jordan Brown
Thu, Feb 20, 2020 9:21 PM

On 2/20/2020 10:03 AM, Parkinbot wrote:

JordanBrown wrote

Did we ever get an authoritative resolution on the negative scale
question?

the ultimate authority is always the compiler ;-)

Not so much for "sometimes produces bad results" problems.  Better to
have somebody (or some documentation) that says "X is expected to work
and Y is expected to be unreliable".

another place to check is the source code ...

Yeah, maybe, if you speak C++ and you understand how the 3D guts all
interact.

But, looking at it with my very marginal C++ knowledge, it sure looks
like all mirror() does is to set up a transformation matrix.

https://github.com/openscad/openscad/blob/master/src/transform.cc#L171

... which suggests that negative scale and the multmatrix equivalents
would be fine.

On 2/20/2020 10:03 AM, Parkinbot wrote: > JordanBrown wrote >> Did we ever get an authoritative resolution on the negative scale >> question? > the ultimate authority is always the compiler ;-) Not so much for "sometimes produces bad results" problems.  Better to have somebody (or some documentation) that says "X is expected to work and Y is expected to be unreliable". > another place to check is the source code ... Yeah, maybe, if you speak C++ and you understand how the 3D guts all interact. But, looking at it with my very marginal C++ knowledge, it sure looks like all mirror() does is to set up a transformation matrix. https://github.com/openscad/openscad/blob/master/src/transform.cc#L171 ... which suggests that negative scale and the multmatrix equivalents would be fine.
P
Parkinbot
Thu, Feb 20, 2020 10:51 PM

Since all affine operations are converted into multmatrix before being
interpreted by the CSG subsystem there can't be much difference if
mirror([0,0,1]) and scale([1,1,-1]) are mapped to the same expression.

Further
https://github.com/openscad/openscad/blob/master/src/polyset.cc##L160
shows that the determinant is used to check inside-outs as proposed by
Ronaldo.

--
Sent from: http://forum.openscad.org/

Since all affine operations are converted into multmatrix before being interpreted by the CSG subsystem there can't be much difference if mirror([0,0,1]) and scale([1,1,-1]) are mapped to the same expression. Further https://github.com/openscad/openscad/blob/master/src/polyset.cc##L160 shows that the determinant is used to check inside-outs as proposed by Ronaldo. -- Sent from: http://forum.openscad.org/
JB
Jordan Brown
Fri, Feb 21, 2020 5:43 AM

On 2/20/2020 2:51 PM, Parkinbot wrote:

Since all affine operations are converted into multmatrix before being
interpreted by the CSG subsystem there can't be much difference if
mirror([0,0,1]) and scale([1,1,-1]) are mapped to the same expression.

Further
https://github.com/openscad/openscad/blob/master/src/polyset.cc##L160
shows that the determinant is used to check inside-outs as proposed by
Ronaldo.

Everybody seems to agree that negative scales are OK, so I removed that
note from the manual.

On 2/20/2020 2:51 PM, Parkinbot wrote: > Since all affine operations are converted into multmatrix before being > interpreted by the CSG subsystem there can't be much difference if > mirror([0,0,1]) and scale([1,1,-1]) are mapped to the same expression. > > Further > https://github.com/openscad/openscad/blob/master/src/polyset.cc##L160 > shows that the determinant is used to check inside-outs as proposed by > Ronaldo. Everybody seems to agree that negative scales are OK, so I removed that note from the manual.
T
TLC123
Wed, Nov 18, 2020 5:38 PM

check out the latest pull request on this upcoming feature
Implement offset_extrude
https://github.com/openscad/openscad/pull/2079

--
Sent from: http://forum.openscad.org/

check out the latest pull request on this upcoming feature Implement offset_extrude https://github.com/openscad/openscad/pull/2079 -- Sent from: http://forum.openscad.org/