discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

bug with rotatie and cylinder

E
easycure
Fri, Jul 3, 2015 12:22 PM

hi everybody,

try this code:

difference () {
cube([3,60,60]);

translate([0,30,30])
    rotate([0,90,0])
        cylinder(r=15,h=3);

}

You will see that the rotated cylinder is "strange"...

is there a bug in OpenSCAD ?

thanx and congrat for OpenScad, it's a wonderful software !!!
easycure

--
View this message in context: http://forum.openscad.org/bug-with-rotatie-and-cylinder-tp13001.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

hi everybody, try this code: difference () { cube([3,60,60]); translate([0,30,30]) rotate([0,90,0]) cylinder(r=15,h=3); } You will see that the rotated cylinder is "strange"... is there a bug in OpenSCAD ? thanx and congrat for OpenScad, it's a wonderful software !!! easycure -- View this message in context: http://forum.openscad.org/bug-with-rotatie-and-cylinder-tp13001.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JL
Jean-Paul Louis
Fri, Jul 3, 2015 12:44 PM

Try

difference () {
cube([3,60,60]);

translate([-0.005,30,30])
rotate([0,90,0])
cylinder(r=15,h=3.01);
}

You need to think about boundaries.

My $0.02 contribution,
Jean-Paul
AC9GH

On Jul 3, 2015, at 8:22 AM, easycure easycure@easycure.fr wrote:

hi everybody,

try this code:

difference () {
cube([3,60,60]);

translate([0,30,30])
    rotate([0,90,0])
        cylinder(r=15,h=3);

}

You will see that the rotated cylinder is "strange"...

is there a bug in OpenSCAD ?

thanx and congrat for OpenScad, it's a wonderful software !!!
easycure

--
View this message in context: http://forum.openscad.org/bug-with-rotatie-and-cylinder-tp13001.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

Try difference () { cube([3,60,60]); translate([-0.005,30,30]) rotate([0,90,0]) cylinder(r=15,h=3.01); } You need to think about boundaries. My $0.02 contribution, Jean-Paul AC9GH > On Jul 3, 2015, at 8:22 AM, easycure <easycure@easycure.fr> wrote: > > hi everybody, > > try this code: > > difference () { > cube([3,60,60]); > > translate([0,30,30]) > rotate([0,90,0]) > cylinder(r=15,h=3); > } > > You will see that the rotated cylinder is "strange"... > > is there a bug in OpenSCAD ? > > thanx and congrat for OpenScad, it's a wonderful software !!! > easycure > > > > -- > View this message in context: http://forum.openscad.org/bug-with-rotatie-and-cylinder-tp13001.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
E
easycure
Fri, Jul 3, 2015 12:55 PM

thanx for your answer, and I don't want to bother you but, what do you mean
about boundaries ? (sorry i'm a noob)

and the problem doesn't occur whitout the rotate function:

difference () {
cube([60,60,3]);

translate([30,30,00])
        cylinder(r=15,h=3);

}

cheers
easycure

--
View this message in context: http://forum.openscad.org/bug-with-rotate-and-cylinder-tp13001p13004.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

thanx for your answer, and I don't want to bother you but, what do you mean about boundaries ? (sorry i'm a noob) and the problem doesn't occur whitout the rotate function: difference () { cube([60,60,3]); translate([30,30,00]) cylinder(r=15,h=3); } cheers easycure -- View this message in context: http://forum.openscad.org/bug-with-rotate-and-cylinder-tp13001p13004.html Sent from the OpenSCAD mailing list archive at Nabble.com.
DM
doug moen
Fri, Jul 3, 2015 12:57 PM

This is a well known problem, which I think is caused by OpenSCAD using
floating point transformation matrices.

Try this as a workaround:

epsilon = 0.01;

difference () {

cube([3,60,60]);

translate([-epsilon,30,30])

rotate([0,90,0])

  cylinder(r=15,h=3+2*epsilon);

}

On 3 July 2015 at 08:22, easycure easycure@easycure.fr wrote:

hi everybody,

try this code:

difference () {
cube([3,60,60]);

 translate([0,30,30])
     rotate([0,90,0])
         cylinder(r=15,h=3);

}

You will see that the rotated cylinder is "strange"...

is there a bug in OpenSCAD ?

thanx and congrat for OpenScad, it's a wonderful software !!!
easycure

--
View this message in context:
http://forum.openscad.org/bug-with-rotatie-and-cylinder-tp13001.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

