discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

error in rendering when using decimal point in variable

B
blouwagie
Sat, May 7, 2016 5:00 PM

Hi

The following draws three rounded boxes. The one where there is a decimal
point in circle radius, does not render correctly. This seems like a bug to
me.  Do I post bugs somewhere else?

module mod_roundedbox(box_x,box_y,box_z,rounding_r)
{
union ()
{
cube ([box_x - rounding_r2, box_y,box_z],center=true); //narrower
in x direction
cube ([box_x,box_y - rounding_r
2,box_z],center=true); //narrower in
y direction

    for (x = [rounding_r-box_x/2:-rounding_r+box_x/2])
        for (y = [rounding_r-box_y/2:-rounding_r+box_y/2])
            translate ([x,y,0]) cylinder (r=rounding_r, h=box_z,

center=true);;
};
};

mod_roundedbox (154,72,c_wall_z,8); // renders correctly
translate ([0,80,0]) mod_roundedbox (154,72,c_wall_z,8.1); //renders
incorrectly, the circle no longer lines up on several places, only
difference is that the radius is 8.1 here, not 8. Not all renderings with
value behind decimal point fail.

Is this a bug or by design?  How can I get this fixed?

OpenSCAD version 2015.03-3  on Mac OS X 10.10.5

--
View this message in context: http://forum.openscad.org/error-in-rendering-when-using-decimal-point-in-variable-tp17293.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hi The following draws three rounded boxes. The one where there is a decimal point in circle radius, does not render correctly. This seems like a bug to me. Do I post bugs somewhere else? module mod_roundedbox(box_x,box_y,box_z,rounding_r) { union () { cube ([box_x - rounding_r*2, box_y,box_z],center=true); //narrower in x direction cube ([box_x,box_y - rounding_r*2,box_z],center=true); //narrower in y direction for (x = [rounding_r-box_x/2:-rounding_r+box_x/2]) for (y = [rounding_r-box_y/2:-rounding_r+box_y/2]) translate ([x,y,0]) cylinder (r=rounding_r, h=box_z, center=true);; }; }; mod_roundedbox (154,72,c_wall_z,8); // renders correctly translate ([0,80,0]) mod_roundedbox (154,72,c_wall_z,8.1); //renders incorrectly, the circle no longer lines up on several places, only difference is that the radius is 8.1 here, not 8. Not all renderings with value behind decimal point fail. Is this a bug or by design? How can I get this fixed? OpenSCAD version 2015.03-3 on Mac OS X 10.10.5 -- View this message in context: http://forum.openscad.org/error-in-rendering-when-using-decimal-point-in-variable-tp17293.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Sat, May 7, 2016 5:26 PM

This works:

module mod_roundedbox(box_x,box_y,box_z,rounding_r)
{
union ()
{
cube ([box_x - rounding_r2, box_y,box_z],center=true);
//narrowerin x direction
cube ([box_x,box_y - rounding_r
2,box_z],center=true); //narrower
iny direction

    for (x = [rounding_r-box_x/2, -rounding_r+box_x/2])
        for (y = [rounding_r-box_y/2, -rounding_r+box_y/2])
            translate ([x,y,0]) cylinder (r=rounding_r,

h=box_z,center=true);
}
}
c_wall_z = 20;

mod_roundedbox (154,72,c_wall_z,8.1);

With colons in the for statements you are generating lots of circles, not
just the corners. I.e. all the points between the two ends with a step size
of 1. When the size is not an integer the last circles are not in the
correct place.

On 7 May 2016 at 18:00, blouwagie bart@louwagie.com wrote:

Hi

The following draws three rounded boxes. The one where there is a decimal
point in circle radius, does not render correctly. This seems like a bug to
me.  Do I post bugs somewhere else?

module mod_roundedbox(box_x,box_y,box_z,rounding_r)
{
union ()
{
cube ([box_x - rounding_r2, box_y,box_z],center=true); //narrower
in x direction
cube ([box_x,box_y - rounding_r
2,box_z],center=true); //narrower
in
y direction

     for (x = [rounding_r-box_x/2:-rounding_r+box_x/2])
         for (y = [rounding_r-box_y/2:-rounding_r+box_y/2])
             translate ([x,y,0]) cylinder (r=rounding_r, h=box_z,

center=true);;
};
};

mod_roundedbox (154,72,c_wall_z,8); // renders correctly
translate ([0,80,0]) mod_roundedbox (154,72,c_wall_z,8.1); //renders
incorrectly, the circle no longer lines up on several places, only
difference is that the radius is 8.1 here, not 8. Not all renderings with
value behind decimal point fail.

Is this a bug or by design?  How can I get this fixed?

OpenSCAD version 2015.03-3  on Mac OS X 10.10.5

--
View this message in context:
http://forum.openscad.org/error-in-rendering-when-using-decimal-point-in-variable-tp17293.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 works: module mod_roundedbox(box_x,box_y,box_z,rounding_r) { union () { cube ([box_x - rounding_r*2, box_y,box_z],center=true); //narrowerin x direction cube ([box_x,box_y - rounding_r*2,box_z],center=true); //narrower iny direction for (x = [rounding_r-box_x/2, -rounding_r+box_x/2]) for (y = [rounding_r-box_y/2, -rounding_r+box_y/2]) translate ([x,y,0]) cylinder (r=rounding_r, h=box_z,center=true); } } c_wall_z = 20; mod_roundedbox (154,72,c_wall_z,8.1); With colons in the for statements you are generating lots of circles, not just the corners. I.e. all the points between the two ends with a step size of 1. When the size is not an integer the last circles are not in the correct place. On 7 May 2016 at 18:00, blouwagie <bart@louwagie.com> wrote: > Hi > > The following draws three rounded boxes. The one where there is a decimal > point in circle radius, does not render correctly. This seems like a bug to > me. Do I post bugs somewhere else? > > module mod_roundedbox(box_x,box_y,box_z,rounding_r) > { > union () > { > cube ([box_x - rounding_r*2, box_y,box_z],center=true); //narrower > in x direction > cube ([box_x,box_y - rounding_r*2,box_z],center=true); //narrower > in > y direction > > for (x = [rounding_r-box_x/2:-rounding_r+box_x/2]) > for (y = [rounding_r-box_y/2:-rounding_r+box_y/2]) > translate ([x,y,0]) cylinder (r=rounding_r, h=box_z, > center=true);; > }; > }; > > mod_roundedbox (154,72,c_wall_z,8); // renders correctly > translate ([0,80,0]) mod_roundedbox (154,72,c_wall_z,8.1); //renders > incorrectly, the circle no longer lines up on several places, only > difference is that the radius is 8.1 here, not 8. Not all renderings with > value behind decimal point fail. > > Is this a bug or by design? How can I get this fixed? > > OpenSCAD version 2015.03-3 on Mac OS X 10.10.5 > > > > -- > View this message in context: > http://forum.openscad.org/error-in-rendering-when-using-decimal-point-in-variable-tp17293.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 >
B
blouwagie
Sat, May 7, 2016 5:50 PM

Thank you nophead.
No wonder the rendering took so long too.

commas for single items in a list it is

--
View this message in context: http://forum.openscad.org/error-in-rendering-when-using-decimal-point-in-variable-tp17293p17295.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Thank you nophead. No wonder the rendering took so long too. commas for single items in a list it is -- View this message in context: http://forum.openscad.org/error-in-rendering-when-using-decimal-point-in-variable-tp17293p17295.html Sent from the OpenSCAD mailing list archive at Nabble.com.