revarbat / BOSL

The Belfry OpenScad Library - A library of tools, shapes, and helpers to make OpenScad easier to use.
https://github.com/revarbat/BOSL/wiki
BSD 2-Clause "Simplified" License
571 stars 62 forks source link

Default alignment of tube - vertically not centered #80

Closed fe60 closed 3 years ago

fe60 commented 3 years ago

Describe the bug Creating a tube without declaring any alignment, does not center the object vertically. According to the documentation [1], this should be the case. Only adding the parameter center=true gives the expected result. But this parameter does not appear in the documentation. Completely surprising is the fact, that align=V_BACK changes the vertical alignment from UP to CENTER.

Code To Reproduce Bug

include <BOSL/constants.scad>
use <BOSL/shapes.scad>
use <BOSL/transforms.scad>
$fn=60;

// not centered vertically
tube(od=15, id=10, h=10);
// centered vertically using a parameter not mentioned in the documentation
xmove(20)
tube(od=15, id=10, h=10, center=true);
// moving the object to the back changes the vertical alignment to centered
xmove(40)
tube(od=15, id=10, h=10, align=V_BACK);

Screenshots BOSLtubeAlignmentBug

Expected behavior The default vertical alignment should be centered.

Additional context OpenSCAD Version: 2019.05

[1] https://github.com/revarbat/BOSL/wiki/shapes.scad#tube

fe60 commented 3 years ago

The unexpected behavior seems to be caused by the default value for the align parameter of the tube module. It's ALIGN_POS instead of ALIGN_CENTER. https://github.com/revarbat/BOSL/blob/master/shapes.scad#L1200

Changing the default value will break models that rely on the current implementation. So instead of fixing this, I propose to adjust the documentation. https://github.com/revarbat/BOSL/wiki/shapes.scad#tube

Proposal: https://github.com/fe60/bosl-wiki/commit/b67b66a0e32855081e25fc01742fbde7a8186598