discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Triangulation of quads

RP
Ronaldo Persiano
Fri, Feb 1, 2019 2:03 PM

nop head nop.head@gmail.com wrote:

The problem with the global one is it produces a 360 degree twist for
every orbit of the Z axis. The relative one does not.

Yes, you are right, the global method can't work .

To avoid the singularity shouldn't you look at the next tangent and orient

it around the axis the way that indicates? How does a fixed direction
perturbation help?

The trouble with the local method may arise just at the beginning of the
path because there it is computed a minimum rotation from vector [0,0,1] to
the first path tangent. When the first unitary tangent is [0,0,-1], we have
a singularity and by taking the identity matrix as the rotation matrix
produces a wrong winding of the very first section. From there on, all
winding will be reverted. When we do a perturbation in one of the vectors
in rotate_from_to(), the cross product of a and the perturbed b is no
longer 0 and the singularity and all its consequences are avoided.

For the intermediate points of the path, the occurrence of two subsequent
tangents opposed to each other will surely generate a bad condition but
then the polyhedron will have a self-intersections which is even worst. So,
just the start point of the path demands concern. Instead of a perturbation
in the minimum rotation function we could just check if the first tangent
is [0,0,-1] and set an ad hoc solution: take the rotation
[[1,0,0],[0,-1,0],[0,0,-1]] instead of calling rotate_from_to(). That
alternative seems better.

nop head <nop.head@gmail.com> wrote: > The problem with the global one is it produces a 360 degree twist for > every orbit of the Z axis. The relative one does not. > Yes, you are right, the global method can't work . To avoid the singularity shouldn't you look at the next tangent and orient > it around the axis the way that indicates? How does a fixed direction > perturbation help? > The trouble with the local method may arise just at the beginning of the path because there it is computed a minimum rotation from vector [0,0,1] to the first path tangent. When the first unitary tangent is [0,0,-1], we have a singularity and by taking the identity matrix as the rotation matrix produces a wrong winding of the very first section. From there on, all winding will be reverted. When we do a perturbation in one of the vectors in rotate_from_to(), the cross product of a and the perturbed b is no longer 0 and the singularity and all its consequences are avoided. For the intermediate points of the path, the occurrence of two subsequent tangents opposed to each other will surely generate a bad condition but then the polyhedron will have a self-intersections which is even worst. So, just the start point of the path demands concern. Instead of a perturbation in the minimum rotation function we could just check if the first tangent is [0,0,-1] and set an ad hoc solution: take the rotation [[1,0,0],[0,-1,0],[0,0,-1]] instead of calling rotate_from_to(). That alternative seems better.
P
Parkinbot
Fri, Feb 1, 2019 2:34 PM

Ronaldo wrote

Instead of a perturbation
in the minimum rotation function we could just check if the first tangent
is [0,0,-1] and set an ad hoc solution: take the rotation
[[1,0,0],[0,-1,0],[0,0,-1]] instead of calling rotate_from_to(). That
alternative seems better.

How do you determine that the continued path will not demand
[[1,0,0],[0,1,0],[0,0,-1]]?

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

Ronaldo wrote > Instead of a perturbation > in the minimum rotation function we could just check if the first tangent > is [0,0,-1] and set an ad hoc solution: take the rotation > [[1,0,0],[0,-1,0],[0,0,-1]] instead of calling rotate_from_to(). That > alternative seems better. How do you determine that the continued path will not demand [[1,0,0],[0,1,0],[0,0,-1]]? -- Sent from: http://forum.openscad.org/
NH
nop head
Fri, Feb 1, 2019 2:38 PM

Ha, I have been using [[-1, 0, 0], [0, 1, 0], [0, 0, -1]]. I have also
experimented with reversing the winding order of the profile and doing the
first rotation from [0, 0, -1]. That extrudes the profile downwards in the
same orientation as it does upwards, whereas the other methods flip it.

There are an infinite number of ways of spinning a cat it seems!

On Fri, 1 Feb 2019 at 14:04, Ronaldo Persiano rcmpersiano@gmail.com wrote:

nop head nop.head@gmail.com wrote:

The problem with the global one is it produces a 360 degree twist for
every orbit of the Z axis. The relative one does not.

Yes, you are right, the global method can't work .

To avoid the singularity shouldn't you look at the next tangent and orient

it around the axis the way that indicates? How does a fixed direction
perturbation help?

The trouble with the local method may arise just at the beginning of the
path because there it is computed a minimum rotation from vector [0,0,1] to
the first path tangent. When the first unitary tangent is [0,0,-1], we have
a singularity and by taking the identity matrix as the rotation matrix
produces a wrong winding of the very first section. From there on, all
winding will be reverted. When we do a perturbation in one of the vectors
in rotate_from_to(), the cross product of a and the perturbed b is no
longer 0 and the singularity and all its consequences are avoided.