This is a well known problem, which I think is caused by OpenSCAD using floating point transformation matrices. Try this as a workaround: epsilon = 0.01; difference () { cube([3,60,60]); translate([-epsilon,30,30]) rotate([0,90,0]) cylinder(r=15,h=3+2*epsilon); } On 3 July 2015 at 08:22, easycure <easycure@easycure.fr> wrote: > hi everybody, > > try this code: > > difference () { > cube([3,60,60]); > > translate([0,30,30]) > rotate([0,90,0]) > cylinder(r=15,h=3); > } > > You will see that the rotated cylinder is "strange"... > > is there a bug in OpenSCAD ? > > thanx and congrat for OpenScad, it's a wonderful software !!! > easycure > > > > -- > View this message in context: > http://forum.openscad.org/bug-with-rotatie-and-cylinder-tp13001.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 > >
DM
doug moen
Fri, Jul 3, 2015 1:02 PM

You expect the end faces of the rotated cylinder to exactly match up with
the faces of the cuboid, but they don't match due to floating point
roundoff in the rotate. So you include a fudge factor, "epsilon", make the
cylinder slightly taller than 3mm, and make sure the cylinder sticks out
past the cuboid faces on both sides.

On 3 July 2015 at 08:55, easycure easycure@easycure.fr wrote:

