Skip to content

Commit 9ef3abc

Browse files
authored
Merge pull request #1308 from BelfrySCAD/revarbat_dev
Added catenary_path().
2 parents 919dbda + fb2cfba commit 9ef3abc

File tree

9 files changed

+373
-155
lines changed

9 files changed

+373
-155
lines changed

.github/workflows/pr_merge.yml

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
name: VersionBump
22
on:
33
pull_request:
4-
types:
5-
- closed
4+
types: [closed]
65

76
jobs:
8-
VersionBump:
9-
if: github.event.pull_request.merged == true
7+
VersionBumpJob:
108
runs-on: ubuntu-latest
9+
if: github.event.pull_request.merged == true
1110
permissions:
1211
contents: write
12+
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v3
16-
17-
- name: Apt Update
18-
run: sudo apt update
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.head_ref }}
1918

2019
- name: Bump Version
21-
id: commit
22-
env:
23-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
24-
run: |
25-
cd $GITHUB_WORKSPACE
26-
./scripts/increment_version.sh
20+
run: ./scripts/increment_version.sh
2721

28-
- name: Push changes
22+
- name: Checkin
2923
uses: stefanzweifel/git-auto-commit-action@v5
3024
with:
31-
branch: master
32-
commit_user_email: [email protected]
3325
commit_message: Version Bump
34-
35-
26+
file_pattern: version.scad
3627

WRITING_DOCS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ metadata directives:
633633
- `Anim`: Make an animation where `$t` varies from `0.0` to almost `1.0`.
634634
- `Frames=36`: Number of animation frames to make.
635635
- `FrameMS=250`: Sets the number of milliseconds per frame for spins and animation.
636+
- `FPS=8`: Sets the number of frames per second for spins and animation.
636637
- `Small`: Make the image small sized.
637638
- `Med`: Make the image medium sized.
638639
- `Big`: Make the image big sized.

drawing.scad

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,89 @@ module arc(n, r, angle, d, cp, points, corner, width, thickness, start, wedge=fa
864864
}
865865

866866

867+
// Function: catenary()
868+
// Synopsis: Returns a 2D Catenary chain or arch path.
869+
// SynTags: Path
870+
// Topics: Paths
871+
// See Also: circle(), stroke()
872+
// Usage:
873+
// path = catenary(width, droop=|angle=, n=);
874+
// Description:
875+
// Returns a 2D Catenary path, which is the path a chain held at both ends will take.
876+
// The path will have the endpoints at `[±width/2, 0]`, and the middle of the path will droop
877+
// towards Y- if the given droop= or angle= is positive. It will droop towards Y+ if the
878+
// droop= or angle= is negative. You *must* specify one of droop= or angle=.
879+
// Arguments:
880+
// width = The straight-line distance between the endpoints of the path.
881+
// droop = If given, specifies the height difference between the endpoints and the hanging middle of the path. If given a negative value, returns an arch *above* the Y axis.
882+
// n = The number of points to return in the path. Default: 100
883+
// ---
884+
// angle = If given, specifies the angle that the path will droop by at the endpoints. If given a negative value, returns an arch *above* the Y axis.
885+
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). (Module only) Default: `CENTER`
886+
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). (Module only) Default: `0`
887+
// Example(2D): By Droop
888+
// stroke(catenary(100, droop=30));
889+
// Example(2D): By Angle
890+
// stroke(catenary(100, angle=30));
891+
// Example(2D): Upwards Arch by Angle
892+
// stroke(catenary(100, angle=30));
893+
// Example(2D): Upwards Arch by Height Delta
894+
// stroke(catenary(100, droop=-30));
895+
// Example(2D): Specifying Vertex Count
896+
// stroke(catenary(100, angle=-85, n=11), dots="dot");
897+
// Example: Sweeping a Catenary Path
898+
// path = xrot(90, p=path3d(catenary(100, droop=20, n=41)));
899+
// path_sweep(circle(r=1.5, $fn=24), path);
900+
function catenary(width, droop, n=100, angle) =
901+
assert(one_defined([droop, angle],"droop,angle"))
902+
let(
903+
sgn = is_undef(droop)? sign(angle) : sign(droop),
904+
droop = droop==undef? undef : abs(droop),
905+
angle = angle==undef? undef : abs(angle)
906+
)
907+
assert(is_finite(width) && width>0, "Bad width= value.")
908+
assert(is_integer(n) && n>0, "Bad n= value. Must be a positive integer.")
909+
assert(is_undef(droop) || is_finite(droop), "Bad droop= value.")
910+
assert(is_undef(angle) || (is_finite(angle) && angle != 0 && abs(angle) < 90), "Bad angle= value.")
911+
let(
912+
catlup_fn = is_undef(droop)
913+
? function(x) let(
914+
p1 = [x-0.001, cosh(x-0.001)-1],
915+
p2 = [x+0.001, cosh(x+0.001)-1],
916+
delta = p2-p1,
917+
ang = atan2(delta.y, delta.x)
918+
) ang
919+
: function(x) (cosh(x)-1)/x,
920+
binsearch_fn = function(targ,x=0,inc=4)
921+
inc < 1e-9? lookup(targ,[[catlup_fn(x),x],[catlup_fn(x+inc),x+inc]]) :
922+
catlup_fn(x+inc) > targ? binsearch_fn(targ,x,inc/2) :
923+
binsearch_fn(targ,x+inc,inc),
924+
scx = is_undef(droop)? binsearch_fn(angle) :
925+
binsearch_fn(droop / (width/2)),
926+
sc = width/2 / scx,
927+
droop = !is_undef(droop)? droop : (cosh(scx)-1) * sc,
928+
path = [
929+
for (x = lerpn(-scx,scx,n))
930+
let(
931+
xval = x * sc,
932+
yval = approx(abs(x),scx)? 0 :
933+
(cosh(x)-1) * sc - droop
934+
)
935+
[xval, yval]
936+
],
937+
out = sgn>0? path : yflip(p=path)
938+
) out;
939+
940+
941+
module catenary(width, droop, n=100, angle, anchor=CTR, spin=0) {
942+
path = catenary(width=width, droop=droop, n=n, angle=angle);
943+
attachable(anchor,spin, two_d=true, path=path, extent=true) {
944+
polygon(path);
945+
children();
946+
}
947+
}
948+
949+
867950
// Function: helix()
868951
// Synopsis: Creates a 2d spiral or 3d helical path.
869952
// SynTags: Path

0 commit comments

Comments
 (0)