For the intermediate points of the path, the occurrence of two subsequent
tangents opposed to each other will surely generate a bad condition but
then the polyhedron will have a self-intersections which is even worst. So,
just the start point of the path demands concern. Instead of a perturbation
in the minimum rotation function we could just check if the first tangent
is [0,0,-1] and set an ad hoc solution: take the rotation
[[1,0,0],[0,-1,0],[0,0,-1]] instead of calling rotate_from_to(). That
alternative seems better.


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

Ha, I have been using [[-1, 0, 0], [0, 1, 0], [0, 0, -1]]. I have also experimented with reversing the winding order of the profile and doing the first rotation from [0, 0, -1]. That extrudes the profile downwards in the same orientation as it does upwards, whereas the other methods flip it. There are an infinite number of ways of spinning a cat it seems! On Fri, 1 Feb 2019 at 14:04, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > nop head <nop.head@gmail.com> wrote: > >> The problem with the global one is it produces a 360 degree twist for >> every orbit of the Z axis. The relative one does not. >> > > Yes, you are right, the global method can't work . > > To avoid the singularity shouldn't you look at the next tangent and orient >> it around the axis the way that indicates? How does a fixed direction >> perturbation help? >> > > The trouble with the local method may arise just at the beginning of the > path because there it is computed a minimum rotation from vector [0,0,1] to > the first path tangent. When the first unitary tangent is [0,0,-1], we have > a singularity and by taking the identity matrix as the rotation matrix > produces a wrong winding of the very first section. From there on, all > winding will be reverted. When we do a perturbation in one of the vectors > in rotate_from_to(), the cross product of a and the perturbed b is no > longer 0 and the singularity and all its consequences are avoided. > > For the intermediate points of the path, the occurrence of two subsequent > tangents opposed to each other will surely generate a bad condition but > then the polyhedron will have a self-intersections which is even worst. So, > just the start point of the path demands concern. Instead of a perturbation > in the minimum rotation function we could just check if the first tangent > is [0,0,-1] and set an ad hoc solution: take the rotation > [[1,0,0],[0,-1,0],[0,0,-1]] instead of calling rotate_from_to(). That > alternative seems better. > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
RP
Ronaldo Persiano
Fri, Feb 1, 2019 2:46 PM

Parkinbot rudolf@digitaldocument.de wrote:

How do you determine that the continued path will not demand
[[1,0,0],[0,1,0],[0,0,-1]]?
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Well, that is not a rotation but a reflection. But it is unimportant which
first rotation you use provided that it rotates [0,0,1] to [0,0,-1]. The
following rotations will be consistent with that first one.

Parkinbot <rudolf@digitaldocument.de> wrote: > How do you determine that the continued path will not demand > [[1,0,0],[0,1,0],[0,0,-1]]? > <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> Well, that is not a rotation but a reflection. But it is unimportant which first rotation you use provided that it rotates [0,0,1] to [0,0,-1]. The following rotations will be consistent with that first one.
NH
nop head
Fri, Feb 1, 2019 2:47 PM

In relative mode you never get the singularity after the start as that
would mean the path has doubled back on itself at a cusp.

On Fri, 1 Feb 2019 at 14:37, Parkinbot rudolf@digitaldocument.de wrote:

Ronaldo wrote

Instead of a perturbation
in the minimum rotation function we could just check if the first tangent
is [0,0,-1] and set an ad hoc solution: take the rotation
[[1,0,0],[0,-1,0],[0,0,-1]] instead of calling rotate_from_to(). That
alternative seems better.

How do you determine that the continued path will not demand
[[1,0,0],[0,1,0],[0,0,-1]]?

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


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

In relative mode you never get the singularity after the start as that would mean the path has doubled back on itself at a cusp. On Fri, 1 Feb 2019 at 14:37, Parkinbot <rudolf@digitaldocument.de> wrote: > Ronaldo wrote > > Instead of a perturbation > > in the minimum rotation function we could just check if the first tangent > > is [0,0,-1] and set an ad hoc solution: take the rotation > > [[1,0,0],[0,-1,0],[0,0,-1]] instead of calling rotate_from_to(). That > > alternative seems better. > > How do you determine that the continued path will not demand > [[1,0,0],[0,1,0],[0,0,-1]]? > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Fri, Feb 1, 2019 3:03 PM

Since one can flip around x or around y I think it makes sense to look at
the second tangent to decide. I.e. perturb b by adding a little of c. Then
it flips the same way it would of the first normal was leaning slightly in
the direction of the second.

However all these methods cause a discontinuity of behaviour with changing
directions. For example the flips change around the 45 degree mark.

One way around that is to always orient the first frame like Frenet-Serret.
I.e. profile gets rotated around Z so the Y axis points towards the centre
of curvature of the start of the path. Then there are no discontinuities of
behaviour.

On Fri, 1 Feb 2019 at 14:47, Ronaldo Persiano rcmpersiano@gmail.com wrote:

