Skip to content

Commit 8c0f979

Browse files
committed
Added x, y, and z args to various _half() modules.
1 parent 9486ea2 commit 8c0f979

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

transforms.scad

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,26 +1867,28 @@ module half_of(v=V_UP, cp=[0,0,0], s=100, planar=false)
18671867
// Module: top_half()
18681868
//
18691869
// Usage:
1870-
// top_half([cp], [s]) ...
1870+
// top_half([z|cp], [s]) ...
18711871
//
18721872
// Description:
18731873
// Slices an object at a horizontal X-Y cut plane, and masks away everything that is below it.
18741874
//
18751875
// Arguments:
18761876
// 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]
1877+
// z = The Z coordinate of the cut-plane, if given. Use instead of `cp`.
18771878
// 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
18781879
// planar = If true, this becomes equivalent to a planar `back_half()`.
18791880
//
18801881
// Examples(Spin):
18811882
// top_half() sphere(r=20);
1883+
// top_half(z=5) sphere(r=20);
18821884
// top_half(cp=5) sphere(r=20);
18831885
// top_half(cp=[0,0,-8]) sphere(r=20);
18841886
// Example(2D):
18851887
// top_half(planar=true) circle(r=20);
1886-
module top_half(s=100, cp=[0,0,0], planar=false)
1888+
module top_half(s=100, z=undef, cp=[0,0,0], planar=false)
18871889
{
18881890
dir = planar? V_BACK : V_UP;
1889-
cp = is_scalar(cp)? cp*dir : cp;
1891+
cp = is_scalar(z)? [0,0,z] : is_scalar(cp)? cp*dir : cp;
18901892
translate(cp) difference() {
18911893
translate(-cp) children();
18921894
translate(-dir*s/2) {
@@ -1904,26 +1906,28 @@ module top_half(s=100, cp=[0,0,0], planar=false)
19041906
// Module: bottom_half()
19051907
//
19061908
// Usage:
1907-
// bottom_half([cp], [s]) ...
1909+
// bottom_half([z|cp], [s]) ...
19081910
//
19091911
// Description:
19101912
// Slices an object at a horizontal X-Y cut plane, and masks away everything that is above it.
19111913
//
19121914
// Arguments:
19131915
// 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. Default: [0,0,0]
1916+
// z = The Z coordinate of the cut-plane, if given. Use instead of `cp`.
19141917
// 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
19151918
// planar = If true, this becomes equivalent to a planar `front_half()`.
19161919
//
19171920
// Examples:
19181921
// bottom_half() sphere(r=20);
1922+
// bottom_half(z=-10) sphere(r=20);
19191923
// bottom_half(cp=-10) sphere(r=20);
19201924
// bottom_half(cp=[0,0,10]) sphere(r=20);
19211925
// Example(2D):
19221926
// bottom_half(planar=true) circle(r=20);
1923-
module bottom_half(s=100, cp=[0,0,0], planar=false)
1927+
module bottom_half(s=100, z=undef, cp=[0,0,0], planar=false)
19241928
{
19251929
dir = planar? V_FWD : V_DOWN;
1926-
cp = is_scalar(cp)? cp*dir : cp;
1930+
cp = is_scalar(z)? [0,0,z] : is_scalar(cp)? cp*dir : cp;
19271931
translate(cp) difference() {
19281932
translate(-cp) children();
19291933
translate(-dir*s/2) {
@@ -1941,26 +1945,28 @@ module bottom_half(s=100, cp=[0,0,0], planar=false)
19411945
// Module: left_half()
19421946
//
19431947
// Usage:
1944-
// left_half([cp], [s]) ...
1948+
// left_half([x|cp], [s]) ...
19451949
//
19461950
// Description:
19471951
// Slices an object at a vertical Y-Z cut plane, and masks away everything that is right of it.
19481952
//
19491953
// Arguments:
19501954
// 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. Default: [0,0,0]
1955+
// x = The X coordinate of the cut-plane, if given. Use instead of `cp`.
19511956
// 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
19521957
// planar = If true, this becomes a 2D operation.
19531958
//
19541959
// Examples:
19551960
// left_half() sphere(r=20);
1961+
// left_half(x=-8) sphere(r=20);
19561962
// left_half(cp=-8) sphere(r=20);
19571963
// left_half(cp=[8,0,0]) sphere(r=20);
19581964
// Example(2D):
19591965
// left_half(planar=true) circle(r=20);
1960-
module left_half(s=100, cp=[0,0,0], planar=false)
1966+
module left_half(s=100, x=undef, cp=[0,0,0], planar=false)
19611967
{
19621968
dir = V_LEFT;
1963-
cp = is_scalar(cp)? cp*dir : cp;
1969+
cp = is_scalar(x)? [x,0,0] : is_scalar(cp)? cp*dir : cp;
19641970
translate(cp) difference() {
19651971
translate(-cp) children();
19661972
translate(-dir*s/2) {
@@ -1978,26 +1984,28 @@ module left_half(s=100, cp=[0,0,0], planar=false)
19781984
// Module: right_half()
19791985
//
19801986
// Usage:
1981-
// right_half([cp], [s]) ...
1987+
// right_half([x|cp], [s]) ...
19821988
//
19831989
// Description:
19841990
// Slices an object at a vertical Y-Z cut plane, and masks away everything that is left of it.
19851991
//
19861992
// Arguments:
19871993
// 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]
1994+
// x = The X coordinate of the cut-plane, if given. Use instead of `cp`.
19881995
// 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
19891996
// planar = If true, this becomes a 2D operation.
19901997
//
19911998
// Examples(FlatSpin):
19921999
// right_half() sphere(r=20);
2000+
// right_half(x=-5) sphere(r=20);
19932001
// right_half(cp=-5) sphere(r=20);
19942002
// right_half(cp=[-5,0,0]) sphere(r=20);
19952003
// Example(2D):
19962004
// right_half(planar=true) circle(r=20);
1997-
module right_half(s=100, cp=[0,0,0], planar=false)
2005+
module right_half(s=100, x=undef, cp=[0,0,0], planar=false)
19982006
{
19992007
dir = V_RIGHT;
2000-
cp = is_scalar(cp)? cp*dir : cp;
2008+
cp = is_scalar(x)? [x,0,0] : is_scalar(cp)? cp*dir : cp;
20012009
translate(cp) difference() {
20022010
translate(-cp) children();
20032011
translate(-dir*s/2) {
@@ -2015,26 +2023,28 @@ module right_half(s=100, cp=[0,0,0], planar=false)
20152023
// Module: front_half()
20162024
//
20172025
// Usage:
2018-
// front_half([cp], [s]) ...
2026+
// front_half([y|cp], [s]) ...
20192027
//
20202028
// Description:
20212029
// Slices an object at a vertical X-Z cut plane, and masks away everything that is behind it.
20222030
//
20232031
// Arguments:
20242032
// 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. Default: [0,0,0]
2033+
// y = The Y coordinate of the cut-plane, if given. Use instead of `cp`.
20252034
// 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
20262035
// planar = If true, this becomes a 2D operation.
20272036
//
20282037
// Examples(FlatSpin):
20292038
// front_half() sphere(r=20);
2039+
// front_half(y=5) sphere(r=20);
20302040
// front_half(cp=5) sphere(r=20);
20312041
// front_half(cp=[0,5,0]) sphere(r=20);
20322042
// Example(2D):
20332043
// front_half(planar=true) circle(r=20);
2034-
module front_half(s=100, cp=[0,0,0], planar=false)
2044+
module front_half(s=100, y=undef, cp=[0,0,0], planar=false)
20352045
{
20362046
dir = V_FWD;
2037-
cp = is_scalar(cp)? cp*dir : cp;
2047+
cp = is_scalar(y)? [0,y,0] : is_scalar(cp)? cp*dir : cp;
20382048
translate(cp) difference() {
20392049
translate(-cp) children();
20402050
translate(-dir*s/2) {
@@ -2052,26 +2062,28 @@ module front_half(s=100, cp=[0,0,0], planar=false)
20522062
// Module: back_half()
20532063
//
20542064
// Usage:
2055-
// back_half([cp], [s]) ...
2065+
// back_half([y|cp], [s]) ...
20562066
//
20572067
// Description:
20582068
// Slices an object at a vertical X-Z cut plane, and masks away everything that is in front of it.
20592069
//
20602070
// Arguments:
20612071
// 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]
2072+
// y = The Y coordinate of the cut-plane, if given. Use instead of `cp`.
20622073
// 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
20632074
// planar = If true, this becomes a 2D operation.
20642075
//
20652076
// Examples:
20662077
// back_half() sphere(r=20);
2078+
// back_half(y=8) sphere(r=20);
20672079
// back_half(cp=8) sphere(r=20);
20682080
// back_half(cp=[0,-10,0]) sphere(r=20);
20692081
// Example(2D):
20702082
// back_half(planar=true) circle(r=20);
2071-
module back_half(s=100, cp=[0,0,0], planar=false)
2083+
module back_half(s=100, y=undef, cp=[0,0,0], planar=false)
20722084
{
20732085
dir = V_BACK;
2074-
cp = is_scalar(cp)? cp*dir : cp;
2086+
cp = is_scalar(y)? [0,y,0] : is_scalar(cp)? cp*dir : cp;
20752087
translate(cp) difference() {
20762088
translate(-cp) children();
20772089
translate(-dir*s/2) {

0 commit comments

Comments
 (0)