thanx for your answer, and I don't want to bother you but, what do you mean
about boundaries ? (sorry i'm a noob)

and the problem doesn't occur whitout the rotate function:

difference () {
cube([60,60,3]);

 translate([30,30,00])
         cylinder(r=15,h=3);

}

cheers
easycure

--
View this message in context:
http://forum.openscad.org/bug-with-rotate-and-cylinder-tp13001p13004.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

You expect the end faces of the rotated cylinder to exactly match up with the faces of the cuboid, but they don't match due to floating point roundoff in the rotate. So you include a fudge factor, "epsilon", make the cylinder slightly taller than 3mm, and make sure the cylinder sticks out past the cuboid faces on both sides. On 3 July 2015 at 08:55, easycure <easycure@easycure.fr> wrote: > thanx for your answer, and I don't want to bother you but, what do you mean > about boundaries ? (sorry i'm a noob) > > and the problem doesn't occur whitout the rotate function: > > difference () { > cube([60,60,3]); > > translate([30,30,00]) > cylinder(r=15,h=3); > } > > cheers > easycure > > > > > -- > View this message in context: > http://forum.openscad.org/bug-with-rotate-and-cylinder-tp13001p13004.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 > >
DM
doug moen
Fri, Jul 3, 2015 1:23 PM

Rotation is done internally using trigonometry. In order for the original
code to work, it would be necessary for sin(90) == 1 and cos(90) == 0. In
the version of OpenSCAD I'm using, cos(90) != 0, so your model doesn't work
as expected.

On 3 July 2015 at 09:02, doug moen doug@moens.org wrote:

You expect the end faces of the rotated cylinder to exactly match up with
the faces of the cuboid, but they don't match due to floating point
roundoff in the rotate. So you include a fudge factor, "epsilon", make the
cylinder slightly taller than 3mm, and make sure the cylinder sticks out
past the cuboid faces on both sides.

On 3 July 2015 at 08:55, easycure easycure@easycure.fr wrote:

thanx for your answer, and I don't want to bother you but, what do you
mean
about boundaries ? (sorry i'm a noob)

and the problem doesn't occur whitout the rotate function:

difference () {
cube([60,60,3]);

 translate([30,30,00])
         cylinder(r=15,h=3);

}

cheers
easycure

--
View this message in context:
http://forum.openscad.org/bug-with-rotate-and-cylinder-tp13001p13004.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

Rotation is done internally using trigonometry. In order for the original code to work, it would be necessary for sin(90) == 1 and cos(90) == 0. In the version of OpenSCAD I'm using, cos(90) != 0, so your model doesn't work as expected. On 3 July 2015 at 09:02, doug moen <doug@moens.org> wrote: > You expect the end faces of the rotated cylinder to exactly match up with > the faces of the cuboid, but they don't match due to floating point > roundoff in the rotate. So you include a fudge factor, "epsilon", make the > cylinder slightly taller than 3mm, and make sure the cylinder sticks out > past the cuboid faces on both sides. > > On 3 July 2015 at 08:55, easycure <easycure@easycure.fr> wrote: > >> thanx for your answer, and I don't want to bother you but, what do you >> mean >> about boundaries ? (sorry i'm a noob) >> >> and the problem doesn't occur whitout the rotate function: >> >> difference () { >> cube([60,60,3]); >> >> translate([30,30,00]) >> cylinder(r=15,h=3); >> } >> >> cheers >> easycure >> >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/bug-with-rotate-and-cylinder-tp13001p13004.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 >> >> >
TP
Torsten Paul
Fri, Jul 3, 2015 6:59 PM

On 07/03/2015 02:57 PM, doug moen wrote:

This is a well known problem, which I think is caused by OpenSCAD using
floating point transformation matrices.

It's just dependent on how the graphics driver does the actual
display. I'm getting this even for

difference() {
cube(10, center = true);
cylinder(h = 10, r = 4, center = true);
}

No transformation involved at all, just the difference painting
triangles of different color in one plane.

See https://en.wikipedia.org/wiki/Z-fighting

ciao,
Torsten.

On 07/03/2015 02:57 PM, doug moen wrote: > This is a well known problem, which I think is caused by OpenSCAD using > floating point transformation matrices. > It's just dependent on how the graphics driver does the actual display. I'm getting this even for difference() { cube(10, center = true); cylinder(h = 10, r = 4, center = true); } No transformation involved at all, just the difference painting triangles of different color in one plane. See https://en.wikipedia.org/wiki/Z-fighting ciao, Torsten.
DM
doug moen
Fri, Jul 3, 2015 8:28 PM

Hi Torsten. You are reporting an F5 bug, whereas I was analyzing an F6 bug.
I think they are two different issues. I can reproduce both.
I think Easycure was also using F6, since his problem goes away with no
rotation.

On 3 July 2015 at 14:59, Torsten Paul Torsten.Paul@gmx.de wrote:

On 07/03/2015 02:57 PM, doug moen wrote:

This is a well known problem, which I think is caused by OpenSCAD using

floating point transformation matrices.

It's just dependent on how the graphics driver does the actual

display. I'm getting this even for

difference() {
cube(10, center = true);
cylinder(h = 10, r = 4, center = true);
}

No transformation involved at all, just the difference painting
triangles of different color in one plane.

See https://en.wikipedia.org/wiki/Z-fighting

ciao,
Torsten.


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

Hi Torsten. You are reporting an F5 bug, whereas I was analyzing an F6 bug. I think they are two different issues. I can reproduce both. I think Easycure was also using F6, since his problem goes away with no rotation. On 3 July 2015 at 14:59, Torsten Paul <Torsten.Paul@gmx.de> wrote: > On 07/03/2015 02:57 PM, doug moen wrote: > >> This is a well known problem, which I think is caused by OpenSCAD using >> > > floating point transformation matrices. > >> >> It's just dependent on how the graphics driver does the actual > display. I'm getting this even for > > difference() { > cube(10, center = true); > cylinder(h = 10, r = 4, center = true); > } > > No transformation involved at all, just the difference painting > triangles of different color in one plane. > > See https://en.wikipedia.org/wiki/Z-fighting > > ciao, > Torsten. > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
TP
Torsten Paul
Fri, Jul 3, 2015 8:50 PM

On 07/03/2015 10:28 PM, doug moen wrote:

Hi Torsten. You are reporting an F5 bug, whereas I was analyzing
an F6 bug. I think they are two different issues. I can reproduce both.

Right, there was never said what to look at exactly, so I stopped
at the first issue I saw.

Hmm, there's code trying to handle sin() and cos() special cases but
that's not active for rotation(). I guess it's worth a try to catch
those too.

ciao,
Torsten.

On 07/03/2015 10:28 PM, doug moen wrote: > Hi Torsten. You are reporting an F5 bug, whereas I was analyzing > an F6 bug. I think they are two different issues. I can reproduce both. > Right, there was never said what to look at exactly, so I stopped at the first issue I saw. Hmm, there's code trying to handle sin() and cos() special cases but that's not active for rotation(). I guess it's worth a try to catch those too. ciao, Torsten.
LB
L Boyd
Sun, Jul 5, 2015 1:54 PM

In the meantime you can clean up the picture by have the cylinder protrude
beyond the the cube on both sides.

difference () {
cube([3,60,60]);

translate([-1,30,30])
    rotate([0,90,0])
        cylinder(r=15,h=5);

}

Just as you would do if making the hole with you drill press, going past to
make a clean hole.

--
View this message in context: http://forum.openscad.org/bug-with-rotate-and-cylinder-tp13001p13044.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

In the meantime you can clean up the picture by have the cylinder protrude beyond the the cube on both sides. difference () { cube([3,60,60]); translate([-1,30,30]) rotate([0,90,0]) cylinder(r=15,h=5); } Just as you would do if making the hole with you drill press, going past to make a clean hole. -- View this message in context: http://forum.openscad.org/bug-with-rotate-and-cylinder-tp13001p13044.html Sent from the OpenSCAD mailing list archive at Nabble.com.