Parkinbot rudolf@digitaldocument.de wrote:

How do you determine that the continued path will not demand
[[1,0,0],[0,1,0],[0,0,-1]]?
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Well, that is not a rotation but a reflection. But it is unimportant which
first rotation you use provided that it rotates [0,0,1] to [0,0,-1]. The
following rotations will be consistent with that first one.


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

Since one can flip around x or around y I think it makes sense to look at the second tangent to decide. I.e. perturb b by adding a little of c. Then it flips the same way it would of the first normal was leaning slightly in the direction of the second. However all these methods cause a discontinuity of behaviour with changing directions. For example the flips change around the 45 degree mark. One way around that is to always orient the first frame like Frenet-Serret. I.e. profile gets rotated around Z so the Y axis points towards the centre of curvature of the start of the path. Then there are no discontinuities of behaviour. On Fri, 1 Feb 2019 at 14:47, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > > > Parkinbot <rudolf@digitaldocument.de> wrote: > >> How do you determine that the continued path will not demand >> [[1,0,0],[0,1,0],[0,0,-1]]? >> <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> > > > Well, that is not a rotation but a reflection. But it is unimportant which > first rotation you use provided that it rotates [0,0,1] to [0,0,-1]. The > following rotations will be consistent with that first one. > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
RP
Ronaldo Persiano
Fri, Feb 1, 2019 4:23 PM

I am not sure I understand fully your proposal because I think there is no
better first section xy orientation except in the very particular case
where the first tangent is [0,0,1] and we may expect that it has the same
orientation as the shape in the xy plane. The Frenet-Serat frame is useless
when we have the first few points aligned in a vertical line once the
initial few tangents are all equal.

I am not sure I understand fully your proposal because I think there is no better first section xy orientation except in the very particular case where the first tangent is [0,0,1] and we may expect that it has the same orientation as the shape in the xy plane. The Frenet-Serat frame is useless when we have the first few points aligned in a vertical line once the initial few tangents are all equal.
P
Parkinbot
Fri, Feb 1, 2019 4:27 PM

this is correct. But the path can go up or down the z-axis ...

Ronaldo wrote

Well, that is not a rotation but a reflection. But it is unimportant which
first rotation you use provided that it rotates [0,0,1] to [0,0,-1]. The
following rotations will be consistent with that first one.

this is correct. But the path can go up or down the z-axis ... Ronaldo wrote > Well, that is not a rotation but a reflection. But it is unimportant which > first rotation you use provided that it rotates [0,0,1] to [0,0,-1]. The > following rotations will be consistent with that first one. -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Fri, Feb 1, 2019 4:35 PM

this is correct. But the path can go up or down the z-axis ...

For up direction, the standard rotation of rotate_from_to() is the identity
what gives the right behavior.

> > this is correct. But the path can go up or down the z-axis ... > For up direction, the standard rotation of rotate_from_to() is the identity what gives the right behavior.
RP
Ronaldo Persiano
Fri, Feb 1, 2019 5:13 PM

nop head nop.head@gmail.com wrote:

One thing to note is that it is possible to accumulate the rotations in a
C style for loop now. It no longer requires a recursive function.

Yes, I just changed accumulate_rotations() in my code to:

function accumulate_rotations(rots) =
[for( i = 0, R = rots[0];
i <= len(rots);
i=i+1, R = rots[i]*R)
R ];

and minimizing_rotations() to:

function minimizing_rotations(tangents) =
// avoid singularity at the first rotation of the sequence
[ let( axis = unit(cross([0,0,1],tangents[1])) )
axis*axis >= 0.99 || tangents[1][2]>=0 ?
rotate_from_to([0,0,1],tangents[1]) :
[[1,0,0],[0,-1,0],[0,0,-1]],
for (i = [1:len(tangents)-2])
rotate_from_to(tangents[i],tangents[i+1])
];

I think I am in position now to update my code in github with the
conclusions of this discussion.

nop head <nop.head@gmail.com> wrote: > One thing to note is that it is possible to accumulate the rotations in a > C style for loop now. It no longer requires a recursive function. > Yes, I just changed accumulate_rotations() in my code to: function accumulate_rotations(rots) = [for( i = 0, R = rots[0]; i <= len(rots); i=i+1, R = rots[i]*R) R ]; and minimizing_rotations() to: function minimizing_rotations(tangents) = // avoid singularity at the first rotation of the sequence [ let( axis = unit(cross([0,0,1],tangents[1])) ) axis*axis >= 0.99 || tangents[1][2]>=0 ? rotate_from_to([0,0,1],tangents[1]) : [[1,0,0],[0,-1,0],[0,0,-1]], for (i = [1:len(tangents)-2]) rotate_from_to(tangents[i],tangents[i+1]) ]; I think I am in position now to update my code in github with the conclusions of this discussion.