Changed cp args in _half() moduled to x, y, or z.

This commit is contained in:
Revar Desmera 2019-05-02 12:05:22 -07:00
parent aa3af91889
commit a6a2ed520b

View File

@ -1723,29 +1723,28 @@ module half_of(v=UP, cp=[0,0,0], s=100, planar=false)
// Module: left_half() // Module: left_half()
// //
// Usage: // Usage:
// left_half([cp], [s]) ... // left_half([s], [x]) ...
// left_half(planar=true, [s], [x]) ...
// //
// Description: // Description:
// Slices an object at a vertical Y-Z cut plane, and masks away everything that is right of it. // Slices an object at a vertical Y-Z cut plane, and masks away everything that is right of it.
// //
// Arguments: // Arguments:
// cp = If given as a scalar, moves the cut plane left by the given amount. If given as a point, specifies a point on the cut plane. NOTE: a `cp` of 5 is equivalent to a `cp` of `[-5,0,0]`, *not* `[5,0,0]`! Default: [0,0,0]
// s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100 // s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100
// x = The X coordinate of the cut-plane. Default: 0
// planar = If true, this becomes a 2D operation. // planar = If true, this becomes a 2D operation.
// //
// Examples: // Examples:
// left_half() sphere(r=20); // left_half() sphere(r=20);
// left_half(cp=-8) sphere(r=20); // left_half(x=-8) sphere(r=20);
// left_half(cp=[8,0,0]) sphere(r=20);
// Example(2D): // Example(2D):
// left_half(planar=true) circle(r=20); // left_half(planar=true) circle(r=20);
module left_half(s=100, cp=[0,0,0], planar=false) module left_half(s=100, x=0, planar=false)
{ {
dir = LEFT; dir = LEFT;
cp = is_num(cp)? cp*dir : cp;
difference() { difference() {
children(); children();
translate(cp-dir*s/2) { translate([x,0,0]-dir*s/2) {
if (planar) { if (planar) {
square(s, center=true); square(s, center=true);
} else { } else {
@ -1760,29 +1759,28 @@ module left_half(s=100, cp=[0,0,0], planar=false)
// Module: right_half() // Module: right_half()
// //
// Usage: // Usage:
// right_half([cp], [s]) ... // right_half([s], [x]) ...
// right_half(planar=true, [s], [x]) ...
// //
// Description: // Description:
// Slices an object at a vertical Y-Z cut plane, and masks away everything that is left of it. // Slices an object at a vertical Y-Z cut plane, and masks away everything that is left of it.
// //
// Arguments: // Arguments:
// cp = If given as a scalar, moves the cut plane right by the given amount. If given as a point, specifies a point on the cut plane. Default: [0,0,0]
// s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100 // s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100
// x = The X coordinate of the cut-plane. Default: 0
// planar = If true, this becomes a 2D operation. // planar = If true, this becomes a 2D operation.
// //
// Examples(FlatSpin): // Examples(FlatSpin):
// right_half() sphere(r=20); // right_half() sphere(r=20);
// right_half(cp=-5) sphere(r=20); // right_half(x=-5) sphere(r=20);
// right_half(cp=[-5,0,0]) sphere(r=20);
// Example(2D): // Example(2D):
// right_half(planar=true) circle(r=20); // right_half(planar=true) circle(r=20);
module right_half(s=100, cp=[0,0,0], planar=false) module right_half(s=100, x=0, planar=false)
{ {
dir = RIGHT; dir = RIGHT;
cp = is_num(cp)? cp*dir : cp;
difference() { difference() {
children(); children();
translate(cp-dir*s/2) { translate([x,0,0]-dir*s/2) {
if (planar) { if (planar) {
square(s, center=true); square(s, center=true);
} else { } else {
@ -1797,29 +1795,28 @@ module right_half(s=100, cp=[0,0,0], planar=false)
// Module: front_half() // Module: front_half()
// //
// Usage: // Usage:
// front_half([cp], [s]) ... // front_half([s], [y]) ...
// front_half(planar=true, [s], [y]) ...
// //
// Description: // Description:
// Slices an object at a vertical X-Z cut plane, and masks away everything that is behind it. // Slices an object at a vertical X-Z cut plane, and masks away everything that is behind it.
// //
// Arguments: // Arguments:
// cp = If given as a scalar, moves the cut plane forward by the given amount. If given as a point, specifies a point on the cut plane. NOTE: a `cp` of 5 is equivalent to a `cp` of `[0,-5,0]`, *not* `[0,5,0]`! Default: [0,0,0]
// s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100 // s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100
// y = The Y coordinate of the cut-plane. Default: 0
// planar = If true, this becomes a 2D operation. // planar = If true, this becomes a 2D operation.
// //
// Examples(FlatSpin): // Examples(FlatSpin):
// front_half() sphere(r=20); // front_half() sphere(r=20);
// front_half(cp=5) sphere(r=20); // front_half(y=5) sphere(r=20);
// front_half(cp=[0,5,0]) sphere(r=20);
// Example(2D): // Example(2D):
// front_half(planar=true) circle(r=20); // front_half(planar=true) circle(r=20);
module front_half(s=100, cp=[0,0,0], planar=false) module front_half(s=100, y=0, planar=false)
{ {
dir = FWD; dir = FWD;
cp = is_num(cp)? cp*dir : cp;
difference() { difference() {
children(); children();
translate(cp-dir*s/2) { translate([0,y,0]-dir*s/2) {
if (planar) { if (planar) {
square(s, center=true); square(s, center=true);
} else { } else {
@ -1834,29 +1831,28 @@ module front_half(s=100, cp=[0,0,0], planar=false)
// Module: back_half() // Module: back_half()
// //
// Usage: // Usage:
// back_half([cp], [s]) ... // back_half([s], [y]) ...
// back_half(planar=true, [s], [y]) ...
// //
// Description: // Description:
// Slices an object at a vertical X-Z cut plane, and masks away everything that is in front of it. // Slices an object at a vertical X-Z cut plane, and masks away everything that is in front of it.
// //
// Arguments: // Arguments:
// cp = If given as a scalar, moves the cut plane back by the given amount. If given as a point, specifies a point on the cut plane. Default: [0,0,0]
// s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100 // s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100
// y = The Y coordinate of the cut-plane. Default: 0
// planar = If true, this becomes a 2D operation. // planar = If true, this becomes a 2D operation.
// //
// Examples: // Examples:
// back_half() sphere(r=20); // back_half() sphere(r=20);
// back_half(cp=8) sphere(r=20); // back_half(y=8) sphere(r=20);
// back_half(cp=[0,-10,0]) sphere(r=20);
// Example(2D): // Example(2D):
// back_half(planar=true) circle(r=20); // back_half(planar=true) circle(r=20);
module back_half(s=100, cp=[0,0,0], planar=false) module back_half(s=100, y=0, planar=false)
{ {
dir = BACK; dir = BACK;
cp = is_num(cp)? cp*dir : cp;
difference() { difference() {
children(); children();
translate(cp-dir*s/2) { translate([0,y,0]-dir*s/2) {
if (planar) { if (planar) {
square(s, center=true); square(s, center=true);
} else { } else {
@ -1871,74 +1867,56 @@ module back_half(s=100, cp=[0,0,0], planar=false)
// Module: bottom_half() // Module: bottom_half()
// //
// Usage: // Usage:
// bottom_half([cp], [s]) ... // bottom_half([s], [z]) ...
// //
// Description: // Description:
// Slices an object at a horizontal X-Y cut plane, and masks away everything that is above it. // Slices an object at a horizontal X-Y cut plane, and masks away everything that is above it.
// //
// Arguments: // Arguments:
// cp = If given as a scalar, moves the cut plane down by the given amount. If given as a point, specifies a point on the cut plane. NOTE: a `cp` of 5 is equivalent to a `cp` of `[0,0,-5]`, *not* `[0,0,5]`! Default: [0,0,0]
// s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100 // s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100
// planar = If true, this becomes equivalent to a planar `front_half()`. // z = The Z coordinate of the cut-plane. Default: 0
// //
// Examples: // Examples:
// bottom_half() sphere(r=20); // bottom_half() sphere(r=20);
// bottom_half(cp=-10) sphere(r=20); // bottom_half(z=-10) sphere(r=20);
// bottom_half(cp=[0,0,10]) sphere(r=20); module bottom_half(s=100, z=0)
// Example(2D):
// bottom_half(planar=true) circle(r=20);
module bottom_half(s=100, cp=[0,0,0], planar=false)
{ {
dir = planar? FWD : DOWN; dir = DOWN;
cp = is_num(cp)? cp*dir : cp;
difference() { difference() {
children(); children();
translate(cp-dir*s/2) { translate([0,0,z]-dir*s/2) {
if (planar) {
square(s, center=true);
} else {
cube(s, center=true); cube(s, center=true);
} }
} }
} }
}
// Module: top_half() // Module: top_half()
// //
// Usage: // Usage:
// top_half([cp], [s]) ... // top_half([s], [z]) ...
// //
// Description: // Description:
// Slices an object at a horizontal X-Y cut plane, and masks away everything that is below it. // Slices an object at a horizontal X-Y cut plane, and masks away everything that is below it.
// //
// Arguments: // Arguments:
// cp = If given as a scalar, moves the cut plane up by the given amount. If given as a point, specifies a point on the cut plane. Default: [0,0,0]
// s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100 // s = Mask size to use. Use a number larger than twice your object's largest axis. If you make this too large, it messes with centering your view. Default: 100
// planar = If true, this becomes equivalent to a planar `back_half()`. // z = The Z coordinate of the cut-plane. Default: 0
// //
// Examples(Spin): // Examples(Spin):
// top_half() sphere(r=20); // top_half() sphere(r=20);
// top_half(cp=5) sphere(r=20); // top_half(z=5) sphere(r=20);
// top_half(cp=[0,0,-8]) sphere(r=20); module top_half(s=100, z=0)
// Example(2D):
// top_half(planar=true) circle(r=20);
module top_half(s=100, cp=[0,0,0], planar=false)
{ {
dir = planar? BACK : UP; dir = UP;
cp = is_num(cp)? cp*dir : cp;
difference() { difference() {
children(); children();
translate(cp-dir*s/2) { translate([0,0,z]-dir*s/2) {
if (planar) {
square(s, center=true);
} else {
cube(s, center=true); cube(s, center=true);
} }
} }
} }
}