mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-04 03:09:45 +00:00
Added offsetcube()
This commit is contained in:
parent
8ee896280b
commit
97cca892d3
1 changed files with 19 additions and 0 deletions
19
shapes.scad
19
shapes.scad
|
@ -39,6 +39,25 @@ include <math.scad>
|
||||||
module nil() union() {}
|
module nil() union() {}
|
||||||
|
|
||||||
|
|
||||||
|
// Makes a cube that is offset along the given vector by half the cube's size.
|
||||||
|
// For example, if v=[-1,1,0], the cube's front right edge will be centered at the origin.
|
||||||
|
// size = size of cube.
|
||||||
|
// v = vector to offset along.
|
||||||
|
// Example:
|
||||||
|
// offsetcube([3,4,5], [-1,1,0]);
|
||||||
|
module offsetcube(size=[1,1,1], v=[0,0,0]) {
|
||||||
|
lx=len(size)==undef? size : size[0];
|
||||||
|
ly=len(size)==undef? size : size[1];
|
||||||
|
lz=len(size)==undef? size : size[2];
|
||||||
|
ax=len(v)==undef? v : v[0];
|
||||||
|
ay=len(v)==undef? v : v[1];
|
||||||
|
az=len(v)==undef? v : v[2];
|
||||||
|
translate([lx*ax/2, ly*ay/2, lz*az/2]) {
|
||||||
|
cube(size, center=true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Makes a cube that has its right face centered at the origin.
|
// Makes a cube that has its right face centered at the origin.
|
||||||
module leftcube(size=[1,1,1]) {l=len(size)==undef? size : size[0]; left(l/2) cube(size, center=true);}
|
module leftcube(size=[1,1,1]) {l=len(size)==undef? size : size[0]; left(l/2) cube(size, center=true);}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue