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

[BUG] ydistribute is offset #91

Open tree68505 opened 2 years ago

tree68505 commented 2 years ago

Describe the bug ydistribute is offset by one in the negative y direction. The code must offset a cube of the same dimensions by one in the negative y direction to properly align with the distribution.

Code To Reproduce Bug

$fn=100;
include<BOSL/shapes.scad>
include<BOSL/transforms.scad>

$AA_dia = 15;
$AAA_dia = 11;
$spacing = 3;
$wiggle_room = .5;
$height = 12;
$box_x = (4*$spacing)+(4*$AA_dia);
$box_y = (2*$AA_dia)+(2*$AAA_dia)+(3*$spacing);

difference(){
//bug?
  //translate([0,-1,0])
  {
  cube([$box_x,$box_y,$height],center=true);
  }
#ydistribute(spacing=$spacing,sizes=[$AA_dia,$AA_dia,$AAA_dia,$AAA_dia]){
aa_bats();
aa_bats();
aaa_bats();
aaa_bats();
}
}
module aaa_bats()
{
  xspread(spacing=$AAA_dia+$spacing, n=5)
 { 
   cyl(l=$height+$wiggle_room,r=($AAA_dia/2));
 }
}
module aa_bats()
{
  xspread(spacing=$AA_dia+$spacing, n=4)
 { 
   cyl(l=$height+$wiggle_room,r=($AA_dia/2));
 }
}

Expected behavior ydistrubute should center on the x-axis.

Screenshots bug

Additional context Add any other context about the problem here.