Skip to content

Commit

Permalink
Merge pull request #1308 from BelfrySCAD/revarbat_dev
Browse files Browse the repository at this point in the history
Added catenary_path().
  • Loading branch information
revarbat authored Nov 29, 2023
2 parents 919dbda + fb2cfba commit 9ef3abc
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 155 deletions.
29 changes: 10 additions & 19 deletions .github/workflows/pr_merge.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
name: VersionBump
on:
pull_request:
types:
- closed
types: [closed]

jobs:
VersionBump:
if: github.event.pull_request.merged == true
VersionBumpJob:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Apt Update
run: sudo apt update
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Bump Version
id: commit
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
run: |
cd $GITHUB_WORKSPACE
./scripts/increment_version.sh
run: ./scripts/increment_version.sh

- name: Push changes
- name: Checkin
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: master
commit_user_email: [email protected]
commit_message: Version Bump


file_pattern: version.scad

1 change: 1 addition & 0 deletions WRITING_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ metadata directives:
- `Anim`: Make an animation where `$t` varies from `0.0` to almost `1.0`.
- `Frames=36`: Number of animation frames to make.
- `FrameMS=250`: Sets the number of milliseconds per frame for spins and animation.
- `FPS=8`: Sets the number of frames per second for spins and animation.
- `Small`: Make the image small sized.
- `Med`: Make the image medium sized.
- `Big`: Make the image big sized.
Expand Down
83 changes: 83 additions & 0 deletions drawing.scad
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,89 @@ module arc(n, r, angle, d, cp, points, corner, width, thickness, start, wedge=fa
}


// Function: catenary()
// Synopsis: Returns a 2D Catenary chain or arch path.
// SynTags: Path
// Topics: Paths
// See Also: circle(), stroke()
// Usage:
// path = catenary(width, droop=|angle=, n=);
// Description:
// Returns a 2D Catenary path, which is the path a chain held at both ends will take.
// The path will have the endpoints at `[±width/2, 0]`, and the middle of the path will droop
// towards Y- if the given droop= or angle= is positive. It will droop towards Y+ if the
// droop= or angle= is negative. You *must* specify one of droop= or angle=.
// Arguments:
// width = The straight-line distance between the endpoints of the path.
// 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.
// n = The number of points to return in the path. Default: 100
// ---
// 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.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). (Module only) Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). (Module only) Default: `0`
// Example(2D): By Droop
// stroke(catenary(100, droop=30));
// Example(2D): By Angle
// stroke(catenary(100, angle=30));
// Example(2D): Upwards Arch by Angle
// stroke(catenary(100, angle=30));
// Example(2D): Upwards Arch by Height Delta
// stroke(catenary(100, droop=-30));
// Example(2D): Specifying Vertex Count
// stroke(catenary(100, angle=-85, n=11), dots="dot");
// Example: Sweeping a Catenary Path
// path = xrot(90, p=path3d(catenary(100, droop=20, n=41)));
// path_sweep(circle(r=1.5, $fn=24), path);
function catenary(width, droop, n=100, angle) =
assert(one_defined([droop, angle],"droop,angle"))
let(
sgn = is_undef(droop)? sign(angle) : sign(droop),
droop = droop==undef? undef : abs(droop),
angle = angle==undef? undef : abs(angle)
)
assert(is_finite(width) && width>0, "Bad width= value.")
assert(is_integer(n) && n>0, "Bad n= value. Must be a positive integer.")
assert(is_undef(droop) || is_finite(droop), "Bad droop= value.")
assert(is_undef(angle) || (is_finite(angle) && angle != 0 && abs(angle) < 90), "Bad angle= value.")
let(
catlup_fn = is_undef(droop)
? function(x) let(
p1 = [x-0.001, cosh(x-0.001)-1],
p2 = [x+0.001, cosh(x+0.001)-1],
delta = p2-p1,
ang = atan2(delta.y, delta.x)
) ang
: function(x) (cosh(x)-1)/x,
binsearch_fn = function(targ,x=0,inc=4)
inc < 1e-9? lookup(targ,[[catlup_fn(x),x],[catlup_fn(x+inc),x+inc]]) :
catlup_fn(x+inc) > targ? binsearch_fn(targ,x,inc/2) :
binsearch_fn(targ,x+inc,inc),
scx = is_undef(droop)? binsearch_fn(angle) :
binsearch_fn(droop / (width/2)),
sc = width/2 / scx,
droop = !is_undef(droop)? droop : (cosh(scx)-1) * sc,
path = [
for (x = lerpn(-scx,scx,n))
let(
xval = x * sc,
yval = approx(abs(x),scx)? 0 :
(cosh(x)-1) * sc - droop
)
[xval, yval]
],
out = sgn>0? path : yflip(p=path)
) out;


module catenary(width, droop, n=100, angle, anchor=CTR, spin=0) {
path = catenary(width=width, droop=droop, n=n, angle=angle);
attachable(anchor,spin, two_d=true, path=path, extent=true) {
polygon(path);
children();
}
}


// Function: helix()
// Synopsis: Creates a 2d spiral or 3d helical path.
// SynTags: Path
Expand Down
Loading

0 comments on commit 9ef3abc

Please sign in to comment.