discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Bug in OpenScad rendering?

F
fred_dot_u
Thu, Mar 10, 2016 9:59 PM

This is pretty common in OpenSCAD. I was able to clear the problem in your
code by adding a "fudge factor" of 0.01 to each of the horizontal cylinders
h value. One can suspect that the problem is related to floating point math,
but I'm not qualified to address that aspect.

--
View this message in context: http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16398.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

This is pretty common in OpenSCAD. I was able to clear the problem in your code by adding a "fudge factor" of 0.01 to each of the horizontal cylinders h value. One can suspect that the problem is related to floating point math, but I'm not qualified to address that aspect. -- View this message in context: http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16398.html Sent from the OpenSCAD mailing list archive at Nabble.com.
EB
Eric Buijs
Thu, Mar 10, 2016 10:04 PM

Great, that took care of the problem. Thanks for the help.

--
View this message in context: http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16399.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Great, that took care of the problem. Thanks for the help. -- View this message in context: http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16399.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Thu, Mar 10, 2016 11:18 PM

The precise cause is that rotation by 90 degrees is not exact in OpenScad
because it converts degrees to radians before doing the trig functions.

If you redefine rotate as follows: -

module rotate(a)
{
cx = cos(a[0]);
cy = cos(a[1]);
cz = cos(a[2]);
sx = sin(a[0]);
sy = sin(a[1]);
sz = sin(a[2]);
multmatrix([
[ cy * cz, cz * sx * sy - cx * sz, cx * cz * sy + sx * sz, 0],
[ cy * sz, cx * cz + sx * sy * sz,-cz * sx + cx * sy * sz, 0],
[-sy,      cy * sx,                cx * cy,                0],
[ 0,      0,                      0,                      1]
]) children();
}

Then F6 works because GCAL can work with coincident faces if they are
exactly coincident. F5 still gives shimmering holes due to Z buffer
fighting so you still need to make the cylinders longer to fix that.

On 10 March 2016 at 22:04, Eric Buijs ebuijs@mac.com wrote:

Great, that took care of the problem. Thanks for the help.

--
View this message in context:
http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16399.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

The precise cause is that rotation by 90 degrees is not exact in OpenScad because it converts degrees to radians before doing the trig functions. If you redefine rotate as follows: - module rotate(a) { cx = cos(a[0]); cy = cos(a[1]); cz = cos(a[2]); sx = sin(a[0]); sy = sin(a[1]); sz = sin(a[2]); multmatrix([ [ cy * cz, cz * sx * sy - cx * sz, cx * cz * sy + sx * sz, 0], [ cy * sz, cx * cz + sx * sy * sz,-cz * sx + cx * sy * sz, 0], [-sy, cy * sx, cx * cy, 0], [ 0, 0, 0, 1] ]) children(); } Then F6 works because GCAL can work with coincident faces if they are exactly coincident. F5 still gives shimmering holes due to Z buffer fighting so you still need to make the cylinders longer to fix that. On 10 March 2016 at 22:04, Eric Buijs <ebuijs@mac.com> wrote: > Great, that took care of the problem. Thanks for the help. > > > > -- > View this message in context: > http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16399.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 >
EB
Eric Buijs
Thu, Mar 10, 2016 11:40 PM

I see, well the rotate module works like a charm. I had to do some catch-up
on my math to understand it however (and still don't understand it fully).
Thanks.

--
View this message in context: http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16401.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I see, well the rotate module works like a charm. I had to do some catch-up on my math to understand it however (and still don't understand it fully). Thanks. -- View this message in context: http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16401.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Fri, Mar 11, 2016 12:52 AM

nop head,

Interesting observation; however, it seems to me that your rotate would
require the same convertions.

2016-03-10 20:40 GMT-03:00 Eric Buijs ebuijs@mac.com:

I see, well the rotate module works like a charm. I had to do some catch-up
on my math to understand it however (and still don't understand it fully).
Thanks.

--
View this message in context:
http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16401.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

nop head, Interesting observation; however, it seems to me that your rotate would require the same convertions. 2016-03-10 20:40 GMT-03:00 Eric Buijs <ebuijs@mac.com>: > I see, well the rotate module works like a charm. I had to do some catch-up > on my math to understand it however (and still don't understand it fully). > Thanks. > > > > -- > View this message in context: > http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16401.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 >
JL
Jean-Paul Louis
Fri, Mar 11, 2016 12:59 AM

Why not using a simpler way like

H  = 90;
W  = 5;
D  = 55;
eps = 0.005;
H1  = H - 2 * W;
H2  = H + eps;
$fn = 360;

difference() {
cube([ H, H, H], center =true);
cube([H1,H1,H1], center =true);
cylinder(d = D, h = H2, center = true);
rotate([90,0,0]) cylinder(d = D, h = H2, center = true);
rotate([0,90,0]) cylinder(d = D, h = H2, center = true); }

Just my $0.02,

Jean-Paul
N1JPL

On Mar 10, 2016, at 7:52 PM, Ronaldo Persiano rcmpersiano@gmail.com wrote:

nop head,

Interesting observation; however, it seems to me that your rotate would require the same convertions.

2016-03-10 20:40 GMT-03:00 Eric Buijs ebuijs@mac.com:
I see, well the rotate module works like a charm. I had to do some catch-up
on my math to understand it however (and still don't understand it fully).
Thanks.

--
View this message in context: http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16401.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


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

Why not using a simpler way like H = 90; W = 5; D = 55; eps = 0.005; H1 = H - 2 * W; H2 = H + eps; $fn = 360; difference() { cube([ H, H, H], center =true); cube([H1,H1,H1], center =true); cylinder(d = D, h = H2, center = true); rotate([90,0,0]) cylinder(d = D, h = H2, center = true); rotate([0,90,0]) cylinder(d = D, h = H2, center = true); } Just my $0.02, Jean-Paul N1JPL > On Mar 10, 2016, at 7:52 PM, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > > nop head, > > Interesting observation; however, it seems to me that your rotate would require the same convertions. > > 2016-03-10 20:40 GMT-03:00 Eric Buijs <ebuijs@mac.com>: > I see, well the rotate module works like a charm. I had to do some catch-up > on my math to understand it however (and still don't understand it fully). > Thanks. > > > > -- > View this message in context: http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16401.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 > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
NH
nop head
Fri, Mar 11, 2016 8:51 AM

Yes but the OpenScad sin and cos functions exposed to the user has special
cases for 0, 30, 45, 90, etc. Unfortunately it doesn't use those internally
for rotate and generating circles.

On 11 March 2016 at 00:52, Ronaldo Persiano rcmpersiano@gmail.com wrote:

nop head,

Interesting observation; however, it seems to me that your rotate would
require the same convertions.

2016-03-10 20:40 GMT-03:00 Eric Buijs ebuijs@mac.com:

I see, well the rotate module works like a charm. I had to do some
catch-up
on my math to understand it however (and still don't understand it fully).
Thanks.

--
View this message in context:
http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16401.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

Yes but the OpenScad sin and cos functions exposed to the user has special cases for 0, 30, 45, 90, etc. Unfortunately it doesn't use those internally for rotate and generating circles. On 11 March 2016 at 00:52, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > nop head, > > Interesting observation; however, it seems to me that your rotate would > require the same convertions. > > 2016-03-10 20:40 GMT-03:00 Eric Buijs <ebuijs@mac.com>: > >> I see, well the rotate module works like a charm. I had to do some >> catch-up >> on my math to understand it however (and still don't understand it fully). >> Thanks. >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/Bug-in-OpenScad-rendering-tp16396p16401.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 >> > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >